Mayfair Posted December 2, 2008 Share Posted December 2, 2008 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
Ace_Gambit Posted December 2, 2008 Share Posted December 2, 2008 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
eXo|Flobu Posted December 2, 2008 Share Posted December 2, 2008 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
Mayfair Posted December 2, 2008 Author Share Posted December 2, 2008 Thank you both very very much, I have learned alot from both of you. Thank you Ace_Gambit, That script works great and it shows me how everything works too which is excellent. Thanks alot guys! 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