Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
new Text:time;
#endif
new gametime;
public OnGameModeInit()
{
time = TextDrawCreate(605.0,25.0,"00:00");
TextDrawUseBox(time, 0);
TextDrawFont(time, 3);
TextDrawSetShadow(time,0); // no shadow
TextDrawSetOutline(time,2); // thickness 1
TextDrawBackgroundColor(time,0x000000FF);
TextDrawColor(time,0xFFA500FF);
TextDrawAlignment(time,3);
TextDrawLetterSize(time,0.5,1.5);
KillTimer(gametime);
gametime = SetTimer("IncreaseTime", 1000, true);
return 1;
}
public OnGameModeExit()
{
return 1;
}
forward IncreaseTime(playerid);
public OnPlayerConnect(playerid)
{
new h, m;
SetToNull(playerid);
GetPlayerTimeEx(playerid, h, m);
TextDrawShowForPlayer(playerid, time);
//TextDrawShowForAll(time);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
//SetToNull(playerid);
KillTimer(gametime);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
//SetToNull(playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/gettime", cmdtext, true, 8) == 0)
{
new h, m;
GetPlayerTimeEx(playerid, h, m);
new string[20];
format(string, sizeof(string), "%d:%d", h, m);
SendClientMessage(playerid, 0x999999AA, string);
return 1;
}
return 0;
}
public IncreaseTime(playerid)
{
new h, m;
new string[20];
GetPlayerTimeEx(playerid, h, m);
TextDrawShowForPlayer(playerid, time);
m++;
if(m == 60)
{
h++;
m = 0;
}
if(h == 24)
{
h = 0;
}
SetPlayerTimeEx(playerid, h, m);
if(m >= 0&&m < 9)
{
format(string, sizeof(string), "%d:0%d", h, m);
TextDrawSetString(time,string);
return 1;
}
if(m == 9)
{
format(string, sizeof(string), "%d:0%d", h, m);
TextDrawSetString(time,string);
return 1;
}
if(h == 0)
{
SetWorldTime(0);
return 1;
}
if(h == 1)
{
SetWorldTime(1);
return 1;
}
if(h == 2)
{
SetWorldTime(2);
return 1;
}
if(h == 3)
{
SetWorldTime(3);
return 1;
}
if(h == 4)
{
SetWorldTime(4);
return 1;
}
if(h == 5)
{
SetWorldTime(5);
return 1;
}
if(h == 6)
{
SetWorldTime(6);
return 1;
}
if(h == 7)
{
SetWorldTime(7);
return 1;
}
if(h == 8)
{
SetWorldTime(8);
return 1;
}
if(h == 9)
{
SetWorldTime(9);
return 1;
}
if(h == 10)
{
SetWorldTime(10);
return 1;
}
if(h == 11)
{
SetWorldTime(11);
return 1;
}
if(h == 12)
{
SetWorldTime(12);
return 1;
}
if(h == 13)
{
SetWorldTime(13);
return 1;
}
if(h == 14)
{
SetWorldTime(14);
return 1;
}
if(h == 15)
{
SetWorldTime(15);
return 1;
}
if(h == 16)
{
SetWorldTime(16);
return 1;
}
if(h == 17)
{
SetWorldTime(17);
return 1;
}
if(h == 18)
{
SetWorldTime(18);
return 1;
}
if(h == 19)
{
SetWorldTime(19);
return 1;
}
if(h == 20)
{
SetWorldTime(20);
return 1;
}
if(h == 21)
{
SetWorldTime(21);
return 1;
}
if(h == 22)
{
SetWorldTime(22);
return 1;
}
if(h == 23)
{
SetWorldTime(23);
return 1;
}
if(m >= 10&&m < 60)
format(string, sizeof(string), "%d:%d", h, m);
TextDrawSetString(time,string);
return 1;
}
stock SetToNull(playerid)
{
SetPlayerTimeEx(playerid, 0, 0);
return 1;
}
stock SetPlayerTimeEx(playerid, hour, minute)
{
SetPVarInt(playerid, "hours", hour);
SetPVarInt(playerid, "minutes", minute);
return 1;
}
stock GetPlayerTimeEx(playerid, &hour, &minute)
{
hour = GetPVarInt(playerid, "hours");
minute = GetPVarInt(playerid, "minutes");
return 1;
}