Jump to content

Getting crazy. Admin


bartje01

Recommended Posts

Hey again...I'm getting a bit crazy now. How can this be wrong?

  
function onWasted (ammo, killer) 
     local account = getPlayerAccount(source) 
     local getPlayerDeaths = getAccountData(account, "data.deaths" ) 
     local getPlayerAdmin = getAccountData(account, "data.adminlevel" ) 
     if getPlayerDeaths then 
      local getPlayerCash = getAccountData(account, "data.cash" ) 
     setTimer( spawnPlayer, 2000, 1, source, 1187.19,-1324.01,13.55 ) 
     outputChatBox ( "You've paid 100$ for medical bill.", source ) 
     setAccountData ( account, "data.cash", tonumber(getPlayerCash) - 100 ) 
     setAccountData ( account, "data.deaths", tonumber(getPlayerDeaths) + 1 ) 
     setAccountData ( account, "data.adminlevel", tonumber(getPlayerAdmin) + 1 ) 
else 
     setAccountData ( account, "data.deaths", 1 ) 
    end 
end 
addEventHandler ( "onPlayerWasted", root, onWasted ) 
  

The cash goes -100. That's good

The deaths goes + 1. That's good

The adminlevel keeps saying: nil. wtf?

I also got an error.

I did all the same as with deaths. Then it should work or not?

  
attempt to perform arithmetic on a nil value 
  

Error line

  
 setAccountData ( account, "data.adminlevel", tonumber(getPlayerAdmin) + 1 ) 
  

Link to comment

It should work now .. tested, by the way I don't get "admin level" .. did you mean rank level or?

function onWasted (ammo, killer) 
     local account = getPlayerAccount(source) 
     local getPlayerDeaths = getAccountData(account, "data.deaths" ) 
     local getPlayerAdmin = getAccountData(account, "data.adminlevel" ) 
     if getPlayerDeaths and getPlayerAdmin then 
      local getPlayerCash = getAccountData(account, "data.cash" ) 
     setTimer( spawnPlayer, 2000, 1, source, 1187.19,-1324.01,13.55 ) 
     outputChatBox ( "You've paid 100$ for medical bill.", source ) 
     setAccountData ( account, "data.cash", tonumber(getPlayerCash) - 100 ) 
     setAccountData ( account, "data.deaths", tonumber(getPlayerDeaths) + 1 ) 
     setAccountData ( account, "data.adminlevel", tonumber(getPlayerAdmin) + 1 ) 
     outputChatBox ( "You are now admin level: " .. getPlayerAdmin, source ) 
else 
     setAccountData ( account, "data.deaths", 1 ) 
     setAccountData ( account, "data.adminlevel", 1 ) 
    end 
addEventHandler ( "onPlayerWasted", root, onWasted ) 
end 

Link to comment

Alright. I editted into a cmd. It doesn't work :(

  
function setAdmin ( sourcePlayer,cmd,who,amount) 
    if ( not who and not amount ) then outputChatBox("*Use /makeadmin [Name] [level]", sourcePlayer, 180, 0, 0 ) return end 
    local gived = getPlayerFromName ( who ) 
    if not gived then outputChatBox("The player "..who.." is not connected", sourcePlayer, 180, 0, 0 ) return end 
    account = getPlayerAccount(gived) 
    if not isGuestAccount ( account ) then 
        local playerAdmin = getAccountData ( account, "data.adminlevel" ) 
         local success = setAccountData ( account, "data.adminlevel", tonumber(playerAdmin) ,tonumber(amount)) 
        if success then 
            outputChatBox ( "Your admin level has been setted.", gived ) 
            outputChatBox ( "You've setted his admin level.", sourcePlayer ) 
        else 
            outputChatBox("ERROR: His adminlevel his not setted", sourcePlayer, 180, 0, 0 ) 
        end 
    end 
end 
addCommandHandler ( "makeadmin", setAdmin ) 
  

Link to comment

I didn't tested it yet but I saw small syntax error, look:

local success = setAccountData ( account, "data.adminlevel", tonumber(playerAdmin) ,tonumber(amount)) 

You are using " , " instead of " + " and that will aply as a next argument so try this:

local success = setAccountData ( account, "data.adminlevel", tonumber(playerAdmin)+tonumber(amount)) 

(line 9)

Link to comment
function setAdmin ( sourcePlayer,cmd,who,level) 
    if ( not who and not level ) then outputChatBox("*Use /makeadmin [Name] [level]", sourcePlayer, 180, 0, 0 ) return end 
    local gived = getPlayerFromName ( who ) 
    if not gived then outputChatBox("The player "..who.." is not connected", sourcePlayer, 180, 0, 0 ) return end 
    account = getPlayerAccount(gived) 
    if not isGuestAccount ( account ) then 
         local success = setAccountData ( account, "data.adminlevel", tonumber(level)) 
        if success then 
            outputChatBox ( "Your admin level has been setted to " .. level .. ".", gived ) 
            outputChatBox ( "You've setted his admin level to " .. level .. ".", sourcePlayer ) 
        else 
            outputChatBox("ERROR: His adminlevel his not setted", sourcePlayer, 180, 0, 0 ) 
        end 
    end 
end 
addCommandHandler ( "makeadmin", setAdmin ) 

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