Jump to content

Godmode went wrong


GerardWay

Recommended Posts

Posted

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?

Posted
  
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) 
  

  • Discord Moderators
Posted

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.

  • 2 weeks later...
Posted

Arran i used ur example and it came up in console that line 17 "getLocalPlayer" was invalid so can u fix it please? i have mtasa 1.1 if that helps and Zango your script doesnt work at all either

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