Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*--------------------------------------------------------------------
- -----------------------[ Relogio by Dr_Pawn ]-----------------------
- ------------------------------------------------------------------*/
- /*------------------------------------------------------------ INCLIDE/DEFINES*/
- #include a_samp
- #define RELOGIO_TAMANHO_PEQUENO 0
- #define RELOGIO_TAMANHO_MEDIO 1
- #define RELOGIO_TAMANHO_GRANDE 2
- /*-------------------------------------------------------------------- FORWARD*/
- forward LigarRelogio(Tamanho, bool:Real);
- forward DesligarRelogio();
- forward HorasRelogio(bool:Real);
- /*------------------------------------------------------------------------ NEW*/
- new Text:Relogio,
- RelogioFunc[3],
- bool:RelogioLigado,
- bool:RelogioReal;
- /*--------------------------------------------------------------- FILTERSCRIPT*/
- public LigarRelogio(Tamanho, bool:Real)
- {
- if(Tamanho == RELOGIO_TAMANHO_PEQUENO)
- {
- Relogio = TextDrawCreate(562.500000, 5.000000, "23:59");
- TextDrawLetterSize(Relogio, 0.250000, 1.700000);
- }
- else if(Tamanho == RELOGIO_TAMANHO_MEDIO)
- {
- Relogio = TextDrawCreate(556.500000, 5.000000, "23:59");
- TextDrawLetterSize(Relogio, 0.299999, 2.000000);
- }
- else if(Tamanho == RELOGIO_TAMANHO_GRANDE)
- {
- Relogio = TextDrawCreate(548.500000, 1.000000, "23:59");
- TextDrawLetterSize(Relogio, 0.399999, 2.999999);
- }
- else
- {
- printf("Nao foi possivel criar o relogio com o tamanho %d.", Tamanho);
- return 1;
- }
- TextDrawBackgroundColor(Relogio, 255);
- TextDrawFont(Relogio, 2);
- TextDrawColor(Relogio, -1);
- TextDrawSetOutline(Relogio, 1);
- TextDrawSetProportional(Relogio, 1);
- if(Real)
- {
- new segundos;
- gettime(RelogioFunc[0], RelogioFunc[1], segundos);
- }
- else
- {
- RelogioFunc[0] = 12;
- RelogioFunc[1] = -1;
- }
- HorasRelogio(Real);
- RelogioFunc[2] = SetTimerEx("HorasRelogio", 1000, true, "i", Real);
- RelogioReal = Real;
- return 1;
- }
- public DesligarRelogio()
- {
- TextDrawHideForAll(Relogio);
- TextDrawDestroy(Relogio);
- KillTimer(RelogioFunc[2]);
- RelogioFunc[0] = 23;
- RelogioFunc[1] = 59;
- return 1;
- }
- public HorasRelogio(bool:Real)
- {
- new string[12];
- if(Real)
- {
- new segundos;
- gettime(RelogioFunc[0], RelogioFunc[1], segundos);
- SetWorldTime(RelogioFunc[0]);
- format(string, sizeof(string), "%02d:%02d", RelogioFunc[0], RelogioFunc[1]);
- TextDrawSetString(Relogio, string);
- }
- else
- {
- RelogioFunc[1] ++;
- if(RelogioFunc[1] == 60)
- {
- RelogioFunc[0] ++;
- RelogioFunc[1] = 0;
- }
- if(RelogioFunc[0] == 24)
- {
- RelogioFunc[0] = 0;
- }
- SetWorldTime(RelogioFunc[0]);
- format(string, sizeof(string), "%02d:%02d", RelogioFunc[0], RelogioFunc[1]);
- TextDrawSetString(Relogio, string);
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("---------- ------- --------- ----------");
- print("---------- Relogio Carregado ----------");
- print("---------- ------- --------- ----------");
- return 1;
- }
- public OnFilterScriptExit()
- {
- if(RelogioLigado) DesligarRelogio();
- print("--------- ------- ------------ --------");
- print("--------- Relogio Descarregado --------");
- print("--------- ------- ------------ --------");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- TextDrawShowForPlayer(playerid, Relogio);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- TextDrawHideForPlayer(playerid, Relogio);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], idx, tmp[256], sendername[MAX_PLAYER_NAME], string[256];
- cmd = strtok(cmdtext, idx);
- GetPlayerName(playerid, sendername, sizeof(sendername));
- if(strcmp(cmd, "/ligarrelogio", true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(!RelogioLigado)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "USE: /LigarRelogio [TAMANHO] [HORAS REAIS]");
- return 1;
- }
- new T = strval(tmp);
- if(T < RELOGIO_TAMANHO_PEQUENO || T > RELOGIO_TAMANHO_GRANDE) return SendClientMessage(playerid, 0xAAAAAAAA, "Tamanho Invalido. (De 0 á 2)");
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "USE: /LigarRelogio [TAMANHO] [HORAS REAIS]");
- return 1;
- }
- new bool:Real;
- if(!strcmp("sim", tmp, true)) Real = true;
- else if(!strcmp("nao", tmp, true) || !strcmp("não", tmp, true)) Real = false;
- else return SendClientMessage(playerid, 0xAAAAAAAA, "Horas Reais Invalida. (Use Sim ou Não)");
- LigarRelogio(T, Real);
- TextDrawShowForAll(Relogio);
- format(string, sizeof(string), "[ADMIN] %s ligou o relogio.", sendername);
- SendClientMessageToAll(0xDDDD00AA, string);
- RelogioLigado = true;
- return 1;
- }
- else
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "O Relogio ja esta ligado.");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "Você não é admin.");
- return 1;
- }
- }
- if(strcmp(cmd, "/desligarrelogio", true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(RelogioLigado)
- {
- DesligarRelogio();
- format(string, sizeof(string), "[ADMIN] %s desligou o relogio.", sendername);
- SendClientMessageToAll(0xDDDD00AA, string);
- RelogioLigado = false;
- return 1;
- }
- else
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "O Relogio ja esta desligado.");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "Você não é admin.");
- return 1;
- }
- }
- if(strcmp(cmd, "/setarhora", true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(RelogioLigado)
- {
- if(!RelogioReal) return SendClientMessage(playerid, 0xAAAAAAAA, "Você não pode mudar as horas reais!");
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "USE: /SetarHora [HORA] [MINUTOS]");
- return 1;
- }
- new H = strval(tmp);
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "USE: /SetarHora [HORA] [MINUTOS]");
- return 1;
- }
- new M = strval(tmp);
- if(H < 0 || H > 23 || M < 0 || M > 59)
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "USE: /SetarHora [0-23] [0-59]");
- return 1;
- }
- RelogioFunc[0] = H;
- RelogioFunc[1] = M-1;
- KillTimer(RelogioFunc[2]);
- HorasRelogio(false);
- RelogioFunc[2] = SetTimerEx("HorasRelogio", 1000, true, "i", false);
- format(string, sizeof(string), "[ADMIN] %s setou a hora para %d:%d.", sendername, H, M);
- SendClientMessageToAll(0xDDDD00AA, string);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "O Relogio não esta ligado.");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, 0xAAAAAAAA, "Você não é admin.");
- return 1;
- }
- }
- return 0;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement