Jump to content

Godmode went wrong


GerardWay

Recommended Posts

guys what is wrong with this script?

function EnableGodmode() 
GodMode=EnableGodmode 
outputChatBox (" #ff0000Godmode is now enabled!!!!",root,255,255,255,true) 
end 
addCommandHandler ("godmode", EnableGodmode) 

i was just messing around and trying to script different scripts but now i need info on this can anyone fix please?

Link to comment
  
local GodMode = false 
  
function EnableGodmode() 
    if (not GodMode) then 
        GodMode=true 
        outputChatBox (" #ff0000Godmode is now enabled!!!!", 255, 255, 255, true) 
    else 
         GodMode=false 
         outputChatBox (" #ff0000Godmode is now disabled!!!!", 255, 255, 255, true) 
    end 
end 
addCommandHandler ("godmode", EnableGodmode) 
  
function godModeDamageCheck() 
    if (GodMode) then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", getLocalPlayer(), godModeDamageCheck) 
  

Link to comment
  • Discord Moderators

a simpler way to toggle:

strGodmodeMessage = " #ff0000Godmode is now: %s!!!!" 
  
function EnableGodmode() 
GodMode = not GodMode 
outputChatBox (strGodmodeMessage:format(GodMode), 255, 255, 255, true) 
end 
addCommandHandler ("godmode", EnableGodmode) 

Your original example was serverside. The above is clientside. If you want it to remain on the serverside, you should try something with onPlayerDamage + setElementHealth (with loss value)

I'm not sure whether that'll prevent against hard deaths though.

Link to comment
  • 2 weeks later...

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