28.08.2015, 02:41
(
Последний раз редактировалось Logofero; 28.08.2015 в 02:57.
Причина: Add Extended example
)
Lite Example:
or
Extended:
PHP код:
new p_alivetimes[MAX_PLAYERS];
public OnPlayerSpawn(playerid) {
p_alivetimes[playerid] = GetTickCount(); // Reset time
return true;
}
public OnPlayerUpdate(playerid) {
new msg[256];
format(msg, sizeof(msg), "Alive_Time: %d seconds", (GetTickCount()-p_alivetimes[playerid]) / 1000); // Last time from spawn
TextDrawSetString(stats[15], msg);
return true;
}
Extended:
PHP код:
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 msg[256];
format(msg, sizeof(msg), "Alive_Time: %d seconds", (GetTickCount()-p_alivetimes[playerid]) / 1000); // Last time from spawn
TextDrawSetString(stats, msg);
return true;
}