Jump to content

[Help] Function only for Admins


BieHDC

Recommended Posts

Hello,

i have this GodModeScript working very well, but i wanna have for working only for Admins

and it should write in Chatbox if not Admin: "This is only for Admins"

addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", rootElement, 
function() 
      if ( getPlayerMoney (source) >= 70000 ) then 
        takePlayerMoney(source, 70000) 
        outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
        setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
      else 
        outputChatBox("Not enough money.", source, 255, 0, 0, true) 
    end 
  end 
) 

Link to post

Like so?

Attention: If Player not Admin he should loose the money and if admin he loose money and get ghostmode

addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", rootElement, 
function() 
      if ( getPlayerMoney (source) >= 70000 ) then 
        takePlayerMoney(source, 70000) 
          if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
          outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
          setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
      else 
        outputChatBox("Function only for Admins, but you lost money for try to buy.", source, 255, 0, 0, true) 
    end 
  end 
) 

Link to post
Like so?

Attention: If Player not Admin he should loose the money and if admin he loose money and get ghostmode

addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", rootElement, 
function() 
      if ( getPlayerMoney (source) >= 70000 ) then 
        takePlayerMoney(source, 70000) 
          if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
          outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
          setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
      else 
        outputChatBox("Function only for Admins, but you lost money for try to buy.", source, 255, 0, 0, true) 
    end 
  end 
) 

this is going to take player money and then tell him that he's not an admin

EDIT : Try this code

addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", rootElement, 
function() 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
      if ( getPlayerMoney (source) >= 70000 ) then 
        takePlayerMoney(source, 70000) 
        outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
        setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
      else 
        outputChatBox("Not enough money or you're not an admin!", source, 255, 0, 0, true)   
       end      
    end 
  end 
) 

Link to post
This takes normal players money if not admin? > I want normal players to loose money

And admins get godmode for buy? > admins should get godmode for money

so if normal player tries to buy it he only loses money and dosen't get one and admins lose money and get one? is that right?

Link to post
Yes and player should see chat message: Only for Admins, but you loose money for trying to buy
addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", rootElement, 
function() 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
      if ( getPlayerMoney (source) >= 70000 ) then 
        takePlayerMoney(source, 70000) 
        outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
        setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
      else 
        takePlayerMoney(source, 70000) 
        outputChatBox("Only for Admins, but you loose money for trying to buy", source, 255, 0, 0, true)   
       end      
    end 
  end 
) 

Try this ( if the player has 100 dolars his money will turn red( -69900 ).. is that ok? )

Link to post

Doesnt work

if normal player tryes to buy nothng happens no money no message

and if admin buy work but with warning: WARNING: userpanel\server.lua:78 Bad 'vehicle' pointer @ 'setVehicleDamageProof'(1)

Link to post

try

addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", getRootElement(), 
function() 
      if ( getPlayerMoney (source) >= 70000 ) then 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
        takePlayerMoney(source, 70000) 
        outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
        setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
      else 
        takePlayerMoney(source, 70000) 
        outputChatBox("Only for Admins, but you loose money for trying to buy", source, 255, 0, 0, true)   
       end     
    end 
  end 
) 
  
  

Link to post

or

addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", getRootElement(), 
function() 
      if ( getPlayerMoney (source) >= 70000 ) then 
      local Myv = getPedOccupiedVehicle(source) 
       if Myv then 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
        takePlayerMoney(source, 70000) 
        outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
        setVehicleDamageProof(Myv,true) 
        setTimer( setVehicleDamageProof, 60000, 1, Myv, false) 
      else 
        takePlayerMoney(source, 70000) 
        outputChatBox("Only for Admins, but you loose money for trying to buy", source, 255, 0, 0, true)   
       end     
    end 
  end 
 end 
) 
  
  

Link to post
addEvent("buyGodMode", true) 
addEventHandler("buyGodMode", getRootElement(), 
function() 
    if ( getPlayerMoney (source) >= 70000 ) then 
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
        takePlayerMoney(source, 70000) 
        outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) 
        setVehicleDamageProof(getPedOccupiedVehicle(source),true) 
        setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) 
        else 
        takePlayerMoney(source, 70000) 
        outputChatBox("Only for Admins, but you loose money for trying to buy", source, 255, 0, 0, true)   
        end     
    else 
    outputChatBox("You haven't got enough money.", source, 255, 0, 0, true)   
    end 
  end 
) 
  

Link to post

Works perfect^thx man

and how to change to set money to 0

like so?

setPlayerMoney(source, 0) 
outputChatBox("Only for Admins, but you loose ALL money for trying to buy!", source, 255, 0, 0, true)  

Link to post

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