Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* O_TextStyles include example filterscript.
- Includes a countdown and an announcement command
- Credits to Seif_ - Idea
- DracoBlue - dcmd
- [XST]O_x(me) - Eveything else
- */
- #include <a_samp>
- #include <o_gametexts>
- #define ANNOUNCE_CMD_STYLE 5 // Style 4,change to whatever you'd wish.
- #define countstring_size 24
- #define COUNT_STYLE 3 // Style 3,for countdown test.
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- #define COLOR_BLUE 0x0259EAFF
- #define COLOR_GREEN1 0x33AA33AA
- new countstring[countstring_size];
- new counttimer;
- new countseconds;
- new bool:IsRunning2;
- new stringC2[64];
- forward CountT();
- stock CountDown(COUNTDOWN_SECONDS)
- {
- format(countstring,sizeof(countstring),"~p~%d",COUNTDOWN_SECONDS);
- GameTextCostumeForAll(countstring,1,COUNT_STYLE);
- counttimer = SetTimer("CountT",1000,true);
- countseconds = COUNTDOWN_SECONDS;
- }
- public CountT()
- {
- countseconds--;
- if(countseconds == 0)
- {
- GameTextCostumeForAll("GO!",1,COUNT_STYLE);
- KillTimer(counttimer);
- IsRunning2 = false;
- return 1;
- }
- new uPd[countstring_size];
- format(uPd,sizeof(uPd),"~y~%d",countseconds);
- GameTextCostumeForAll(uPd,1,COUNT_STYLE);
- return 1;
- }
- public OnPlayerCommandText(playerid,cmdtext[])
- {
- dcmd(countdown, 9, cmdtext);
- dcmd(announcement,12,cmdtext);
- return 0;
- }
- dcmd_countdown(playerid,params[])
- {
- if(IsRunning2 == true) return SendClientMessage(playerid,COLOR_BLUE,"A countdown is already running.");
- if(!params[0]) return SendClientMessage(playerid,COLOR_BLUE,"USAGE: /countdown [seconds]");
- if(!IsNumeric(params)) return SendClientMessage(playerid,COLOR_BLUE,"ERROR: The seconds must be numeric!");
- format(stringC2,sizeof(stringC2),"The player \"%s\" has started a countdown of %d seconds!",PLAYER_NAME(playerid),strval(params));
- SendClientMessageToAll(COLOR_GREEN1,stringC2);
- CountDown(strval(params));
- IsRunning2 = true;
- return 1;
- }
- dcmd_announcement(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BLUE,"You are not an admin!");
- if(!params[0]) return SendClientMessage(playerid,COLOR_BLUE,"USAGE: /announcement [text]");
- GameTextCostumeForAll(params,5,ANNOUNCE_CMD_STYLE);
- return 1;
- }
- stock PLAYER_NAME(playerid) {
- new NA[MAX_PLAYER_NAME]; GetPlayerName(playerid,NA,MAX_PLAYER_NAME); return NA;
- }
- stock IsNumeric(string[]) //No idea by who,but thanks for this!
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment