27.01.2013, 10:28
Declare two variables for all players like these:
Create a prototype for the timer:
When a player types "/hello":
And let's continue with our callback:
-----------------------------------------------------------------------------------------------------------------------
Now we have to save the time if the player disconnect.
You ought to load the 'hellotime' when the player connect.
I hope I helped you.
Код:
new hellotime[MAX_PLAYERS]; new timerr[MAX_PLAYERS];
Код:
forward HelloPlayer(playerid);
Код:
timerr = SetTimerEx("HelloPlayer", 1000, true, "i", playerid); hellotime[playerid] = 0;
Код:
HelloPlayer(playerid) { hellotime[playerid]++; if(hellotime[playerid] == 60) KillTimer(timerr[playerid]); return 1; }
Now we have to save the time if the player disconnect.
Код:
public OnPlayerDisconnect(playerid, reason) { new timeFile[128], name[24]; GetPlayerName(playerid, 24); format(timeFile, 128, "time_%s", name); if(!fexist(timeFile)) dini_Create(timeFile); KillTimer(timerr[playerid]); dini_IntSet(timeFile, "Time", hellotime[playerid]); return 1; }
Код:
public OnPlayerConnect(playerid) { new timeFile[128], name[24]; GetPlayerName(playerid, 24); format(timeFile, 128, "time_%s", name); if(fexist(timeFile)) { hellotime[playerid] = dini_Int(timeFile, "Time"); timerr[playerid] = SetTimerEx("HelloPlayer", 1000, true, "i", playerid); } return 1; }