Jump to content

Creating Giveplayer Money


Mayfair

Recommended Posts

Hello there,

I am thinking(Wanting) to create a script that gives all players in my server a check sum of money every few minutes or so, So i think i'd need to use a timer.

But i'm not sure how to (where to) start on creating a script that gives all players in my server money every so offten.

Would it be possable if someone could help me create this script or point me into the correct direction

Thank you,

Link to comment

This is an example in its simplest form.

  
local CASH_INCREASE = 1000 -- increase by $1000 
local INTERVAL = 5000 -- increase every 5 seconds 
  
function givePlayersMoney() 
  for _, player in ipairs(getElementsByType("player") or {}) do 
    givePlayerMoney(player, CASH_INCREASE) 
  end 
  setTimer(givePlayersMoney, INTERVAL, 1) 
end 
  
givePlayersMoney() 
  

Link to comment

you need a function which gives all players of the server an amount of money

http://development.mtasa.com/index.php? ... layerMoney

givePlayerMoney ( player thePlayer, int amount ) 

for "player theplayer" you can use getRootElement() which means all players

for "int amount" you use your own amount as number

now you need the setTimer function

http://development.mtasa.com/index.php?title=SetTimer

setTimer ( function theFunction, int timeInterval, int timesToExecute, [ var arguments... ] )] 

as "function theFunction" you might use givePlayerMoney

for "int timeInterval" you use the time between the function runs in milliseconds

as "int timesToExecute" you use 0 for unlimited runs

"[ var arguments... ]" are the arguments of the function you use

in this case you must use "player thePlayer" and "int amount"

i hope this helps you a bit ;)

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