Jump to content

How to create god mod for dayz?


Ianito

Recommended Posts

You should be able to use those functions and events;
onPlayerDamage 
cancelEvent 

I'd give you an example, but I've got to get back to work. Just home over lunch, if no-one else has responded by then I'll make one for you. :)

I'll try here as well, thanks for helping me bro :)

Link to comment

Here you go;

Server-Side(Requires Admin permission);

function toggleGodMode(thePlayer, cmd) 
local theAccountName = getAccountName(getPlayerAccount(thePlayer)) 
    if(isObjectInACLGroup("user."..theAccountName, aclGetGroup("Admin"))) then 
        local currentStatus = getElementData(thePlayer, "MISC.GodMode") 
        if(currentStatus ~= false) then 
            setElementData(thePlayer, "MISC.GodMode", false) 
            outputChatBox("#696969[server]: #B8B8B8You have #B80000de-activated#B8B8B8 God Mode!", thePlayer, 255, 255, 255, true) 
        else 
            setElementData(thePlayer, "MISC.GodMode", true) 
            outputChatBox("#696969[server]: #B8B8B8You have #00B800activated#B8B8B8 God Mode!", thePlayer, 255, 255, 255, true) 
        end 
    end 
end 
addCommandHandler("god", toggleGodMode, false, false) 

Client-Side;

function cancelDamage() 
    if(getElementData(localPlayer, "MISC.GodMode") == true) then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), cancelDamage) 

Link to comment
Here you go;

Server-Side(Requires Admin permission);

function toggleGodMode(thePlayer, cmd) 
local theAccountName = getAccountName(getPlayerAccount(thePlayer)) 
    if(isObjectInACLGroup("user."..theAccountName, aclGetGroup("Admin"))) then 
        local currentStatus = getElementData(thePlayer, "MISC.GodMode") 
        if(currentStatus ~= false) then 
            setElementData(thePlayer, "MISC.GodMode", false) 
            outputChatBox("#696969[server]: #B8B8B8You have #B80000de-activated#B8B8B8 God Mode!", thePlayer, 255, 255, 255, true) 
        else 
            setElementData(thePlayer, "MISC.GodMode", true) 
            outputChatBox("#696969[server]: #B8B8B8You have #00B800activated#B8B8B8 God Mode!", thePlayer, 255, 255, 255, true) 
        end 
    end 
end 
addCommandHandler("god", toggleGodMode, false, false) 

Client-Side;

function cancelDamage() 
    if(getElementData(localPlayer, "MISC.GodMode") == true) then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), cancelDamage) 

Did not work bro, the blood of DayZ is different from normal, is "blood"

Link to comment

I made this little script, it can help you.

do not know much. honeymoon because I started just learn from dayz

if errors can let me know :)

  
function godon(player) 
local theAccountName = getAccountName (getPlayerAccount (player)) 
     if (isObjectInACLGroup ("user." .. theAccountName, aclGetGroup ("Admin"))) then 
local QntAtual = getElementData(player,"blood")  
 setElementData(player, "blood", QntAtual + 31313131)  
end 
addCommandHandler("godon", godon) 
  
function godoff(player) 
local theAccountName = getAccountName (getPlayerAccount (player)) 
     if (isObjectInACLGroup ("user." .. theAccountName, aclGetGroup ("Admin"))) then 
setElementData (player, "blood", 12000 ) 
end 
addCommandHandler("godoff", godoff) 

Edited by Guest
Link to comment
You have one big mistake there, you put part of the code outside the function, also ,is "local" lowercase.

is right now?

google translator left in place a capital

  
function godon ( jogador ) 
local theAccountName = getAccountName ( getPlayerAccount ( jogador ) ) 
     if ( isObjectInACLGroup ( "user". .. theAccountName, aclGetGroup ( "Admin" ) ) ) then 
local QntAtual = getElementData ( jogador , "sangue" ) 
 setElementData ( jogador , "sangue" , QntAtual + 31313131 ) 
end 
addCommandHandler ( "godon" , godon ) 
  
function godoff ( jogador ) 
local theAccountName = getAccountName ( getPlayerAccount ( jogador ) ) 
     if ( isObjectInACLGroup ( "user". .. theAccountName, aclGetGroup ( "Admin" ) ) ) then 
setElementData ( jogador , "sangue" , 12000 ) 
end 
addCommandHandler ( "godoff" , godoff ) 

Edited by Guest
Link to comment
local godTable = {} 
  
  
function godmodeCheck(dataName,oldValue) 
    if getElementType(source) == "player" and dataName == "blood" then 
        if godTable[source] == true then 
            local newValue = getElementData(source,dataName) 
            setElementData( source, dataName, oldValue ) 
        end 
    end 
end 
addEventHandler("onElementDataChange",root,godmodeCheck) 
  
  
function godModeOn(player) 
local theAccountName = getAccountName (getPlayerAccount (player)) 
    if (isObjectInACLGroup ("user." .. theAccountName, aclGetGroup ("Admin"))) then 
        godTable[player] = true 
    end 
end 
addCommandHandler("godon", godModeOn) 
  
function godModeOff(player) 
local theAccountName = getAccountName (getPlayerAccount (player)) 
    if (isObjectInACLGroup ("user." .. theAccountName, aclGetGroup ("Admin"))) then 
        godTable[player] = false 
    end 
end 
addCommandHandler("godoff", godModeOff) 
  
addEventHandler ( "onPlayerJoin", root, function () 
godTable[source] = false 
end) 
  
addEventHandler ( "onResourceStart", resourceRoot, function () 
    for _,player in ipairs(getElementsByType ( "player" ) ) do 
        godTable[player] = false 
    end 
end) 
  

Edited by Guest
Link to comment

Try this :

addEventHandler( "onElementDataChange", root, function( dataName, oldValue ) 
    if getElementType( source ) == "player" and dataName == "blood" then 
        if getElementData( source, "godModState" ) then 
            setElementData( source, dataName, oldValue ) 
        end 
    end 
end ) 
  
addCommandHandler("godon", function( player ) 
    local theAccountName = getAccountName( getPlayerAccount( player ) ) 
    if isObjectInACLGroup( "user." .. theAccountName, aclGetGroup( "Admin") ) then 
        setElementData( source, "godModState", true ) 
    end 
end ) 
  
  
addCommandHandler( "godoff", function( player ) 
    local theAccountName = getAccountName( getPlayerAccount( player ) ) 
    if isObjectInACLGroup( "user." .. theAccountName, aclGetGroup( "Admin" ) ) then 
        setElementData( source, "godModState", false ) 
    end 
end ) 
  
  
addEventHandler ( "onPlayerLogout", root, function ( oldAccount ) 
    local theAccountName = getAccountName( oldAccount ) 
    if isObjectInACLGroup( "user." .. theAccountName, aclGetGroup( "Admin" ) ) then 
        setElementData( source, "godModState", false ) 
    end 
end ) 

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