Jump to content

How to Make Gate Opened Only when Group Member are near that


Recommended Posts

  
-- this does only check if you're in the correct group. 
local allowedGroups = {["Groupname"]=true} -- Groups who are allowed  
  
function opengroupGate(player) 
local group = getElementData(hitElement, "group") 
if (allowedGroups[group] then 
-- your script here.. :> 
  

That's the code you'll be needing to check if he's in the correct group.

  
-- this is all you need to make a gate. 
createObject 
moveObject 
createColSphere 
  

an example:

  
local allowedGroups = {["Groupname"]=true} 
col1 = createColSphere ( x, y, z, radius )  
gate1 = createObject (modelid, x,y,z) 
  
--open teh gate. 
function openGate1(player) 
local group = getElementData(hitElement, "group") 
if (allowedGroups[group] then  
moveObject (gate1,  milliseconds,x,y,z ) 
end 
  end 
   addEventHandler("onColShapeHit", col1, openGate1) 
  
-- Close gate 
  
function closeGate1(player) 
moveObject(gate1, milliseconds,x,y,z) 
end 
  addEventHandler("onColShapeLeave", col1, closeGate1) 
  

Link to comment
  
local allowedGroups = { ["Groupname"]=true } 
col1 = createColSphere ( x, y, z, radius )  
gate1 = createObject (modelid, x,y,z) 
  
function openGate1 ( player ) 
     if ( allowedGroups [ getElementData ( player, "Group" ) ] ) then  
             moveObject (gate1,  milliseconds,x,y,z ) 
     end 
end 
addEventHandler("onColShapeHit", col1, openGate1) 
  
function closeGate1() 
        moveObject(gate1, milliseconds,x,y,z) 
end 
addEventHandler("onColShapeLeave", col1, closeGate1) 
  

Link to comment

Like This?

local allowedGroups = { ["THE_KING"]=true }

col1 = createColSphere (2838.8000488281, -1653.3000488281, 10.800000190735, 10 )

gate1 = createObject (971, 2846.6999511719,-1657.1999511719,13.300000190735,0,359.5,76)

function openGate1 ( player )

if ( allowedGroups [ getElementData ( player, "Group" ) ] ) then

moveObject (gate1, 3000,2846.6999511719,-1657.1999511719,3.5999999046326 )

end

end

addEventHandler("onColShapeHit", col1, openGate1)

function closeGate1()

moveObject(gate1, 3000,2846.6999511719,-1657.1999511719,13.300000190735)

end

addEventHandler("onColShapeLeave", col1, closeGate1)

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