Jump to content

GodMode Script Admin Only!


Recommended Posts

I Cant make it admin only

local godModeState = false 
  
addCommandHandler ( "godmode", 
    function ( ) 
      if  exports.global:isPlayerSuperAdmin( ) 
        godModeState = ( not godModeState ) 
        outputChatBox ( "God Mode is now ".. ( godModeState and "Enabled" or "Disabled" ) ..".", 0, 255, 0 ) 
    end 
    end 
) 
  
function togdamage ( attacker, weapon, bodypart ) 
    if ( godModeState ) then 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onClientPlayerDamage", localPlayer, togdamage ) 

Link to comment
addCommandHandler("godmode", 
    function() 
        if exports.global:isPlayerSuperAdmin() then 
            if getElementData(source, "godmode") and getElementData(source, "godmode") == true then 
                setElementData(localPlayer, "godmode", false) 
                outputChatBox("God Mode is now disabled.", 0, 255, 0, false) 
            else 
                setElementData(localPlayer, "godmode", true) 
                outputChatBox("God Mode is now enabled.", 0, 255, 0, false) 
            end 
        end 
    end 
) 
  
function togdamage(attacker, weapon, bodypart) 
    if getElementData(source, "godmode") and getElementData(source, "godmode") == true then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", localPlayer, togdamage) 

Link to comment
addCommandHandler("godmode", 
    function() 
        if exports.global:isPlayerSuperAdmin() then 
            if getElementData(source, "godmode") and getElementData(source, "godmode") == true then 
                setElementData(localPlayer, "godmode", false) 
                outputChatBox("God Mode is now disabled.", 0, 255, 0, false) 
            else 
                setElementData(localPlayer, "godmode", true) 
                outputChatBox("God Mode is now enabled.", 0, 255, 0, false) 
            end 
        end 
    end 
) 
  
function togdamage(attacker, weapon, bodypart) 
    if getElementData(source, "godmode") and getElementData(source, "godmode") == true then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", localPlayer, togdamage) 

Does'nt Work :/

Link to comment

Try:

addCommandHandler("godmode", 
    function() 
        if exports.global:isPlayerSuperAdmin() then 
            if getElementData(localPlayer, "godmode") and getElementData(localPlayer, "godmode") == true then 
                setElementData(localPlayer, "godmode", false) 
                outputChatBox("God Mode is now disabled.", 0, 255, 0, false) 
            else 
                setElementData(localPlayer, "godmode", true) 
                outputChatBox("God Mode is now enabled.", 0, 255, 0, false) 
            end 
        end 
    end 
) 
  
function togdamage(attacker, weapon, bodypart) 
    if getElementData(source, "godmode") and getElementData(source, "godmode") == true then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", localPlayer, togdamage) 

Link to comment

He not showed source code function IsPlayerSuperAdmin. I'm not a telepathist.

setElementData 
getElementData 

Server side: Player login -> if player admin then set data 'Admin' and etc.

Client side: just check what return data.

Link to comment

@micheal1230: This should work:

local godModeState = false 
  
addCommandHandler ( "godmode", 
    function ( ) 
        if ( exports.global:isPlayerSuperAdmin ( localPlayer ) ) then -- You had forgot to define 'localPlayer' and forgot about 'then'. 
            godModeState = ( not godModeState ) 
            outputChatBox ( "God Mode is now ".. ( godModeState and "Enabled" or "Disabled" ) ..".", 0, 255, 0 ) 
        end 
    end 
) 
  
function togdamage ( attacker, weapon, bodypart ) 
    if ( godModeState ) then 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onClientPlayerDamage", localPlayer, togdamage ) 

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