Help with Paycheck Timer and GivePlayerMoney - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with Paycheck Timer and GivePlayerMoney (
/showthread.php?tid=252070)
Help with Paycheck Timer and GivePlayerMoney -
ernie - 30.04.2011
Hey All,
This is my first time with PAWN and Ive read through the Wiki couldn't find what I was looking for so I thought Id ask here.
Originally,
I had my Paycheck code only work on Player id 0. So that every 300 seconds (5 min) the player would receive $3000. I then fixed it to work for all players with the following code.
Код:
public paycheck()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GivePlayerMoney(i,3000);
SendClientMessage(i, COLOR_GREEN, "5Mins $3000 Paycheck Recieved");
//SetTimer("paycheck",0,false);
}
}
I have Paycheck as a forward and paycheck as a timer in gamemodeinit. The commented line crashes the server or gives players unlimited amounts of 3000 dollars.
I was wondering how to make this:
Work for ALL Players
Reset Timer so it happens every 5 minutes.
Thanks for your time,
Regards,
Liam
Re: Help with Paycheck Timer and GivePlayerMoney -
Tee - 30.04.2011
pawn Код:
SetTimer("paycheck",0,false);
That above sets the timer for 0 ms (miliseconds) and does not loop it (Timer never called). That would defiantly crash the server. If you want the timer to loop (Give player $3000 ever 5 mins) Just set the timer on OnGameModeInit and change the false to true (true - repeating the timer | false - the timer will be called once) And don't use a timer in the paycheck funtion.
https://sampwiki.blast.hk/wiki/SetTimer