Jump to content

admin god mode


Recommended Posts

Posted

hello,

i'd like to know how to make it able for admins not to die, does anybody have a resource or script for this?

thank you

ps: i know i've bin asking much on this forum, but soon when i finnish some mission scripts i will upload them on mta community

Posted

Hi,

I don't know if someone have allready made this script.

But i think you can made it youself ;)

Example, when the player are domaged, we check if is an admin and if it's an admin, we cancel the event.

So he are not domaged :D

I think it work...

  
addEventHandler ( "onPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        cancelEvent() 
    end 
end 
  

Posted
Hi,

I don't know if someone have allready made this script.

But i think you can made it youself ;)

Example, when the player are domaged, we check if is an admin and if it's an admin, we cancel the event.

So he are not domaged :D

I think it work...

  
addEventHandler ( "onPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        cancelEvent() 
    end 
end 
  

no it's not work, the event can't be canceled.

https://wiki.multitheftauto.com/wiki/OnPlayerDamage

It should also be noted that canceling this event has no effect. Cancel the client-side event onClientPlayerDamage instead.

Posted

@UP

Hmm You think that's working?

addEventHandler ( "onClientPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        cancelEvent() 
    end 
end 

Posted
  
addEventHandler ( "onPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    local thePlayer = getPlayerName ( thePlayer ) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    setElementHealth ( thePlayer , 100 )   
    end 
end 

You can instead set his health to 100...

Posted
@UP

Hmm You think that's working?

addEventHandler ( "onClientPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        cancelEvent() 
    end 
end 

No, because the functions:

getAccountName 
getPlayerAccount 
isObjectInACLGroup 
aclGetGroup 

is server-side, and the event 'onClientPlayerDamage' is Client-side

Posted

server side

function admin () 
 local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
setElementData(source,"admin",true) 
end 
 end  
  
addEventHandler("onPlayerLogin",resourceRoot,admin) 

client side

addEventHandler ( "onClientPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    if getElementData(source,"admin") then 
        cancelEvent() 
    end 
end) 

Posted
server side
function admin () 
 local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
setElementData(source,"admin",true) 
end 
 end  
  
addEventHandler("onPlayerLogin",resourceRoot,admin) 

client side

addEventHandler ( "onClientPlayerDamage", getRootElement (), 
function(attacker, weapon, bodypart, loss) 
    if getElementData(source,"admin") then 
        cancelEvent() 
    end 
end) 

Fuccckin pro o_O

Posted
Yeah it's cool, but can you add command to toggle it please? :<
  
addCommandHandler("godoff", 
function() 
if (getElementData(source, "admin") == true) then 
setElementData(source, "admin", false) 
end 
end) 
  

Posted

-- server side:

function toggleGodMode(thePlayer) 
local account = getPlayerAccount(thePlayer) 
if (not account or isGuestAccount(account)) then return end 
local accountName = getAccountName(account) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then 
    if getElementData(thePlayer,"invincible") then 
        setElementData(thePlayer,"invincible",false) 
        outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) 
    else 
        setElementData(thePlayer,"invincible",true) 
        outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) 
        end 
    end 
end 
addCommandHandler("godmode",toggleGodMode) 

-- client side:

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) 

Posted
-- server side:
function toggleGodMode(thePlayer) 
local account = getPlayerAccount(thePlayer) 
if (not account or isGuestAccount(account)) then return end 
local accountName = getAccountName(account) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then 
    if getElementData(thePlayer,"invincible") then 
        setElementData(thePlayer,"invincible",false) 
        outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) 
    else 
        setElementData(thePlayer,"invincible",true) 
        outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) 
        end 
    end 
end 
addCommandHandler("godmode",toggleGodMode) 

-- client side:

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) 

Castillo comes and fucck everybody :) Great :shock:

  • 2 weeks later...
Posted

hey,

i have added a part for godmode for moderators in it :)

original /godmode command for admins is still the same

command for moderators is /god

here is server script

thx again solidsnake

function toggleGodMode(thePlayer)

local account = getPlayerAccount(thePlayer)

if (not account or isGuestAccount(account)) then return end

local accountName = getAccountName(account)

if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then

if getElementData(thePlayer,"invincible") then

setElementData(thePlayer,"invincible",false)

outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0)

else

setElementData(thePlayer,"invincible",true)

outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0)

end

end

end

addCommandHandler("godmode",toggleGodMode)

function toggleGodMode(thePlayer)

local account = getPlayerAccount(thePlayer)

if (not account or isGuestAccount(account)) then return end

local accountName = getAccountName(account)

if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Moderator" ) ) ) then

if getElementData(thePlayer,"invincible") then

setElementData(thePlayer,"invincible",false)

outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0)

else

setElementData(thePlayer,"invincible",true)

outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0)

end

end

end

addCommandHandler("god",toggleGodMode)

Posted

Very messed, lemme help.

function toggleGodMode(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if not account or isGuestAccount(account) then return end 
    local accountName = getAccountName(account) 
    if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) or isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Moderator" ) ) then 
        setElementData(thePlayer,"invincible",not getElementData(thePlayer,"invincible")) 
        if getElementData(thePlayer,"invincible") then outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) 
        else outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end 
    end 
    addCommandHandler("godmode",toggleGodMode) 
    addCommandHandler("god",toggleGodMode) 

Posted
Very messed, lemme help.
function toggleGodMode(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if not account or isGuestAccount(account) then return end 
    local accountName = getAccountName(account) 
    if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) or isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Moderator" ) ) then 
        setElementData(thePlayer,"invincible",not getElementData(thePlayer,"invincible")) 
        if getElementData(thePlayer,"invincible") then outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) 
        else outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end 
    end 
    addCommandHandler("godmode",toggleGodMode) 
    addCommandHandler("god",toggleGodMode) 

ah thx :)

i tried it first to make it work without making the codes double, but here it is now :)

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