Jump to content

Problem with Restricted Area Script


Recommended Posts

Posted

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 ) 

Posted

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 ) 
  

560x95_FFFFFF_09FF00_050505_000000.png

"Querer não é poder, mas tentar é avançar"!

Posted

if isPedInVehicle (  
    hitElement 
    ) then 
        return  
            outputChatBox('You can not enter the area with vehicle',hitElement,255,0,0) 
    end 

  

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

  

Posted
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 ) 

560x95_FFFFFF_09FF00_050505_000000.png

"Querer não é poder, mas tentar é avançar"!

Posted

It works exactly the way I wanted it. But I got a problem, the message "Welcome to admin area" is spamming Chat, is there anyway to stop it? if there isn't I 'll remove the line

Posted

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  

Posted
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 ) 

560x95_FFFFFF_09FF00_050505_000000.png

"Querer não é poder, mas tentar é avançar"!

Posted
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 ) 

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 you give the actual line number? because line 7 on my code is this line:

if isPedInVehicle ( hitElement ) then 

which can't cause that error.

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

That line doesn't exist on my code.

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

Isn't that what you wanted? nobody can enter with vehicles.

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

No, I didn't want it. It was supposed to allow admins entering even with vehicles. So, non-admins couldn't enter, even on foot or vehicles. Admins should stay inside base, even with vehicles or foot, and non-admins should be moved outside

Posted
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 ) 

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