Money Timer
#1

Hi all!

I have a problem. i cant do money timer.

every 1min give player money $25000.
Reply
#2

Код:
SetTimer("GiveCash", 60000, true);

forward GiveCash();
public GiveCash()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, 25000);
}
return 1;
}
Reply
#3

*Removed xD*
Reply
#4

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 Код:
forward myTimer();
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;
}
Reply
#5

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 Код:
forward myTimer();
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
Reply
#6

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

Is it possible to set a SendClientMesage when receiving the money?
Reply
#8

Yes..

Код:
SendClientMessage(playerid, color, "Text");


Reply
#9

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?
Reply
#10

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;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)