Jump to content

Road Block team lock


Jimmy97

Recommended Posts

Posted

Hey guys i downloaded RoadBlock script from mta community and edited a little bit,but now i want to lock command so just some teams can use it like : "LSPD","SFPD"(just two of those teams) here is script:

rbs = { } 
  
function del(source,command) 
  
            for index, roadb in ipairs( rbs ) do 
                destroyElement( roadb ) 
            end 
            outputChatBox("*ROADBLOCK* Deleted all roadblocks.",source,255,255,0) 
  
end 
  
addCommandHandler("rbdel",del) 
  
function small(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(978,x,y,z-0.15,0,0,rotZ) ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("rbsmall",small) 
  
function large(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(981,x,y,z,0,0,rotZ+180) ) 
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("rblarge",large) 
  
function yellow(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3578,x,y,z-0.2,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("rbyellow",yellow) 
   
function detour(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3091,x,y,z-0.38,0,0,rotZ+180) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
addCommandHandler("rbdetour",detour) 
  
function cone(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(1238,x,y,z-0.65,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("cone",cone) 
  
function fence(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(1459,x,y,z-0.4,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("fence",fence) 
   
function line(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(2957,x,y,z-2.6,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("line",line) 
  
function dock(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3578,x,y,z-0.15,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("dbarrier",dock) 
  
function hbarrier(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(981,x,y,z-0.15,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
             
end 
  
addCommandHandler("hbarrier",hbarrier) 

Posted

You can make a table with the teams you wish to be able to use the command and then check if the player team is on that table.

getPlayerTeam 
getTeamName 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
teams = 
    { 
        [ "LSPD" ] = true, 
        [ "SFPD" ] = true 
    } 

That's our allowed team table.

Now you must check if the team name of the player that used the command is on that table, something like this:

if ( teams [ teamName ] ) then 
 -- Your code 
end 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

can u explain me why it says that : "expected to close "{" at line 4 near "["?

teams = 
    
    { 
        [ "Las Venturas Police" ] = true, 
        [ "El Quebrados Sheriff" ] = true 
        [ "S.W.A.T" ] = true, 
        [ "S.A.S" ] = true 
        [ "C.I.A" ] = true, 
        [ "Federal Bureau of Investigation" ] = true 
        [ "Fort Carson Sheriff" ] = true 
        [ "National Guard" ] = true 
        [ "Fort Carson Sheriff" ] = true 
     
    } 
if ( teams [ teamName ] ) then 
  
rbs = { } 
  
function del(source,command) 
  
            for index, roadb in ipairs( rbs ) do 
                destroyElement( roadb ) 
            end 
            outputChatBox("*ROADBLOCK* Deleted all roadblocks.",source,255,255,0) 
  
end 
  
addCommandHandler("rbdel",del) 
  
function small(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(978,x,y,z-0.15,0,0,rotZ) ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("rbsmall",small) 
  
function large(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(981,x,y,z,0,0,rotZ+180) ) 
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("rblarge",large) 
  
function yellow(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3578,x,y,z-0.2,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("rbyellow",yellow) 
  
function detour(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3091,x,y,z-0.38,0,0,rotZ+180) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
addCommandHandler("rbdetour",detour) 
  
function cone(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(1238,x,y,z-0.65,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("cone",cone) 
  
function fence(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(1459,x,y,z-0.4,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("fence",fence) 
  
function line(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(2957,x,y,z-2.6,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("line",line) 
  
function dock(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3578,x,y,z-0.15,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
addCommandHandler("dbarrier",dock) 
  
function hbarrier(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(981,x,y,z-0.15,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
             
end 
  
addCommandHandler("hbarrier",hbarrier) 
  
end 

Posted
teams = 
    
    { 
        [ "Las Venturas Police" ] = true, 
        [ "El Quebrados Sheriff" ] = true 
        [ "S.W.A.T" ] = true, 
        [ "S.A.S" ] = true 
        [ "C.I.A" ] = true, 
        [ "Federal Bureau of Investigation" ] = true 
        [ "Fort Carson Sheriff" ] = true 
        [ "National Guard" ] = true 
        [ "Fort Carson Sheriff" ] = true 
    } 

You got missing commas after each team, only last one doesn't has to have a comma.

Btw, your code is wrong, the if ( teams [ teamName ] ) was supposed to be inside your command function.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...