Jump to content

big lol


drk

Recommended Posts

Posted

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

Posted

Why tonumber()? the code is:

elseif (money <= 5000 and > 1000) then 

I don't know why it needs tonumber :S

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) 

Posted
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) 

Posted

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

Posted

I don't need to learn this again :lol: My question is about ">" not about "source is nil". But, ok dude D: Np.

I will try

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