Jump to content

Godmode only for admins


xTravax

Recommended Posts

Hello again!

I Got a godmode command script and i don't know what to put in lua file for that only admins can use that command

so like only acl "Admin" can use it

so if you can do it for me it would be nice

but pls dont post me functions idk to script i just need that someone edit my script so i can have that only acl group "Admin"

can use command /godmode

so here's script

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

Link to comment

Try that

server

local godModeState = false 
  
function enabled(player) 
    local account=getAccountName(getPlayerAccount(player)) 
    if(isObjectInACLGroup("user."..account,aclGetGroup("Admin")))then 
        addEventHandler("onPlayerDamage", root, togdamage ) 
        outputChatBox("God mode is now enabled",0,255,0) 
        addCommandHandler("godmode",disabled) 
        removeCommandHandler("godmode",enabled) 
        godModeState = true 
    end 
end 
addCommandHandler("godmode",enabled) 
  
function disabled(player) 
    local account=getAccountName(getPlayerAccount(player)) 
    if(isObjectInACLGroup("user."..account,aclGetGroup("Admin")))then 
        removeEventHandler("onPlayerDamage", root, togdamage ) 
        outputChatBox("God mode is now disabled",0,255,0) 
        addCommandHandler("godmode",enabled) 
        for i,v in ipairs(getElementsByType("player")) do 
            removeElementData(v,"godMode") 
        end 
        godModeState = false 
    end 
end 
  
function togdamage() 
    local account=getAccountName(getPlayerAccount(source)) 
    if(isObjectInACLGroup("user."..account,aclGetGroup("Admin")))then 
        setElementData(source,"godMode","true") 
    end 
end 

client

addEventHandler("onClientPlayerDamage",localPlayer, 
    function() 
        if(getElementData(source,"godMode"))then 
            cancelEvent() 
        end 
    end 
) 

Link to comment

Now when i write /godmode

it starts twice

so its like with no color like usually

it shows

Godmode disabled!

Godmode enabled!

and when i reconnect it does

Godmode enabled!

Godmode disabled!

but when i write /godmode

it at same time disables and enables godmode so pls fix it

im not some scripter but in some scripts when you use setTimer it changes only once idk but pls help me

Link to comment

-- server side:

function enabled ( player ) 
    local account = getAccountName ( getPlayerAccount ( player ) ) 
    if ( isObjectInACLGroup ( "user.".. account,aclGetGroup ( "Admin" ) ) )then 
        local state = ( not getElementData ( player, "godMode" ) ) 
        outputChatBox ( "God mode is now ".. ( state and "enabled" or "disabled" ) .."", player, 255, 0, 0 ) 
        setElementData ( player, "godMode", state ) 
    end 
end 
addCommandHandler ( "godmode", enabled ) 

-- client side:

addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function ( ) 
        if ( getElementData ( source, "godMode" ) ) then 
            cancelEvent ( ) 
        end 
    end 
) 

Link to comment
-- server side:
function enabled ( player ) 
    local account = getAccountName ( getPlayerAccount ( player ) ) 
    if ( isObjectInACLGroup ( "user.".. account,aclGetGroup ( "Admin" ) ) )then 
        local state = ( not getElementData ( player, "godMode" ) ) 
        outputChatBox ( "God mode is now ".. ( state and "enabled" or "disabled" ) .."", player, 255, 0, 0 ) 
        setElementData ( player, "godMode", state ) 
    end 
end 
addCommandHandler ( "godmode", enabled ) 

-- client side:

addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function ( ) 
        if ( getElementData ( source, "godMode" ) ) then 
            cancelEvent ( ) 
        end 
    end 
) 

But i guess it'll only 'godmode' for the admin who've typed this command , and i think he wants it for all admins.

Link to comment
Then castillo's code is what you need.

yea i know that -__-

but like i said when i use his script other people see when i enabled godmode

so i do /godmode and other 40 players see that i activated godmode

but it doesnt show like HuX has enabled GodMode!

it shows like GodMode is Enabled!

i dont want that players see on chat when i use /godmode command

Link to comment
Then castillo's code is what you need.

yea i know that -__-

but like i said when i use his script other people see when i enabled godmode

so i do /godmode and other 40 players see that i activated godmode

but it doesnt show like HuX has enabled GodMode!

it shows like GodMode is Enabled!

i dont want that players see on chat when i use /godmode command

Try changing player to source.

Link to comment
Then castillo's code is what you need.

yea i know that -__-

but like i said when i use his script other people see when i enabled godmode

so i do /godmode and other 40 players see that i activated godmode

but it doesnt show like HuX has enabled GodMode!

it shows like GodMode is Enabled!

i dont want that players see on chat when i use /godmode command

See on wiki

outputChatBox 

to get hex codes

learn scripting

no one will not make it for you

* Then you quit, your element data will removed

Link to comment
Then castillo's code is what you need.

yea i know that -__-

but like i said when i use his script other people see when i enabled godmode

so i do /godmode and other 40 players see that i activated godmode

but it doesnt show like HuX has enabled GodMode!

it shows like GodMode is Enabled!

i dont want that players see on chat when i use /godmode command

It has to work, the only player argument you have is the one who used the command, and outputChatBox is set to output to that player, post your code.

Link to comment

--client side

addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function ( ) 
        if ( getElementData ( source, "godMode" ) ) then 
            cancelEvent ( ) 
        end 
    end 
) 

--server side

function enabled ( player ) 
    local account = getAccountName ( getPlayerAccount ( player ) ) 
    if ( isObjectInACLGroup ( "user.".. account,aclGetGroup ( "Admin" ) ) )then 
        local state = ( not getElementData ( player, "godMode" ) ) 
        outputChatBox ( "God mode is now ".. ( state and "enabled" or "disabled" ) .."", 255, 0, 0 ) 
        setElementData ( player, "godMode", state ) 
    end 
end 
addCommandHandler ( "godmode", enabled ) 

I Don't know i mean it works normally but only the problem is that other players see on chat when i use it and they shouldnt see that..

Link to comment
    function enabled ( player ) 
        local account = getAccountName ( getPlayerAccount ( player ) ) 
        if ( isObjectInACLGroup ( "user.".. account,aclGetGroup ( "Admin" ) ) )then 
            local state = ( not getElementData ( player, "godMode" ) ) 
            outputChatBox ( "God mode is now ".. ( state and "enabled" or "disabled" ) .."", player, 255, 0, 0 ) 
            setElementData ( player, "godMode", state ) 
        end 
    end 
    addCommandHandler ( "godmode", enabled ) 

Link to comment
--client side
addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function ( ) 
        if ( getElementData ( source, "godMode" ) ) then 
            cancelEvent ( ) 
        end 
    end 
) 

--server side

function enabled ( player ) 
    local account = getAccountName ( getPlayerAccount ( player ) ) 
    if ( isObjectInACLGroup ( "user.".. account,aclGetGroup ( "Admin" ) ) )then 
        local state = ( not getElementData ( player, "godMode" ) ) 
        outputChatBox ( "God mode is now ".. ( state and "enabled" or "disabled" ) .."", 255, 0, 0 ) 
        setElementData ( player, "godMode", state ) 
    end 
end 
addCommandHandler ( "godmode", enabled ) 

I Don't know i mean it works normally but only the problem is that other players see on chat when i use it and they shouldnt see that..

Does the chat message has colors?

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