Axel Posted March 13, 2012 Share Posted March 13, 2012 I made a little rb command that creates a roadblock and a /rbd command that deletes it.. the problem is that if i create 2 roadblocks it delets only one.. and i'm not good at tables.. here's the code if someone wants to help function rbs(source,command,state) if getPlayerTeam(source) == getTeamFromName("Muncitorii Strazilor") or getPlayerTeam(source) == getTeamFromName("Las Venturas Police Department") then local x,y,z = getElementPosition(source) local rotX,rotY,rotZ = getElementRotation(source) if state == "1" then rb = createObject(978,x,y,z-0.15,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "2" then rb = createObject(981,x,y,z,0,0,rotZ+180) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "3" then rb = createObject(3578,x,y,z-0.2,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "4" then rb = createObject(3091,x,y,z-0.38,0,0,rotZ+180) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "5" then rb = createObject(1238,x,y,z-0.65,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "6" then rb = createObject(1459,x,y,z-0.4,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) else outputChatBox("SYNTAXA: /rb [1-6]",source,255,255,0) end end end addCommandHandler("rb",rbs) function del(source,command) destroyElement(rb) end addCommandHandler("rbd",del) Link to comment
bandi94 Posted March 13, 2012 Share Posted March 13, 2012 Try this (incearca asta iti stergea doar unu pentru ca nu leai pus in tabel ) @Forum modelator when this "in pairs" bug will be fixed ? rb={} function rbs(source,command,state) if getPlayerTeam(source) == getTeamFromName("Muncitorii Strazilor") or getPlayerTeam(source) == getTeamFromName("Las Venturas Police Department") then local x,y,z = getElementPosition(source) local rotX,rotY,rotZ = getElementRotation(source) if state == "1" then rb[#rb+1] = createObject(978,x,y,z-0.15,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "2" then rb[#rb+1] = createObject(981,x,y,z,0,0,rotZ+180) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "3" then rb[#rb+1] = createObject(3578,x,y,z-0.2,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "4" then rb[#rb+1] = createObject(3091,x,y,z-0.38,0,0,rotZ+180) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "5" then rb[#rb+1] = createObject(1238,x,y,z-0.65,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "6" then rb[#rb+1] = createObject(1459,x,y,z-0.4,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) else outputChatBox("SYNTAXA: /rb [1-6]",source,255,255,0) end end end addCommandHandler("rb",rbs) function del(source,command) for i,v in pairs">pairs(rb) do destroyElement(v) end end addCommandHandler("rbd",del) Link to comment
Axel Posted March 14, 2012 Author Share Posted March 14, 2012 SCRIPT ERROR: roadblock/script.lua:39 unfinished string near '">pairs(rb) do' hmm Link to comment
GanJaRuleZ Posted March 14, 2012 Share Posted March 14, 2012 Script correct.. rb={} function rbs(source,command,state) if getPlayerTeam(source) == getTeamFromName("Muncitorii Strazilor") or getPlayerTeam(source) == getTeamFromName("Las Venturas Police Department") then local x,y,z = getElementPosition(source) local rotX,rotY,rotZ = getElementRotation(source) if state == "1" then rb[#rb+1] = createObject(978,x,y,z-0.15,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "2" then rb[#rb+1] = createObject(981,x,y,z,0,0,rotZ+180) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "3" then rb[#rb+1] = createObject(3578,x,y,z-0.2,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "4" then rb[#rb+1] = createObject(3091,x,y,z-0.38,0,0,rotZ+180) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "5" then rb[#rb+1] = createObject(1238,x,y,z-0.65,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) elseif state == "6" then rb[#rb+1] = createObject(1459,x,y,z-0.4,0,0,rotZ) setElementPosition ( source, x, y, z+1 ) outputChatBox("*Blocaj adaugat.",source,255,255,0) else outputChatBox("SYNTAXA: /rb [1-6]",source,255,255,0) end end end addCommandHandler("rb",rbs) function del(source,command) for i,v in ipairs(rb) do -- Aicia ai facut 'pairs' in loc de 'ipairs' destroyElement(v) end end addCommandHandler("rbd",del) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now