Jump to content

help with groups


Recommended Posts

Hey how to add to only one group can open the door for dayz gamemode code

local gate = createObject ( 10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90 ) 
local state = 0 
  
function move() 
    if state == 0 then  
        moveObject ( gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
        state = state + 1 
    elseif state == 1 then  
        moveObject ( gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
        state = state - 1 
    end 
end 
 addCommandHandler("gate", move ) 

Link to comment

Hey how to add to only one group can open the door for dayz gamemode code

local gate = createObject ( 10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90 ) 
local state = 0 
  
function move() 
    if state == 0 then  
        moveObject ( gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
        state = state + 1 
    elseif state == 1 then  
        moveObject ( gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
        state = state - 1 
    end 
end 
 addCommandHandler("gate", move ) 

Link to comment

Try this:

local gate = createObject ( 10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90 ) 
local state = 0 
local team = "teamname" 
  
addCommandHandler ( "gate", 
    function ( ) 
        if getPlayerTeam ( source ) == team then 
            if state == 0 then 
                moveObject ( gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
                state = 1 
            elseif state == 1 then 
                moveObject ( gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
                state = 0 
            end 
        end 
    end 
) 

Link to comment
Try this:
local gate = createObject ( 10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90 ) 
local state = 0 
local team = "teamname" 
  
addCommandHandler ( "gate", 
    function ( ) 
        if getPlayerTeam ( source ) == team then 
            if state == 0 then 
                moveObject ( gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
                state = 1 
            elseif state == 1 then 
                moveObject ( gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
                state = 0 
            end 
        end 
    end 
) 

not working

Link to comment

Fox, if you're using MTA DayZ 0.95a. Add this to "DayZ/group/group.slua"

  
function isPlayerInGroup(player, group) 
    if GAC[GetAccount(player)][1] == group then 
        return true 
    else 
        return false 
    end 
end 
  

Now your script.

  
    local gate = createObject ( 10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90 ) 
    local state = 0 
    local group = "TheGroupYouWant" 
      
    addCommandHandler ( "gate", 
        function ( ) 
            if isPlayerInGroup ( source, group ) then 
                if state == 0 then 
                    moveObject ( gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
                    state = 1 
                elseif state == 1 then 
                    moveObject ( gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
                    state = 0 
                end 
            end 
        end 
    ) 
  

Link to comment
not working

Anyway you don't know how to make anything. So guys please close this thread, it cannot be solved.

Hey now, that's not very nice. He's as entitled to getting help here as anyone else is.

Blue Pie's would work but he made a mistake, getPlayerTeam returns a team element, not a team name. The fix is simple, use getTeamName to check if the name of the team matches.

local gate = createObject(10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90) 
local state = 0 
local theTeam = "TeamName" 
  
function move() 
    if(getTeamName(getPlayerTeam(localPlayer)) == theTeam) then 
        if(state == 0) then 
            moveObject(gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
            state = 1 
        elseif(state == 1) then 
            moveObject(gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
            state = 0 
        end 
    else 
        outputChatBox("#BB0000You're not allowed to open this gate!", 0, 0, 0, true) 
    end 
end 
addCommandHandler("gate", move) 

You'll also want to use Debugging to see what kind of warnings and/or errors you are receiving. It will help you fix them yourself and help us help you faster.

Link to comment
not working

Anyway you don't know how to make anything. So guys please close this thread, it cannot be solved.

Hey now, that's not very nice. He's as entitled to getting help here as anyone else is.

Blue Pie's would work but he made a mistake, getPlayerTeam returns a team element, not a team name. The fix is simple, use getTeamName to check if the name of the team matches.

local gate = createObject(10828, 276.60000610352, 2503.3000488281, 28.10000038147, 0, 0, 90) 
local state = 0 
local theTeam = "TeamName" 
  
function move() 
    if(getTeamName(getPlayerTeam(localPlayer)) == theTeam) then 
        if(state == 0) then 
            moveObject(gate, 4000, 276.5, 2537.1999511719, 28.10000038147) 
            state = 1 
        elseif(state == 1) then 
            moveObject(gate, 4000, 276.60000610352, 2503.3000488281, 28.10000038147) 
            state = 0 
        end 
    else 
        outputChatBox("#BB0000You're not allowed to open this gate!", 0, 0, 0, true) 
    end 
end 
addCommandHandler("gate", move) 

You'll also want to use Debugging to see what kind of warnings and/or errors you are receiving. It will help you fix them yourself and help us help you faster.

Ty man i fix it you the best :DD

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