Sparrow Posted January 12, 2012 Share Posted January 12, 2012 I do a simple script that is allow army to block road with barriers, but when I'm testing this in my local server I found that all can use it, also I stuck inside the barrier, how to solve this? here is the script: local barrier = {} function createBarrier (thePlayer) local getTeam = getTeamFromName ("Army") if (getTeam) then local x, y, z = getElementPosition (thePlayer) barrier[thePlayer] = createObject (3578, x, y, z, 0, 0, 0) end end addCommandHandler ("barrier", createBarrier) function removeBarrier (thePlayer) if (isElement(barrier[thePlayer])) then destroyElement(barrier[thePlayer]) barrier[thePlayer] = nil end end addCommandHandler ("rbarrier", removeBarrier) Link to comment
Kenix Posted January 12, 2012 Share Posted January 12, 2012 You mean it? Server local barrier = {} function isUser( source,name ) if isElement( source ) and type( name ) == "string" then local acc = getPlayerAccount( source ) if acc then if isObjectInACLGroup( "user."..getAccountName( acc ),aclGetGroup( name ) ) then return true end return false end return false end return false end function createBarrier ( thePlayer ) if isUser( thePlayer,"Admin" ) then -- check if player Admin for example local getTeam = getTeamFromName ("Army") if (getTeam) then local x, y, z = getElementPosition (thePlayer) barrier[thePlayer] = createObject (3578, x, y, z, 0, 0, 0) end end end addCommandHandler ("barrier", createBarrier) function removeBarrier ( thePlayer ) if isUser( thePlayer,"Admin" ) then -- check if player Admin for example if isElement( barrier[thePlayer ] ) then destroyElement( barrier[thePlayer ] ) barrier[ thePlayer ] = nil end end end addCommandHandler ("rbarrier", removeBarrier) Link to comment
Sparrow Posted January 12, 2012 Author Share Posted January 12, 2012 with yours only admins can do it? Edit: it's working only for "Army" team, and I solve the problem of bugged inside it by changing: barrier[thePlayer] = createObject (3578, x + 6, y , z, 0, 0, 0) but if I create 2+ barriers I only remove 1 barrier, how to set it only create 1 barrier? Link to comment
Castillo Posted January 12, 2012 Share Posted January 12, 2012 local barrier = {} function isUser( source,name ) if isElement( source ) and type( name ) == "string" then local acc = getPlayerAccount( source ) if acc then if isObjectInACLGroup( "user."..getAccountName( acc ),aclGetGroup( name ) ) then return true end return false end return false end return false end function createBarrier ( thePlayer ) if isUser( thePlayer,"Admin" ) then -- check if player Admin for example local getTeam = getTeamFromName ("Army") if (getTeam) then local x, y, z = getElementPosition (thePlayer) if (isElement(barrier[thePlayer])) then return end barrier[thePlayer] = createObject (3578, x, y, z, 0, 0, 0) end end end addCommandHandler ("barrier", createBarrier) function removeBarrier ( thePlayer ) if isUser( thePlayer,"Admin" ) then -- check if player Admin for example if isElement( barrier[thePlayer ] ) then destroyElement( barrier[thePlayer ] ) barrier[ thePlayer ] = nil end end end addCommandHandler ("rbarrier", removeBarrier) Link to comment
Sparrow Posted January 12, 2012 Author Share Posted January 12, 2012 thx, its working well 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