Jump to content

Roadblock


Axel

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...