help me with payday on every hour - 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)
+--- Thread: help me with payday on every hour (
/showthread.php?tid=398644)
help me with payday on every hour -
Hugoca - 10.12.2012
Hi.I wanna if player is online to get 1000 money when the time is --:00.Thanks
Re: help me with payday on every hour -
iggy1 - 10.12.2012
https://sampforum.blast.hk/showthread.php?tid=187229
Re: help me with payday on every hour -
LarzI - 10.12.2012
Under OnGameModeInit, start a loop that loops very often. In this example I've used 100ms each interval
pawn Код:
SetTimer( "PayDayTimer", 100, true );
You can then do a time check in the timer-callback, like so:
pawn Код:
forward PayDayTimer();
public PayDayTimer()
{
new
hour,
minute,
second;
gettime( hour, minute, second ); //get the current time
if( minute == 0 ) //if minute == 0 - anything o' clock
{
for( new i = 0; i < MAX_PLAYERS; i++ ) //loop through all possible players
{
if( IsPlayerConnected( i )) //check if the players loop through are connected (no point giving money to players who don't exist)
{
SendClientMessage( i, 0xFFFF00FF, "PAYDAY! + $1000"); //send a message
GivePlayerMoney( i, 1000 ); //give them money
}
}
}
}