26.10.2013, 06:15
@Rajat_Pawar - Nice try but I don't think that code would be very nice
@rickisme
You serious ? lol
Here is how I would do it.
@rickisme
pawn Код:
foreach(Player, i)
{
if(IsPlayerLogged(i))
{
Here is how I would do it.
pawn Код:
#include <timerfix> // https://sampforum.blast.hk/showthread.php?tid=289675
#include <YSI\y_hooks>
static PayDayTime[MAX_PLAYERS];
// Called when it's a players payday
forward OnPlayerPayDay(playerid);
// Start payday update
hook OnGameModeInit()
{
SetTimer("PayDayUpdate", 60000, true);
return 1;
}
// Reset players payday time when they connect
hook OnPlayerConnect(playerid)
{
PayDayTime[playerid] = gettime();
return 1;
}
// Check for paydays once a minute is good
forward PayDayUpdate();
public PayDayUpdate()
{
foreach(new i : Player)
{
// It's payday!
if(gettime() - PayDayTime[i] >= 3600)
{
PayDayTime[i] = gettime();
CallLocalFunction("OnPlayerPayDay", "i", i);
}
}
return 1;
}
// Set the players payday time (Called from inside gamemode/other includes)
forward SetPayDayTime(playerid);
public SetPayDayTime(playerid) { PayDayTime[playerid] = gettime(); }
// Get the players payday time (Called from inside gamemode/other includes)
forward GetPayDayTime(playerid);
public GetPayDayTime(playerid) { return PayDayTime[playerid]; }
// Used when a player logs in we can restore their payday time
forward UpdatePayDayTime(playerid, seconds);
public UpdatePayDayTime(playerid, seconds) { PayDayTime[playerid] = gettime() - seconds; }