Jump to content

god mode


mint3d

Recommended Posts

Posted

only example, try

  
-- server 
local GodCommand = "god" -- command 
  
function SetGodAdmin(P) 
if isGuestAccount(getPlayerAccount(P)) then return outputChatBox("Only Adm can use",P) end -- guest 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(P)),aclGetGroup( "Admin" )) then -- is admin? 
local Is = getElementData(P,"GodAdmin") -- get data 
if Is then -- if data is true 
removeElementData(P,"GodAdmin") -- lets remove 
outputChatBox("God mod off",P) 
else -- else lets activate 
setElementData(P,"GodAdmin",true) 
outputChatBox("God mod on",P) 
 end 
   end 
      end 
addCommandHandler(GodCommand,SetGodAdmin) 
  
-- client 
  
addEventHandler("onClientPlayerDamage",getLocalPlayer(), 
function() 
if getElementData(source,"GodAdmin") then  
cancelEvent() 
 end 
    end 
) 
  

560x95_FFFFFF_09FF00_050505_000000.png

"Querer não é poder, mas tentar é avançar"!

Posted

your code is a total mess

here try castillo's code

SERVER SIDED:

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 SIDED:

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) 

this is Castillo's code.

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted
only example, try
  
-- server 
local GodCommand = "god" -- command 
  
function SetGodAdmin(P) 
if isGuestAccount(getPlayerAccount(P)) then return outputChatBox("Only Adm can use",P) end -- guest 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(P)),aclGetGroup( "Admin" )) then -- is admin? 
local Is = getElementData(P,"GodAdmin") -- get data 
if Is then -- if data is true 
removeElementData(P,"GodAdmin") -- lets remove 
outputChatBox("God mod off",P) 
else -- else lets activate 
setElementData(P,"GodAdmin",true) 
outputChatBox("God mod on",P) 
 end 
   end 
      end 
addCommandHandler(GodCommand,SetGodAdmin) 
  
-- client 
  
addEventHandler("onClientPlayerDamage",getLocalPlayer(), 
function() 
if getElementData(source,"GodAdmin") then  
cancelEvent() 
 end 
    end 
) 
  

Meh, tried to fix your code a bit using local defined variables:

-- server 
local plrGodadmin = false 
  
function SetGodAdmin(P) 
    if isGuestAccount(getPlayerAccount(P)) then  
        outputChatBox("Only Admins can use this", P, 255, 0, 0) 
        return 
    end -- guest 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(P)),aclGetGroup( "Admin" )) then -- is admin? 
        if (plrGodadmin == true) then -- if data is true 
            plrGodadmin = false -- lets remove 
            outputChatBox("God mod off",P) 
        elseif (plrGodadmin == false) then -- else lets activate 
            plrGodadmin = true 
            outputChatBox("God mod on",P) 
        else 
            return 
        end 
    end 
end 
addCommandHandler("god", SetGodAdmin) 
  
-- client 
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), 
  function() 
    if (plrGodadmin == true) then 
        cancelEvent() 
    end 
end 
) 
  

I can also use element data, buh, try it this way. (Untested)

And now Aurora is back again, pm for more info.

Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA.

Ex. Developer at Community of Social Gamers - CSG

Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP

9o6E8.png Ab-47

Posted

You cannot use it like that.

local plrGodadmin = false 

It will work good as long as one player is on the server, but if there are more players it wont work correctly.

2nd, you dont have plrGodadmin defined client-side.

Posted

Server side

  
function setInince(thePlayer) 
    if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then 
        if (getElementData(thePlayer, "INV") == "true") then 
            setElementData(thePlayer,"INV", "false") 
            outputChatBox("God mode OFF", thePlayer) 
        else 
            setElementData(thePlayer,"INV", "true") 
            outputChatBox("God mode ON", thePlayer) 
        end 
    else 
        outputChatBox("You do not have permission for this", thePlayer) 
    end 
end 
addCommandHandler("god", setInince) 

Client side

function noadmdamage() 
if (getElementData(source, "INV") == "true") then 
    cancelEvent() 
else 
 end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) 
  

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
Server side
  
function setInince(thePlayer) 
    if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then 
        if (getElementData(thePlayer, "INV") == "true") then 
            setElementData(thePlayer,"INV", "false") 
            outputChatBox("God mode OFF", thePlayer) 
        else 
            setElementData(thePlayer,"INV", "true") 
            outputChatBox("God mode ON", thePlayer) 
        end 
    else 
        outputChatBox("You do not have permission for this", thePlayer) 
    end 
end 
addCommandHandler("god", setInince) 

Client side

function noadmdamage() 
if (getElementData(source, "INV") == "true") then 
    cancelEvent() 
else 
 end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) 
  

Would this code even work? I mean, when the player triggers the command for the first time his data is nil towards "INV" so it wouldn't be false or true, which would cause the code not to work, I guess. If the code itself did automatically change the players element data to false, you've defined false as "false" meaning it's in a word-form, not recognizable by MTA, just a data definition.

Suggestion, if what I say is correct:

  
function onJoin() 
     if (not getElementData(source, "INV") then 
          setElementData(source, "INV", "false") 
     end 
end 
addEventHandler("onPlayerJoin", root, onJoin) --Not tested 

And now Aurora is back again, pm for more info.

Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA.

Ex. Developer at Community of Social Gamers - CSG

Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP

9o6E8.png Ab-47

Posted
Server side
  
function setInince(thePlayer) 
    if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then 
        if (getElementData(thePlayer, "INV") == "true") then 
            setElementData(thePlayer,"INV", "false") 
            outputChatBox("God mode OFF", thePlayer) 
        else 
            setElementData(thePlayer,"INV", "true") 
            outputChatBox("God mode ON", thePlayer) 
        end 
    else 
        outputChatBox("You do not have permission for this", thePlayer) 
    end 
end 
addCommandHandler("god", setInince) 

Client side

function noadmdamage() 
if (getElementData(source, "INV") == "true") then 
    cancelEvent() 
else 
 end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) 
  

Would this code even work? I mean, when the player triggers the command for the first time his data is nil towards "INV" so it wouldn't be false or true, which would cause the code not to work, I guess. If the code itself did automatically change the players element data to false, you've defined false as "false" meaning it's in a word-form, not recognizable by MTA, just a data definition.

Suggestion, if what I say is correct:

  
function onJoin() 
     if (not getElementData(source, "INV") then 
          setElementData(source, "INV", "false") 
     end 
end 
addEventHandler("onPlayerJoin", root, onJoin) --Not tested 

Try my code you genius, it's working.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
your code is a total mess

here try castillo's code

SERVER SIDED:

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 SIDED:

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) 

this is Castillo's code.

That code should work.

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