Jimmy97 Posted June 28, 2012 Share Posted June 28, 2012 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) Link to comment
Castillo Posted June 28, 2012 Share Posted June 28, 2012 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 Link to comment
Jimmy97 Posted June 28, 2012 Author Share Posted June 28, 2012 can u give me example never tried that before Link to comment
Castillo Posted June 28, 2012 Share Posted June 28, 2012 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 Link to comment
Jimmy97 Posted June 28, 2012 Author Share Posted June 28, 2012 thank you,man you are great Link to comment
Jimmy97 Posted June 28, 2012 Author Share Posted June 28, 2012 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 Link to comment
Castillo Posted June 28, 2012 Share Posted June 28, 2012 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. 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