Money Timer - 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: Money Timer (
/showthread.php?tid=135998)
Money Timer -
Sajtos - 22.03.2010
Hi all!
I have a problem. i cant do money timer.
every 1min give player money $25000.
Re: Money Timer -
MrLeNy - 22.03.2010
Код:
SetTimer("GiveCash", 60000, true);
forward GiveCash();
public GiveCash()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, 25000);
}
return 1;
}
Re: Money Timer -
MaykoX - 22.03.2010
*Removed xD*
Re: Money Timer -
Correlli - 22.03.2010
Quote:
Originally Posted by † мąүқоҳ™
pawn Код:
//ontop forward Money(playerid); //ongamemodeint SetTimer("Money",30000,1); //on bottom public Money(playerid) { GivePlayerMoney(playerid, 25000); return 1; }
|
Your code won't work.
pawn Код:
/* under OnGameModeInit/OnFilterScriptInit (depends where do you want to use it) */
SetTimer("myTimer", 60000, true);
pawn Код:
public myTimer()
{
for(new u = 0; u < MAX_PLAYERS; u++) GivePlayerMoney(u, 25000);
return true;
}
Re: Money Timer -
Sajtos - 23.03.2010
Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by † мąүқоҳ™
pawn Код:
//ontop forward Money(playerid); //ongamemodeint SetTimer("Money",30000,1); //on bottom public Money(playerid) { GivePlayerMoney(playerid, 25000); return 1; }
|
Your code won't work.
pawn Код:
/* under OnGameModeInit/OnFilterScriptInit (depends where do you want to use it) */ SetTimer("myTimer", 60000, true);
pawn Код:
public myTimer() { for(new u = 0; u < MAX_PLAYERS; u++) GivePlayerMoney(u, 25000); return true; }
|
thankyou
Re: Money Timer -
Joe_ - 23.03.2010
Try using
Код:
for(new a, b = GetMaxPlayers(); a < b; a++)
Instead of
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
The top one is faster and eats less resources.
MAX_PLAYERS has a static value of 500.
GetMaxPlayers(); has a dynamic value of the server max players (set in your server.cfg).
So it's a waste looping through 500 people if there is only 10 online.
You can also try using IsPlayerConnected, but I think the script would have to go through each player and check if their connected, which would be slow.
Re: Money Timer -
ColdXX - 23.03.2010
Is it possible to set a SendClientMesage when receiving the money?
Re: Money Timer -
Joe_ - 23.03.2010
Yes..
Код:
SendClientMessage(playerid, color, "Text");
Re: Money Timer -
ColdXX - 23.03.2010
i tried to put it here
pawn Код:
public myTimer()
{
for(new u = 0; u < MAX_PLAYERS; u++) GivePlayerMoney(u, 10000);
SendClientMessage(playerid,COLOR_BLUE,"You have received....");
return 1;
}
but it said undefined symbol"playerid"...where should i put it?
Re: Money Timer -
Joe_ - 23.03.2010
Quote:
Originally Posted by ColdXX
i tried to put it here
pawn Код:
public myTimer() { for(new u = 0; u < MAX_PLAYERS; u++) GivePlayerMoney(u, 10000); SendClientMessage(playerid,COLOR_BLUE,"You have received...."); return 1; }
but it said undefined symbol"playerid"...where should i put it?
|
There's a loop going through all players there... the varible is U.
pawn Код:
public myTimer()
{
for(new u = 0; u < MAX_PLAYERS; u++) GivePlayerMoney(u, 10000);
SendClientMessage(u,COLOR_BLUE,"You have received....");
}
return 1;