bartje01 Posted March 8, 2011 Share Posted March 8, 2011 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
proracer Posted March 8, 2011 Share Posted March 8, 2011 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
bartje01 Posted March 8, 2011 Author Share Posted March 8, 2011 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
proracer Posted March 8, 2011 Share Posted March 8, 2011 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
bartje01 Posted March 8, 2011 Author Share Posted March 8, 2011 Yes. but when I do + it increases. I want to set it. So when I do /makeadmin player 10 he is admin level 10 and then when I do /makeadmin player 4 he is level 4. Link to comment
proracer Posted March 8, 2011 Share Posted March 8, 2011 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
bartje01 Posted March 8, 2011 Author Share Posted March 8, 2011 Yohohooo. It works fine ! Thankyou very much. I tried anything except this It is so obvious too. Ty Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now