Jump to content

Moving Gate "Command Handler"


DonPro

Recommended Posts

hi i tryed to make this moving gate to an Command handler, it was an Event Handler. but i wanna keep the ACL group so no one elsn can use the command. i tryed to look on Wiki but i didnt understand how to make it to an Command handler. pleas help me.

local gate = createObject(2893, -2055.69, 169.19, 27.89, 343, 0, 90) 
local marker = createMarker(-2056.60, 171, 27.89, "cylinder", 1, 255, 255, 255, 0) 
  
  
function isAclGroup(p,group) 
if p and getElementType(p) == "player" and type(group) == "string" then 
     local Deadusergroup = getAccountName(getPlayerAccount(p)) 
         if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then 
              return true 
      else   
             return false 
            end   
      else 
             return false   
      end 
 end 
  
function addCommandHandler("lift") then 
    end 
  
function moveGate(psource) 
     if isAclGroup(psource,"SamCarTow") then 
          moveObject(gate, 4000, -2055.69, 169.19, 29.89) 
      end 
end 
addCommandHandler("onMarkerHit", marker, moveGate) 
  
function moveBack(pp) 
     moveObject(gate, 4000, -2055.69, 169.19, 27.89) 
end 
addCommandHandler("onMarkerLeave", marker, moveBack) 

Link to comment

Use /open or /close.

Good Luck! 8)

local gate = createObject(2893, -2055.69, 169.19, 27.89, 343, 0, 90) 
local marker = createMarker(-2056.60, 171, 27.89, "cylinder", 1, 255, 255, 255, 0) 
  
  
function isAclGroup(p,group) 
    if p and getElementType(p) == "player" and type(group) == "string" then 
        local Deadusergroup = getAccountName(getPlayerAccount(p)) 
        if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then 
            return true 
        else   
            return false 
        end   
    else 
        return false   
    end 
end 
  
function moveGate(playerSource, cmd) 
    if cmd == "open" then 
        if isAclGroup(playerSource,"SamCarTow") then 
            moveObject(gate, 4000, -2055.69, 169.19, 29.89) 
        end 
    elseif cmd == "close" then 
        moveObject(gate, 4000, -2055.69, 169.19, 27.89) 
    end 
end 
addCommandHandler("open", moveGate) 
addCommandHandler("close", moveGate) 

Edited by Guest
Link to comment
local gate = createObject(2893, -2055.69, 169.19, 27.89, 343, 0, 90) 
local gateState = false -- Define a variable with the state of the gate 
  
function isAclGroup ( p, group ) 
    if ( p and getElementType ( p ) == "player" and type ( group ) == "string" ) then 
        return isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( group ) ) 
    else 
        return false 
    end 
end 
  
function moveGate ( psource ) 
    if isAclGroup ( psource, "SamCarTow" ) then 
        gateState = ( not gateState ) -- Set the state of the gate to the opposite of the current 
        if ( gateState ) then -- If the state is 'true' 
            moveObject ( gate, 4000, -2055.69, 169.19, 29.89 ) -- Open the gate 
        else -- If the state is 'false' 
            moveObject ( gate, 4000, -2055.69, 169.19, 27.89 ) -- Close the gate 
        end 
    end 
end 
addCommandHandler ( "lift", movegate ) 

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