Jump to content

Problem with Restricted Area Script


Recommended Posts

I'm trying to do a script where if a player enters the area, he is automatically moved outside it.

It works if a player is on foot, but it doesn't if he is using a vehicle(I don't want it happening).

And also the message "Access Denied" keeps appearing and spamming Chat without stopping.

I want your help to make message appears only once and to don't allow players with vehicle enter area.

col = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
zone = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 255, 0, 0, 170 ) 
setElementData (zone, "zombieProof", true) 
  
  
function enterAdmin(hitElement,matchingDimension) 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)),aclGetGroup("Admin")) then 
    toggleControl (hitElement, "fire", true ) 
    toggleControl (hitElement, "aim_weapon", true) 
    toggleControl (hitElement, "vehicle_fire", true) 
    outputChatBox("Welcome to Admin area", hitElement, 0, 170, 255) 
       else 
    outputChatBox("Access denied", hitElement, 255, 0, 0) 
         setElementPosition (hitElement, 0, 0, 120 ) 
end 
end 
addEventHandler( "onColShapeHit", col, enterAdmin ) 

Link to comment

try

local col = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
local zone = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 255, 0, 0, 170 ) 
setElementData (zone, "zombieProof", true) 
  
  
function enterAdmin(hitElement,matchingDimension) 
local accName = getAccountName ( getPlayerAccount ( hitElement ) )  
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    toggleControl (hitElement, "fire", true ) 
    toggleControl (hitElement, "aim_weapon", true) 
    toggleControl (hitElement, "vehicle_fire", true) 
    outputChatBox("Welcome to Admin area", hitElement, 0, 170, 255) 
       else 
    outputChatBox("Access denied", hitElement, 255, 0, 0) 
         setElementPosition (hitElement, 0, 0, 120 ) 
end 
end 
addEventHandler( "onColShapeHit", col, enterAdmin ) 
  

Link to comment
if isPedInVehicle (  
    hitElement 
    ) then 
            setElementPosition (  
            getPedOccupiedVehicle( hitElement ),x,y,z  
            ) 
            outputChatBox('You can not enter the area with vehicle',hitElement,255,0,0) 
        return 
    end 

Try this and if there's any error use debugscript and don't forget to change the x,y,z position .

Link to comment
local col = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
local zone = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 255, 0, 0, 170 ) 
setElementData (zone, "zombieProof", true) 
  
  
function enterAdmin(hitElement,matchingDimension) 
if isPedInVehicle ( 
    hitElement 
    ) then 
            setElementPosition ( 
            getPedOccupiedVehicle( hitElement ),0, 0, 120 
            ) 
            outputChatBox('You can not enter the area with vehicle',hitElement,255,0,0) 
        return 
    end 
local accName = getAccountName ( getPlayerAccount ( hitElement ) ) 
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    toggleControl (hitElement, "fire", true ) 
    toggleControl (hitElement, "aim_weapon", true) 
    toggleControl (hitElement, "vehicle_fire", true) 
    outputChatBox("Welcome to Admin area", hitElement, 0, 170, 255) 
       else 
    outputChatBox("Access denied", hitElement, 255, 0, 0) 
         setElementPosition (hitElement, 0, 0, 120 ) 
end 
end 
addEventHandler( "onColShapeHit", col, enterAdmin ) 

Link to comment

Now, I'm getting this error:

 [2013-06-16 13:35:44] WARNING: testing_zone\territorio.lua:7: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] 
[2013-06-16 13:35:44] ERROR: testing_zone\territorio.lua:7: attempt to concatenate a boolean value  

Link to comment
local col = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
local zone = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 255, 0, 0, 170 ) 
setElementData (zone, "zombieProof", true) 
  
  
function enterAdmin(hitElement,matchingDimension) 
if isPedInVehicle ( 
    hitElement 
    ) then 
            setElementPosition ( 
            getPedOccupiedVehicle( hitElement ),0, 0, 120 
            ) 
            outputChatBox('You can not enter the area with vehicle',hitElement,255,0,0) 
        return 
    end 
    if getElementType(hitElement) == "player" then 
local accName = getAccountName ( getPlayerAccount ( hitElement ) ) 
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    toggleControl (hitElement, "fire", true ) 
    toggleControl (hitElement, "aim_weapon", true) 
    toggleControl (hitElement, "vehicle_fire", true) 
    outputChatBox("Welcome to Admin area", hitElement, 0, 170, 255) 
       else 
    outputChatBox("Access denied", hitElement, 255, 0, 0) 
         setElementPosition (hitElement, 0, 0, 120 ) 
end 
end 
end 
addEventHandler( "onColShapeHit", col, enterAdmin ) 

Link to comment
local col = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
local zone = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 255, 0, 0, 170 ) 
setElementData ( zone, "zombieProof", true ) 
  
function enterAdmin ( hitElement, matchingDimension ) 
    if ( getElementType ( hitElement ) == "player" ) then 
        if isPedInVehicle ( hitElement ) then 
            setElementPosition ( getPedOccupiedVehicle ( hitElement ), 0, 0, 120 ) 
            outputChatBox ( 'You can not enter the area with vehicle',hitElement, 255, 0, 0 ) 
            return 
        end 
  
        local accName = getAccountName ( getPlayerAccount ( hitElement ) ) 
        if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then 
            toggleControl ( hitElement, "fire", true ) 
            toggleControl ( hitElement, "aim_weapon", true ) 
            toggleControl ( hitElement, "vehicle_fire", true ) 
            outputChatBox ( "Welcome to Admin area", hitElement, 0, 170, 255 ) 
        else 
            outputChatBox ( "Access denied", hitElement, 255, 0, 0 ) 
            setElementPosition ( hitElement, 0, 0, 120 ) 
        end 
    end 
end 
addEventHandler( "onColShapeHit", col, enterAdmin ) 

Link to comment
local col = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
local zone = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 255, 0, 0, 170 ) 
setElementData ( zone, "zombieProof", true ) 
  
function enterAdmin ( hitElement, matchingDimension ) 
    if ( getElementType ( hitElement ) == "player" ) then 
        local accName = getAccountName ( getPlayerAccount ( hitElement ) ) 
        if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then 
            toggleControl ( hitElement, "fire", true ) 
            toggleControl ( hitElement, "aim_weapon", true ) 
            toggleControl ( hitElement, "vehicle_fire", true ) 
            outputChatBox ( "Welcome to Admin area", hitElement, 0, 170, 255 ) 
        else 
            outputChatBox ( "Access denied", hitElement, 255, 0, 0 ) 
            local hitElement = ( isPedInVehicle ( hitElement ) and getPedOccupiedVehicle ( hitElement ) or hitElement ) 
            setElementPosition ( hitElement, 0, 0, 120 ) 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", col, enterAdmin ) 

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