Jump to content

use functions in one command


Dimmitry007

Recommended Posts

How to enable and disable godmode only in one CMd?

Here's my code

function aduty ( player ) 
local accName = getAccountName(getPlayerAccount(player)) 
if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then 
outputChatBox("Admin "..getPlayerName(player).." Is Now OnDuty!",getRootElement(),255,0,0) 
outputChatBox("",getRootElement(),255,0,0) 
outputServerLog("Admin "..getPlayerName(player).." Is Now OnDuty!") 
setElementData( player, "blood", 999999999999999 ) 
heal = "999999999999999" 
end 
end 
addCommandHandler("aduty",aduty) 
  
function offaduty ( player ) 
local accName = getAccountName(getPlayerAccount(player)) 
if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then 
outputChatBox("Admin "..getPlayerName(player).." Is No Longer OnDuty!",getRootElement(),255,0,0) 
outputChatBox("",getRootElement(),255,0,0) 
outputServerLog("Admin "..getPlayerName(player).." Is No Longer OnDuty!") 
setElementData( player, "blood", 12000 ) 
end 
end 
addCommandHandler("offduty",offaduty) 
  
function heal_func ( player ) 
local accName = getAccountName(getPlayerAccount(player)) 
if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then 
if heal == "an" then 
setElementData( player, "food", 250 ) 
setElementData( player, "thirst", 250 ) 
end 
end 
end 
setTimer(heal_func, 60000, 0) 

Link to comment

Look here :

function setPlayerOnDuty( player ) 
    local accName = getAccountName(getPlayerAccount(player)) 
    if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then 
        local duty = getElementData(player, "duty") or 0 
        if duty == 0 then 
            outputChatBox("Admin "..getPlayerName(player).." Is Now OnDuty!",getRootElement(),255,0,0) 
            outputChatBox("",getRootElement(),255,0,0) 
            outputServerLog("Admin "..getPlayerName(player).." Is Now OnDuty!") 
            setElementData( player, "blood", 999999999999999 ) 
            setElementData( player, "duty", 1 ) 
        else 
            outputChatBox("Admin "..getPlayerName(player).." Is No Longer OnDuty!",getRootElement(),255,0,0) 
            outputChatBox("",getRootElement(),255,0,0) 
            outputServerLog("Admin "..getPlayerName(player).." Is No Longer OnDuty!") 
            setElementData( player, "blood", 12000 ) 
            setElementData( player, "duty", 0 ) 
        end 
    end 
end     
addCommandHandler("aduty",setPlayerOnDuty) 

Link to comment

ok how to make this in one command?

i tried and tried it never worked

function startgm() 
    gmtimer = setTimer(gmforad, 2000, 0) 
    outputChatBox ("You're OnDuty",255, 0, 0,true) 
end 
addCommandHandler("aduty", startgm) 
  
function offgm() 
    killTimer (gmtimer) 
    setElementData(getLocalPlayer(),"blood", 12000) 
    outputChatBox ("You're OffDuty!",255, 0, 0,true) 
end 
addCommandHandler("offaduty", offgm) 
  
function gmforad() 
    if getElementData(getLocalPlayer(),"logedin") then 
        setElementData(getLocalPlayer(),"blood", 500000) 
        setElementData(getLocalPlayer(),"bleeding", 0) 
        setElementData(getLocalPlayer(),"cold", false) 
        setElementData(getLocalPlayer(),"temperature", 37) 
        setElementData(getLocalPlayer(),"pain", false) 
        setElementData(getLocalPlayer(),"brokenbone", false) 
        setElementData(getLocalPlayer(),"thirst", 100) 
        setElementData(getLocalPlayer(),"food", 100) 
        end 
end 

Link to comment
function startgm() 
    if not getElementData(getLocalPlayer(), "onduty") then 
      gmtimer = setTimer(gmforad, 2000, 0) 
      outputChatBox ("You're now on-duty",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", true) 
    else 
      killTimer (gmtimer) 
      setElementData(getLocalPlayer(),"blood", 12000) 
      outputChatBox ("You're now off-duty!",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", false) 
    end 
end 
addCommandHandler("duty", startgm) 
  
 function gmforad() 
    if getElementData(getLocalPlayer(),"logedin") then 
        setElementData(getLocalPlayer(),"blood", 500000) 
        setElementData(getLocalPlayer(),"bleeding", 0) 
        setElementData(getLocalPlayer(),"cold", false) 
        setElementData(getLocalPlayer(),"temperature", 37) 
        setElementData(getLocalPlayer(),"pain", false) 
        setElementData(getLocalPlayer(),"brokenbone", false) 
        setElementData(getLocalPlayer(),"thirst", 100) 
        setElementData(getLocalPlayer(),"food", 100) 
        end 
end 

Link to comment
function startgm() 
    if not getElementData(getLocalPlayer(), "onduty") then 
      gmtimer = setTimer(gmforad, 2000, 0) 
      outputChatBox ("You're now on-duty",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", true) 
    else 
      killTimer (gmtimer) 
      setElementData(getLocalPlayer(),"blood", 12000) 
      outputChatBox ("You're now off-duty!",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", false) 
    end 
end 
addCommandHandler("duty", startgm) 
  
 function gmforad() 
    if getElementData(getLocalPlayer(),"logedin") then 
        setElementData(getLocalPlayer(),"blood", 500000) 
        setElementData(getLocalPlayer(),"bleeding", 0) 
        setElementData(getLocalPlayer(),"cold", false) 
        setElementData(getLocalPlayer(),"temperature", 37) 
        setElementData(getLocalPlayer(),"pain", false) 
        setElementData(getLocalPlayer(),"brokenbone", false) 
        setElementData(getLocalPlayer(),"thirst", 100) 
        setElementData(getLocalPlayer(),"food", 100) 
        end 
end 

thanks ALOT!

Link to comment

If I am not mistaken, this is for a DayZ server, therefore, you can use a check for the 'admin' (or 'support') element data.

function startgm() 
    if not getElementData(getLocalPlayer(), "admin") then outputChatBox("You are not an admin.", 255, 0, 0) return; end --End function here if client is not an admin 
    if not getElementData(getLocalPlayer(), "onduty") then 
      gmtimer = setTimer(gmforad, 2000, 0) 
      outputChatBox ("You're now on-duty",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", true) 
    else 
      killTimer (gmtimer) 
      setElementData(getLocalPlayer(),"blood", 12000) 
      outputChatBox ("You're now off-duty!",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", false) 
    end 
end 
addCommandHandler("duty", startgm) 
  
 function gmforad() 
    if getElementData(getLocalPlayer(),"logedin") then 
        setElementData(getLocalPlayer(),"blood", 500000) 
        setElementData(getLocalPlayer(),"bleeding", 0) 
        setElementData(getLocalPlayer(),"cold", false) 
        setElementData(getLocalPlayer(),"temperature", 37) 
        setElementData(getLocalPlayer(),"pain", false) 
        setElementData(getLocalPlayer(),"brokenbone", false) 
        setElementData(getLocalPlayer(),"thirst", 100) 
        setElementData(getLocalPlayer(),"food", 100) 
        end 
end 

Link to comment

Server

function setPlayerDutyStats(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then 
        triggerClientEvent(thePlayer, "onPlayerOnDuty", thePlayer) 
    end 
end 
addCommandHandler("aduty", setPlayerDutyStats) 

Client

function startgm() 
    if not getElementData(getLocalPlayer(), "onduty") then 
      gmtimer = setTimer(gmforad, 2000, 0) 
      outputChatBox ("You're now on-duty",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", true) 
    else 
      killTimer (gmtimer) 
      setElementData(getLocalPlayer(),"blood", 12000) 
      outputChatBox ("You're now off-duty!",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", false) 
    end 
end 
addEvent("onPlayerOnDuty", true) 
addEventHandler("onPlayerOnDuty", root, startgm) 
  
function gmforad() 
    if getElementData(getLocalPlayer(),"logedin") then 
        setElementData(getLocalPlayer(),"blood", 500000) 
        setElementData(getLocalPlayer(),"bleeding", 0) 
        setElementData(getLocalPlayer(),"cold", false) 
        setElementData(getLocalPlayer(),"temperature", 37) 
        setElementData(getLocalPlayer(),"pain", false) 
        setElementData(getLocalPlayer(),"brokenbone", false) 
        setElementData(getLocalPlayer(),"thirst", 100) 
        setElementData(getLocalPlayer(),"food", 100) 
    end 
end 

Link to comment
Server
function setPlayerDutyStats(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then 
        triggerClientEvent(thePlayer, "onPlayerOnDuty", thePlayer) 
    end 
end 
addCommandHandler("aduty", setPlayerDutyStats) 

Client

function startgm() 
    if not getElementData(getLocalPlayer(), "onduty") then 
      gmtimer = setTimer(gmforad, 2000, 0) 
      outputChatBox ("You're now on-duty",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", true) 
    else 
      killTimer (gmtimer) 
      setElementData(getLocalPlayer(),"blood", 12000) 
      outputChatBox ("You're now off-duty!",255, 0, 0,true) 
      setElementData(getLocalPlayer(), "onduty", false) 
    end 
end 
addEvent("onPlayerOnDuty", true) 
addEventHandler("onPlayerOnDuty", root, startgm) 
  
function gmforad() 
    if getElementData(getLocalPlayer(),"logedin") then 
        setElementData(getLocalPlayer(),"blood", 500000) 
        setElementData(getLocalPlayer(),"bleeding", 0) 
        setElementData(getLocalPlayer(),"cold", false) 
        setElementData(getLocalPlayer(),"temperature", 37) 
        setElementData(getLocalPlayer(),"pain", false) 
        setElementData(getLocalPlayer(),"brokenbone", false) 
        setElementData(getLocalPlayer(),"thirst", 100) 
        setElementData(getLocalPlayer(),"food", 100) 
    end 
end 

thanks

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