Jump to content

Help! GodMode!


Recommended Posts

try this

server.lua

function togglestaffMode(thePlayer) 
  
if hasObjectPermissionTo(thePlayer,"general.adminpanel",false) then 
  
    if getElementData(thePlayer,"invincible") then 
        setElementData(thePlayer,"invincible",false) 
        outputChatBox("member of team." .. getPlayerName(thePlayer) .. " Is unprotected!", getRootElement(), 255, 255, 255,true ) 
    else 
        setElementData(thePlayer,"invincible",true) 
        outputChatBox("member of team." .. getPlayerName(thePlayer) .. " Is protected!", getRootElement(), 255, 255, 255,true ) 
        end 
    end 
end 
addCommandHandler("GodMode",togglestaffMode) 
  

client.lua

addEventHandler ( "onClientPlayerDamage",root, 
function () 
    if getElementData(source,"invincible") then 
        cancelEvent() 
    end 
end) 
  
addEventHandler("onClientPlayerStealthKill",localPlayer, 
function (targetPlayer) 
    if getElementData(targetPlayer,"invincible") then 
        cancelEvent() 
    end 
end) 

Link to comment
function dontTryBug(element) 
    if element == localPlayer then 
        if ( guiGetVisible ( oneMinute ) ~= true ) then 
            if source == injectMarker then 
                addEventHandler ("onClientRender", root, dxMenu ) 
                guiSetVisible ( injectBtn, true ) 
                showCursor ( true ) 
                addEventHandler ( "onClientPlayerDamage", root, 
                function() 
                cancelEvent() 
                end) 
            else 
                if timeRem ~= "Time Remaining : 0 Seconds" then 
                    if source == injectMarker then 
                    showCursor ( false ) 
                    guiSetVisible ( injectBtn, false ) 
                    removeEventHandler ("onClientRender", root, dxMenu ) 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientMarkerHit", getRootElement(), dontTryBug) 

See I added the cancel event, now I want to remove it !

Link to comment
function one() 
guiSetText ( oneMinute, "Damage On")  
setTimer ( two, 1000, 1)   
addEventHandler ( 'onClientPlayerDamage', root, cancelEvent ); 
end 
  
function two() 
guiSetText ( oneMinute, "Damage Off")   
setTimer ( one, 1000, 1)   
setTimer ( removeEventHandler, 1000, 1, 'onClientPlayerDamage', root, cancelEvent ); 
end 

Bad argument @ 'removeEventHandler' [Expected function at argument 3, got nil] 

Link to comment
function one() 
guiSetText(oneMinute, "Damage On") 
setTimer(two, 1000, 1) 
cancelEvent() 
end 
addEventHandler("onClientPlayerDamage", root, one) 
  
function two() 
guiSetText(oneMinute, "Damage Off") 
setTimer(one, 1000, 1) 
cancelEvent() 
end 
removeEventHandler("onClientPlayerDamage", root, two) 

Link to comment
function one() 
guiSetText(oneMinute, "Damage On") 
setTimer(two, 1000, 1) 
cancelEvent() 
end 
addEventHandler("onClientPlayerDamage", root, one) 
  
function two() 
guiSetText(oneMinute, "Damage Off") 
setTimer(one, 1000, 1) 
cancelEvent() 
end 
removeEventHandler("onClientPlayerDamage", root, two) 

There's no event attached to function two, so why you are using removeEventHandler lol

---

You dont really need to delete the event handler

just use element data

function godMode() 
    if getElementData(source,"godMode") == true then 
    cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage",root,godMode) 

Link to comment
function one() 
guiSetText(oneMinute, "Damage On") 
setTimer(two, 1000, 1) 
cancelEvent() 
addEventHandler("onClientPlayerDamage", root, one) 
end 
  
function two() 
guiSetText(oneMinute, "Damage Off") 
setTimer(one, 1000, 1) 
removeEventHandler("onClientPlayerDamage", root, one) 
end 

Link to comment

Well I have a little timer, like 10 Seconds,

And when the 10 Seconds start,

It adds in god mode,

When 10 seconds stop,

It removes god mode.

My script is like this,

function hundredtsixt()  
guiSetText ( oneMinute, "GodMode On!")    
setTimer ( hundredtsevt, 1000, 1)   
--- Starts the god mode 
end 
  
function hundredtsevt()  
guiSetText ( oneMinute, "GodMode Off!")    
setTimer ( hundredteht, 1000, 1)   
--- Stops GodMode 
end 

Link to comment
function hundredtsixt ( ) 
    guiSetText ( oneMinute, "GodMode On!" ); 
    setTimer ( setElementData, 1000, 1, localPlayer, "godmode", true ); 
end 
  
function hundredtsevt ( ) 
    guiSetText ( oneMinute, "GodMode Off!" ); 
    setTimer ( setElementData, 1000, 1, localPlayer, "godmode", false ); 
end 
  
addEventHandler ( "onClientPlayerDamage", root, 
    function ( ) 
        if ( getElementData ( source, "godmode" ) ) then 
            cancelEvent ( ); 
        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...