28.08.2015, 03:34
Okey
Add
PHP код:
/*
* native ConvertSeconds(time_seconds, &hours, &minutes, &seconds);
*/
stock ConvertSeconds(time_seconds, &hours, &minutes, &seconds) {
new tmp;
tmp = time_seconds % 86400;
hours = tmp / 3600;
tmp = time_seconds % 3600;
minutes = tmp / 60;
seconds = tmp % 60;
// printf("ConvertSeconds %d TO %02d:%02d:%02d", time_seconds, hours, minutes, seconds);
}
new p_alivetimes[MAX_PLAYERS];
new Text:stats;
public OnGameModeInit() {
// Other options...
// Create TextDraws
stats = TextDrawCreate(517.800231, 92.759986, "Alive_Time:000:00:00");
TextDrawLetterSize(stats, 0.227999, 1.170666);
TextDrawAlignment(stats, 1);
TextDrawColor(stats, -1);
TextDrawSetShadow(stats, 0);
TextDrawSetOutline(stats, 0);
TextDrawBackgroundColor(stats, 255);
TextDrawFont(stats, 1);
TextDrawSetProportional(stats, 1);
TextDrawSetShadow(stats, 0);
return true;
}
public OnGameModeExit() {
TextDrawHideForAll(stats);
TextDrawDestroy(stats);
return true;
}
public OnPlayerDisconnect(playerid, reason) {
TextDrawHideForPlayer(playerid, stats);
return true;
}
public OnPlayerSpawn(playerid) {
TextDrawShowForPlayer(playerid, stats);
p_alivetimes[playerid] = GetTickCount(); // Reset time
return true;
}
public OnPlayerUpdate(playerid) {
new
hours,
minutes,
seconds,
msg[256];
ConvertSeconds(((GetTickCount()-p_alivetimes[playerid]) / 1000), hours, minutes, seconds);
format(msg, sizeof(msg), "Alive_Time: %02d:%02d:%02d", hours, minutes, seconds); // Last time from spawn
TextDrawSetString(stats, msg);
return true;
}
PHP код:
stock ConvertSeconds(time_seconds, &hours, &minutes, &seconds) {
new tmp;
tmp = time_seconds % 86400;
hours = time_seconds / 3600; // Remove restriction 24 hours
tmp = time_seconds % 3600;
minutes = tmp / 60;
seconds = tmp % 60;
printf("ConvertSeconds %d TO %02d:%02d:%02d", time_seconds, hours, minutes, seconds);
}