Guest User

xD

a guest
Aug 5th, 2010
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.64 KB | None | 0 0
  1. /* O_TextStyles include example filterscript.
  2.  
  3. Includes a countdown and an announcement command
  4. Credits to Seif_ - Idea
  5. DracoBlue - dcmd
  6. [XST]O_x(me) - Eveything else
  7.  
  8. */
  9.  
  10.  
  11. #include <a_samp>
  12. #include <o_gametexts>
  13.  
  14. #define ANNOUNCE_CMD_STYLE 5 // Style 4,change to whatever you'd wish.
  15. #define countstring_size 24
  16. #define COUNT_STYLE 3 // Style 3,for countdown test.
  17.  
  18. #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
  19.  
  20. #define COLOR_BLUE 0x0259EAFF
  21. #define COLOR_GREEN1 0x33AA33AA
  22.  
  23.  
  24. new countstring[countstring_size];
  25. new counttimer;
  26. new countseconds;
  27. new bool:IsRunning2;
  28. new stringC2[64];
  29.  
  30. forward CountT();
  31.  
  32. stock CountDown(COUNTDOWN_SECONDS)
  33. {
  34.     format(countstring,sizeof(countstring),"~p~%d",COUNTDOWN_SECONDS);
  35.     GameTextCostumeForAll(countstring,1,COUNT_STYLE);
  36.     counttimer = SetTimer("CountT",1000,true);
  37.     countseconds = COUNTDOWN_SECONDS;
  38. }
  39.  
  40. public CountT()
  41. {
  42.     countseconds--;
  43.     if(countseconds == 0)
  44.     {
  45.         GameTextCostumeForAll("GO!",1,COUNT_STYLE);
  46.         KillTimer(counttimer);
  47.         IsRunning2 = false;
  48.         return 1;
  49.     }
  50.     new uPd[countstring_size];
  51.     format(uPd,sizeof(uPd),"~y~%d",countseconds);
  52.     GameTextCostumeForAll(uPd,1,COUNT_STYLE);
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerCommandText(playerid,cmdtext[])
  57. {
  58.     dcmd(countdown, 9, cmdtext);
  59.     dcmd(announcement,12,cmdtext);
  60.     return 0;
  61. }
  62.  
  63. dcmd_countdown(playerid,params[])
  64. {
  65.     if(IsRunning2 == true) return SendClientMessage(playerid,COLOR_BLUE,"A countdown is already running.");
  66.     if(!params[0]) return SendClientMessage(playerid,COLOR_BLUE,"USAGE: /countdown [seconds]");
  67.     if(!IsNumeric(params)) return SendClientMessage(playerid,COLOR_BLUE,"ERROR: The seconds must be numeric!");
  68.     format(stringC2,sizeof(stringC2),"The player \"%s\" has started a countdown of %d seconds!",PLAYER_NAME(playerid),strval(params));
  69.     SendClientMessageToAll(COLOR_GREEN1,stringC2);
  70.     CountDown(strval(params));
  71.     IsRunning2 = true;
  72.     return 1;
  73. }
  74.  
  75. dcmd_announcement(playerid,params[])
  76. {
  77.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BLUE,"You are not an admin!");
  78.     if(!params[0]) return SendClientMessage(playerid,COLOR_BLUE,"USAGE: /announcement [text]");
  79.     GameTextCostumeForAll(params,5,ANNOUNCE_CMD_STYLE);
  80.     return 1;
  81. }
  82.    
  83. stock PLAYER_NAME(playerid) {
  84.     new NA[MAX_PLAYER_NAME]; GetPlayerName(playerid,NA,MAX_PLAYER_NAME); return NA;
  85. }
  86.  
  87. stock IsNumeric(string[]) //No idea by who,but thanks for this!
  88. {
  89.     for (new i = 0, j = strlen(string); i < j; i++)
  90.     {
  91.         if (string[i] > '9' || string[i] < '0') return 0;
  92.     }
  93.     return 1;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment