|H|TiTanium Posted June 16, 2013 Share Posted June 16, 2013 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
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 Sorry for posting again and makeing double post , but please help me, I'd like to have this scripted for today. Link to comment
manawydan Posted June 16, 2013 Share Posted June 16, 2013 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
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 What about if a player is in a vehicle ? Link to comment
iPrestege Posted June 16, 2013 Share Posted June 16, 2013 if isPedInVehicle ( hitElement ) then return outputChatBox('You can not enter the area with vehicle',hitElement,255,0,0) end Link to comment
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 I think you've forgotten to add setelementposition to make he gets moved while in a car Link to comment
iPrestege Posted June 16, 2013 Share Posted June 16, 2013 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
manawydan Posted June 16, 2013 Share Posted June 16, 2013 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
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 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 Link to comment
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 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
manawydan Posted June 16, 2013 Share Posted June 16, 2013 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
Castillo Posted June 16, 2013 Share Posted June 16, 2013 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
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 NOw, I'm getting this error : [2013-06-16 13:35:44] ERROR: testing_zone\territorio.lua:7: attempt to concatenate a boolean value I'm using solidsnake fixes Link to comment
iPrestege Posted June 16, 2013 Share Posted June 16, 2013 Works fine here server side . Link to comment
Castillo Posted June 16, 2013 Share Posted June 16, 2013 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. Link to comment
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 Line 7 : if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)),aclGetGroup("Admin")) then Link to comment
Castillo Posted June 16, 2013 Share Posted June 16, 2013 That line doesn't exist on my code. Link to comment
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 My mistake. Everything is ready and fixed, Thank you for helping me Link to comment
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 Sorry, while testing it, I got another problem, even admins can't enter area if they are in vehicles Link to comment
Castillo Posted June 16, 2013 Share Posted June 16, 2013 Isn't that what you wanted? nobody can enter with vehicles. Link to comment
|H|TiTanium Posted June 16, 2013 Author Share Posted June 16, 2013 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 Link to comment
Castillo Posted June 16, 2013 Share Posted June 16, 2013 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
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