Jump to content

Gate help


|TSF|FoX

Recommended Posts

Hello everybody i made a gate script but now i want to make it a clan base on dayz gamemode but everybody can open it i use the regular group system witch comes with dayz 

the code 

  
local gate = createObject ( 8378,1064.3000488281,1771,19.700000762939,0,0,0 ) 
local state = 0      
  
function move() 
    if state == 0 then  
        moveObject ( gate,4000,1064.3000488281,1771.0999755859,40.099998474121) 
        state = state + 1 
    elseif state == 1 then   
        moveObject ( gate, 4000,1064.3000488281,1771,19.700000762939) 
        state = state - 1 
    end 
end 
 addCommandHandler("gate", move ) 

 

Link to comment
local gate = createObject ( 8378,1064.3000488281,1771,19.700000762939,0,0,0 ) 
local state = 0      
  
function move(thePlayer) 
    if getElementData(thePlayer, "group") == "Your group name here" then
       if state == 0 then  
           moveObject ( gate,4000,1064.3000488281,1771.0999755859,40.099998474121) 
           state = state + 1 
       elseif state == 1 then   
           moveObject ( gate, 4000,1064.3000488281,1771,19.700000762939) 
           state = state - 1 
       end
    end
end 
 addCommandHandler("gate", move ) 

 

Link to comment

u welcome


 

local opencommand = "gate"  --open command
local closecommand = "gate1" --close command
local ACL = "Server Owner" --acl

local GateObject = 3036  --object
local OpenTime = 6000 --opening second
local rotX, rotY, rotZ = 0, 0, 90 --rotations 
local Defx, Defy, defz = 2055, -1697, 14.199999809265 --closed position 
local opx, opy, opz = 2055, -1697, 10  --opened position

--create the gate (DO NOT EDIT) 
local ggate = createObject ( GateObject, Defx, Defy, defz, rotX, rotY, rotZ)

--DO NOT EDIT
function gateopen ( p )
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(p)), aclGetGroup(ACL)) then
        moveObject (ggate, OpenTime, opx, opy, opz)
        outputChatBox("gate open", p,0,255,0,true)
    else
        outputChatBox("u dont have permission", p,0,255,0,true)
    end
end
addCommandHandler( opencommand, gateopen)
 
function gateclose ( p )
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(p)), aclGetGroup(ACL)) then
        moveObject (ggate, OpenTime, Defx, Defy, defz)
        outputChatBox("gate closing", p,0,255,0,true)
    else
        outputChatBox("u dont have permission", p,0,255,0,true)
    end
end
addCommandHandler( closecommand, gateclose)

 

Edited by MilOG
ww
Link to comment
1 hour ago, Dimos7 said:

local gate = createObject ( 8378,1064.3000488281,1771,19.700000762939,0,0,0 ) 
local state = 0      
  
function move(thePlayer) 
    if getElementData(thePlayer, "group") == "Your group name here" then
       if state == 0 then  
           moveObject ( gate,4000,1064.3000488281,1771.0999755859,40.099998474121) 
           state = state + 1 
       elseif state == 1 then   
           moveObject ( gate, 4000,1064.3000488281,1771,19.700000762939) 
           state = state - 1 
       end
    end
end 
 addCommandHandler("gate", move ) 

 

How can we even make the script work for you, tell us if your group system have export functions. If yes, then put it here.

Link to comment

Well, I suppose you can then call this instead of that getElementData in the reply above.

if ( not isGuestAccount( getPlayerAccount( thePlayer ) ) and ( isGangMember( 'yourGangName', getAccountName( getPlayerAccount( thePlayer ) ) ) ) then
    -- Your gate script
end

You will need to execute the gate script inside the DayZ resource, as otherwise it'll not be able to find the isGangMember function that is included in the resource.

Edited by myonlake
Link to comment
14 hours ago, myonlake said:

Well, I suppose you can then call this instead of that getElementData in the reply above.


if ( not isGuestAccount( getPlayerAccount( thePlayer ) ) and ( isGangMember( 'yourGangName', getAccountName( getPlayerAccount( thePlayer ) ) ) ) then
    -- Your gate script
end

You will need to execute the gate script inside the DayZ resource, as otherwise it'll not be able to find the isGangMember function that is included in the resource.

An easier method will be to do it like this:

local gang = getElementData(player, "gang") or false;
local thegang = "THEGANGNAME";

if (gang and gang == thegang) then
	-- Move the gate!
end

Also no need to run in DayZ, it can be a stand alone resource.

Sorry haven't seen the posts above :)xD 

Edited by Tekken
Link to comment
7 hours ago, Tekken said:

An easier method will be to do it like this:


local gang = getElementData(player, "gang") or false;
local thegang = "THEGANGNAME";

if (gang and gang == thegang) then
	-- Move the gate!
end

Also no need to run in DayZ, it can be a stand alone resource.

Sorry haven't seen the posts above :)xD 

Sure, you can do that, but that kinda takes away the whole point of having functions in scripting languages in general. What if that element data key changes? You'll need to replace that everywhere. That's why we use functions. And instead of doing all that weird code, you can simply just write this and it'll do the same thing.

if ( getElementData( thePlayer, 'gang' ) == 'yourGangName' ) then
    -- Your gate script
end
Edited by myonlake
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...