Jump to content

GodMode Script Admin Only!


Recommended Posts

Posted

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 ) 

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

If I helped you, please click the like button on the right ;) Thanks!

Posted
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 :/

Posted

Are you sure this script is running and the resource 'global' is running and you're a super admin?

If I helped you, please click the like button on the right ;) Thanks!

Posted

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) 

Posted

Oh yes, I forgot that, hehe'.

Try Alpha's version, he fixed the 'source' issue there.

If I helped you, please click the like button on the right ;) Thanks!

Posted
Use
setElementData 
getElementData 

Why should he use element data? his script is 100% client side and the function: isPlayerSuperAdmin is as well client side.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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