19.05.2016, 14:47
PHP код:
forward MyFunct(playerid);
new timercreated[MAX_PLAYERS];
new mytimer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
timercreated[playerid] = 1;
mytimer[playerid] = SetTimerEx("MyFunct",120000,0,"i",playerid); // Timer for 2 minutes for every player who connect to the server, without repeating
return true;
}
public OnPlayerDisconnect(playerid)
{
if(timercreated[playerid] == 1)
{
KillTimer(mytimer[playerid]);
timercreated[playerid] = 0;
}
return true;
}
public MyFunct(playerid)
{
if(playerid != INVALID_PLAYER_ID)
{
timercreated[playerid] = 0;
// If time goes and he isn't finished.
}
return true;
}
PHP код:
if(timercreated[playerid] == 1)
{
KillTimer(mytimer[playerid]);
timercreated[playerid] = 0;
}