#include <a_samp> #include <time> forward ClockSync(playerid); new Text:Clock; public OnFilterScriptInit() { Clock = TextDrawCreate(547.000000,24.000000,"00:00"); TextDrawAlignment(Clock,0); TextDrawBackgroundColor(Clock,0x000000ff); TextDrawFont(Clock,3); TextDrawLetterSize(Clock,0.6,1.9); TextDrawColor(Clock,0xffffffff); TextDrawSetOutline(Clock,2); TextDrawSetProportional(Clock,1); TextDrawSetShadow(Clock,1); SetTimer("ClockSync", 1000, 1); } public OnFilterScriptExit() { return 1; } public OnPlayerSpawn(playerid) { TextDrawShowForPlayer(playerid,Clock); return 1; } public OnPlayerConnect(playerid) { return 1; } public ClockSync(playerid) { new string[256]; new hour, minute, second; gettime(hour,minute,second); if(hour < 10 && minute < 10) { format(string, sizeof(string), "0%d:0%d", hour, minute); } else if(hour < 10 && minute > 9) { format(string, sizeof(string), "0%d:%d", hour, minute); } else if(hour > 9 && minute < 10) { format(string, sizeof(string), "%d:0%d", hour, minute); } else { format(string, sizeof(string), "%d:%d", hour, minute); } TextDrawSetString(Text:Clock, string); SetWorldTime(hour); } |
#include <a_samp>
forward ClockSync(playerid);
new Text:Clock;
new chour, cmin;
public OnFilterScriptInit()
{
Clock = TextDrawCreate(547.000000,24.000000,"00:00");
TextDrawAlignment(Clock,0);
TextDrawBackgroundColor(Clock,0x000000ff);
TextDrawFont(Clock,3);
TextDrawLetterSize(Clock,0.6,1.9);
TextDrawColor(Clock,0xffffffff);
TextDrawSetOutline(Clock,2);
TextDrawSetProportional(Clock,1);
TextDrawSetShadow(Clock,1);
SetTimer("ClockSync", 1000, 1);
}
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,Clock);
return 1;
}
public OnPlayerDeath(playerid)
{
TextDrawHideForPlayer(playerid,Clock);
return 1;
}
public ClockSync(playerid)
{
new string[64];
if(cmin == 59)
{
cmin = 0;
if(chour == 23) chour = 0;
else chour++;
}
else cmin++;
for(new i=0; i<GetMaxPlayers(); i++) if(GetPlayerState(i) != PLAYER_STATE_NONE && IsPlayerConnected(i)) SetPlayerTime(i,chour,cmin);
format(string, 64, "%02d:%02d", chour, cmin);
TextDrawSetString(Text:Clock, string);
SetWorldTime(chour);
}