drk Posted February 4, 2012 Share Posted February 4, 2012 in mta 1.0.5 when I use "if (money > 500) then" it works. Now, in MTA 1.3 I get an error ( unexpected symbol near ... ) I tried with =>, >=. But don't work lol Link to comment
drk Posted February 4, 2012 Author Share Posted February 4, 2012 Why tonumber()? the code is: elseif (money <= 5000 and > 1000) then I don't know why it needs tonumber full code: setTimer( function() local account = getPlayerAccount(source) local money = getPlayerMoney(source) if (money <= 1000) then setAccountData(account,'My Level','New User') setElementData(source,'Level','New User') elseif (money <= 5000 and > 1000) then setAccountData(account,'My Level','Regular') setElementData(source,'Level','Regular') elseif (money <= 20000 and > 1000) then setAccountData(account,'My Level','Experienced') setElementData(source,'Level','Experienced') elseif (money <= 45000 and > 20000) then setAccountData(account,'My Level','Veteran') setElementData(source,'Level','Veteran') elseif (money > 45000) then setAccountData(account,'My Level','Guru') setElementData(source,'Level','Guru') end end,500,0) Link to comment
Castillo Posted February 4, 2012 Share Posted February 4, 2012 setTimer( function() if (not source) then return end local account = getPlayerAccount(source) local money = getPlayerMoney(source) if (money >= 1000) then setAccountData(account,'My Level','New User') setElementData(source,'Level','New User') elseif (money >= 5000 and money > 1000) then setAccountData(account,'My Level','Regular') setElementData(source,'Level','Regular') elseif (money >= 20000 and money > 1000) then setAccountData(account,'My Level','Experienced') setElementData(source,'Level','Experienced') elseif (money >= 45000 and money > 20000) then setAccountData(account,'My Level','Veteran') setElementData(source,'Level','Veteran') elseif (money > 45000) then setAccountData(account,'My Level','Guru') setElementData(source,'Level','Guru') end end,500,0) Link to comment
Kenix Posted February 4, 2012 Share Posted February 4, 2012 Learn it http://www.lua.org/manual/5.1/ https://wiki.multitheftauto.com/wiki/Scr ... troduction source in your code nil. This correct. Server local timer = { } addEventHandler( 'onPlayerLogin',root, function( ) timer[ source ] = setTimer( function( player ) local account = getPlayerAccount( player ) if not isGuestAccount( account ) then local money = getPlayerMoney( player ) if money <= 1000 then setAccountData( account,'My Level','New User' ) setElementData( player,'Level','New User' ) elseif money <= 5000 and money > 1000 then setAccountData( account,'My Level','Regular' ) setElementData( player,'Level','Regular' ) elseif money <= 20000 and money > 1000 then setAccountData( account,'My Level','Experienced' ) setElementData( player,'Level','Experienced' ) elseif money <= 45000 and money > 20000 then setAccountData( account,'My Level','Veteran' ) setElementData( player,'Level','Veteran' ) elseif money > 45000 then setAccountData( account,'My Level','Guru' ) setElementData( player,'Level','Guru' ) end end end, 500,0,source ) end ) addEventHandler( 'onPlayerQuit',root, function( ) timer[ source ] = nil end ) If you create timer in server side and you update player stats or something ,better create with table and player is index. Remember it Link to comment
drk Posted February 4, 2012 Author Share Posted February 4, 2012 I don't need to learn this again My question is about ">" not about "source is nil". But, ok dude D: Np. I will try Link to comment
Kenix Posted February 4, 2012 Share Posted February 4, 2012 No problem I going sleep. Link to comment
drk Posted February 4, 2012 Author Share Posted February 4, 2012 It worked! Thanks Kenix and castillo for trying to help too 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