Witam. Przybywam ponownie na to forum aby prosic o pomoc przy pewnej petli a mianowicie:
Mam UID gracza - 3 i chcem znalezc konta online, ktore posiadaja takowe UID przypisane do konta i pobrac ich ID.
Przyklad: UID 3, Konto, ktore posiada to UID to Darkness a jego ID w grze to np. 15.
Jesli ktos czegos nie zrozumial to prosze pisac ponizej a jak ktos wie jak to ogarnac to zapraszam do komentarzy. Stawiam respekt za pomoc.
Ps. Moja aktualna petla, ktorej uzywam w GM wyglada tak:
foreach(Player, playersid)
{
if(PlayerInfo[playersid][pID] == PlayerInfo[playerid][pDialogData])
{
playersid = PlayerID;
}
}
function najblizszadel( playerSource, commandName ) local najblizsze = 3
local iddousuniecia = 9999
x2,y2,z2 = getElementPosition(playerSource)
for k,v in ipairs ( getElementsByType ( "object" )) do
if getElementModel(v) == 4032 then
x1,y1,z1 = getElementPosition(v) odleglosc = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2)
if odleglosc < najblizsze then
iddousuniecia = v
najblizsze = odleglosc
end
end
end
destroyElement(iddousuniecia) -- ta linijka nie dziala
end
addCommandHandler ( "usun", najblizszadel)
B??d:
Bad argument @ 'destroyElement' [Expected element at argument 1, got boolean]
addCommandHandler("walizz", function(plr,cmd)
for i,v in ipairs(waliza) do local x, y, z = getElementPosition(plr) createPickup ( x, y+3, z, v[1], v[2], v[3], v[4]) end)
B??dy w db3: ERROR: loading script failed: cores.lua:326: unexpected symbol near ')'
local znajdzki = {
["id znajdzki,x,y,z,"] = "id znajdzki tzn blue t-shirt itd.",
}
Wiem ,?e si? da tak? tabelk? zrobi? tylko nie za bardzo wiem jak.
2 sprawa to chc? by jak kto? znalaz? znajdzke to ?eby jak 2 raz w t? sam? wchodzi? pisa?o Znalaz?e? ju? t? znajdzke. Do tego ta tabela si? przyda pewnie.
Cze??. Od razu m?wi? ?e nie chc? bezsensownych temat?w od os?b, kt?re chc? nabi? posty a nie pom?c mi z tym problemem.
Ot?? m?j problem polega na tym ?e usuwam elementy z tablicy lecz zamiast wszystkich element?w usuwaj? si? no, powiedzmy, wszystkie opr?cz ostatniego elementu.
M?j kod:
function destroy(global_id)
if not global_id then return end
for key, value in pairs(element['text']) do
if value['global_id'] == tostring(global_id) then
table.remove(element['text'], key) end
end
end
Oczywi?cie u?ywam to tak
destroy('test')
Wiele os?b b?dzie m?wi? ?e to trzeba da? w tonumber, ale w moim global_id nie jest liczba tylko tekst.
Pr?bowa?em te? usuwa? wszystkie elementy z danego ID w taki spos?b
function destroy(global_id)
if not global_id then return end
for key, value in pairs(element['text']) do
if value['global_id'] == tostring(global_id) then
element['text'][key] = nil
end
end
end
Ale po tym u?yciu nie dzia?a tak jakby warunek ...
Licz? na pomoc, takie rzeczy mi si? nigdy nie zdarza?y.
Cze??, napisa?em sobie prosty system ?owienia ryb i chcia?em zrobi? "wykrywanie" czy gracz jest przy ?owisku, wi?c napisa?em sobie taki kodzik u?ywaj?c p?tli
Tak jak w tytule. Zrobi?em prac? i mam 2 problem. Jednym z nich jest w?a?nie "onClientMarkerHit", kt?ry ?apie z byle jakiej wysoko?ci i nie wiem jak temu zaradzi?.
Drugim problemem jest p?tla, kt?rej nie umiem zrobi? , posiadam mianowicie markery na math.random i jak wjedzie si? w marker (np. zaladunku) to pojawia si? marker (np. roz?adunku), a nie umiem ju? zrobi? tak, ?eby to si? tak w k??ko powtarza?o. xd
witam robi mi si? p?tla w mysql zapisywaniu nie wiem jak to rozwi?za? je?li jest tyle os?b na duty tyle razy zapisuje si? text w mysql a nie 1 rekord kod : [lua]
addCommandHandler('e', function(plr,cmd, ...)
local name = getPlayerName(plr):gsub("#%x%x%x%x%x%x","")
if not getElementData(plr,"admin") then return end
if getElementData(plr,"admin") then
local ranga = test
if not ... then
local x = getElementData(plr,"ekipaoff")
if x == false then
exports["noti"]:noti("Wy??czy?e? czat ekipy",plr)
setElementData(plr,"ekipaoff",true)
end
if x == true then
exports["noti"]:noti("W??czy?e? czat ekipy",plr)
setElementData(plr,"ekipaoff",false)
end
return end
if ... then
if getElementData(plr,"ekipaoff") == true then exports["noti"]:noti("Posiadasz wy??czone wiadomo?ci tego czatu, nie mo?esz na nim pisa?!", plr) return end
local msg=table.concat({...}, " ")
if (getAdmin(plr,4)) then
ranga = "CEO"
end
if (getAdmin(plr,3)) then
ranga = "Starszy Administrator"
end
if (getAdmin(plr,2)) then
ranga = "Administrator"
end
if (getAdmin(plr,1)) then
ranga = "Support"
en...
Ostatnio sobie grzebalem w LUA i chcialem zrobic cos ala swiatla policyjne do aut. Uda?o mi sie wystrugac cos takiego:
[lua]function add(thePlayer, seat, jacked )
local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Policja" ) ) then
if ( getElementModel ( source ) == 411 ) then
addVehicleSirens(source, 8, 2, false, false, true, true)
setVehicleSirens(source, 1, 0.8, 2.2, 0, 255, 255, 255, 198.9, 198.9)
setVehicleSirens(source, 2, -0.7, 2.2, 0, 255, 255, 255, 200, 200)
setVehicleSirens(source, 3, 0.5, 0.4, 0.5, 0, 0, 255, 200, 200)
setVehicleSirens(source, 4, 0.8, -2.3, 0.2, 255, 0, 0, 200, 200)
setVehicleSirens(source, 5, -0.9, -2.3, 0.2, 255, 0, 0, 200, 200)
setVehicleSirens(source, 6, 0.1, 2.7, -0.5, 0, 0, 255, 198.9, 198.9)
setVehicleSirens(source, 7, -0.1, 2.7, -0.5, 255, 0, 0, 200, 200)
setVehicleSirens(source, 8, 0.3, 0.4, 0.5, 255, 0, 0, 198.9, 198.9)
end
end
end
addEventHandler ( "onVehicleEnter", getRootElement(), add)[/lua]
I chcia?bym tutaj to zrobic do kilku aut, jednak nie chce robic z miliona if?w i setVehicleSirens bo chcialem to oprzec na tablicach. I tutaj jest moj problem, jako i? moj poziom znajomosci LUA jest na naprawde niskim poziomie to chcialbym sie zapytac czy ktos by mi to pomogl zrobic. Domy?lam sie ?e pewnie trzeba byloby zrobic petle z setvehiclesirens z zminnymi cos typu x,y,z i kolor...
[code]C:UsersNikodem xDesktopsamp037_svr_R2-1-1_win32gamemodesHynix.pwn(1901) : error 002: only a single statement (or expression) can follow each "case"
C:UsersNikodem xDesktopsamp037_svr_R2-1-1_win32gamemodesHynix.pwn(1901) : error 001: expected token: ")", but found ";"
C:UsersNikodem xDesktopsamp037_svr_R2-1-1_win32gamemodesHynix.pwn(1901) : warning 215: expression has no effect
C:UsersNikodem xDesktopsamp037_svr_R2-1-1_win32gamemodesHynix.pwn(1901) : error 001: expected token: ";", but found ")"
C:UsersNikodem xDesktopsamp037_svr_R2-1-1_win32gamemodesHynix.pwn(1901) : fatal error 107: too many error messages on o...
Witam chcia?bym, ?eby animacje zosta?y powtarzane dan? ilo?? razy przez p?tle. Jednak w praktyce nie dzia?a, co mam zrobi? (Pr?buje napisa? skrypt na podnoszenie sztangli)
Oto kod:
public OnPlayerCommandText(playerid, cmdtext[])
{
for (new mojapetla = 0; mojapetla < 10; mojapetla++)
{
if (strcmp("/cwicz", cmdtext, true, 10) == 0)
{
GameTextForPlayer(playerid, "~r~~h~Rozpoczoles cwiczenia", 3000, 3);
ApplyAnimation(playerid,"benchpress","gym_bp_geton",4.1,0,0,0,1,0);
ApplyAnimation(playerid,"benchpress","gym_bp_up_A",4.1,0,0,0,1,0);
ApplyAnimation(playerid,"benchpress","gym_bp_down",4.1,0,0,0,1,0);
return 1;
}
}
return 0;
}
Mojego ostatniego posta nikt si? nie podj??,
dotyczy? on wyp?at, poniewa? zrobi?em wyp?aty co godzin? poprzez onClientRender, poniewa? chodzi?o mi o wyp?aty zgodne z naszym zegarkiem, gdy 12 wyp?ata, gdy 18 wyp?ata, jednak jedna taka wyp?ata wykonuje si? oko?o 20 razy, poniewa? jest to event onClientRender, chc? to naprawi?, jakiego zdarzenia u?y?? Czy mo?e p?tli?
To kod:
[lua]addEventHandler("onClientRender", root,
function()
local time = getRealTime()
local hours = time.hour
local minutes = time.minute
local seconds = time.second
if (hours==0) and (minutes==0) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==1) and (minutes==0) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==2 and (minutes==0)) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==3) and (minutes==0) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==4) and (minutes==0) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==5) and (minutes==0) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==6) and (minutes==0) and (seconds==0) then
triggerServerEvent("update",localPlayer)
elseif (hours==7) and (minutes==0) and (seconds==0) then
triggerServerEvent("...
Witam.
Od tego? czasu jak zabrak?o mi pr?du podczas pisania mapy usun??a si? lecz da?em rady j? przywr?ci?.
Lecz teraz kod wykonuje si? do jednego momentu tak jakby do jednej linii i ... lipa.
Oto kod:
for(new a=0; a <= MAX_OBJECTS; a++)
{
DestroyObject(objects[a]);//roz?adowywani/niszczenie obiekt?w
pred[a] = 0;//ustawianie ?e gracz nie jest z czerwonego teamu
pblue[a] = 0;//ustawianie ?e gracz nie jest z niebieskiego teamu
} //i tu jakby si? ko?czy wykonywanie dalszego kodu
Gdy usun? t? p?tl? i b?dzie kod na spawn to mnie zespawnuje a gdy to jest to si? zacina i lipa...
Linijka gdzie si? zacina/nie wykonuje kod.
Linijka nr. 1376
Pr?bowa?em skompilowa? w innym edytorze czli PawnX i nic...
C:Documents and SettingsDOMPulpitPas.pwn(24) : error 028: invalid subscript (not an array or too many subscripts): "Sprite0"
C:Documents and SettingsDOMPulpitPas.pwn(24) : error 017: undefined symbol "i"
C:Documents and SettingsDOMPulpitPas.pwn(24) : error 029: invalid expression, assumed zero
C:Documents and SettingsDOMPulpitPas.pwn(24) : fatal error 107: too many error messages on one line
Witam, mam problem. Utworzy?em p?tle kt?ra wy?wietla przedmioty kt?re s? na ziemi jednak wy?wietla tylko ona jeden przedmiot mimo ?e obok s? inne, wy?wietla ostatnie id kt?re znajdzie. Pomo?ecie jako? ?eby wy?wietla?o wszystkie?
for(new nr = 0; nr < sizeof(ItemInfo); nr++)
{
if(DoInRange(5.0,playerid,ItemInfo[nr][iOSX],ItemInfo[nr][iOSY],ItemInfo[nr][iOSZ])&&ItemInfo[nr][iStan])
{
new string2[1024], car, string1[64];
string1 = "