Advertisement
Guest User

Reklama System v0.1 by QWER

a guest
Sep 26th, 2011
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.22 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define SUBOR "Reklamy.txt"
  4. #define TIMER 180
  5. #define SEC(%0) %0*1000
  6. //#define DEBUG
  7. forward SendRandomMessage();
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.     if(!fexist(SUBOR)){
  12.     print( "============= Reklama System v1.0 by QWER =============");
  13.     printf("Súbor \"%s\" sa nenašiel. Server bol vypnutý !",SUBOR);
  14.     SendRconCommand("exit");
  15.     }else{
  16.     print( "============= Reklama System v1.0 by QWER =============");
  17.     print("Súbor sa našiel, všetko OK !");
  18.     }
  19.     SetTimer("SendRandomMessage",SEC(TIMER),true);
  20.     return 1;
  21. }
  22.  
  23. public SendRandomMessage(){
  24. new File:a = fopen(SUBOR,io_read);
  25. new b,str[128];
  26. while(fread(a,str)){
  27. b++;
  28. }
  29. if(b == 0){
  30. print( "============= Reklama System v1.0 by QWER =============");
  31. printf("Súbor \"%s\" je prázdny (Chýbajú tam reklamy). Server bol vypnutý !",SUBOR);
  32. SendRconCommand("exit");
  33. }
  34. new r = random(b)+1;
  35. b = 0;
  36. a = fopen(SUBOR,io_read);
  37. while(fread(a,str)){
  38. if(b == r) {
  39. DelChar(str);
  40. #if defined DEBUG
  41. print(str);
  42. #endif
  43. SendClientMessageToAll(-1,str);
  44. break;
  45. }
  46. b++;
  47. }
  48. fclose(a);
  49. }
  50.  
  51.  
  52.  
  53. stock DelChar(tstring[])
  54. {
  55.     new ln = strlen(tstring);
  56.     if(tstring[ln-2] == '\r')tstring[ln-2] = '\0';
  57.     if(tstring[ln-1] == '\n')tstring[ln-1] = '\0';
  58. }
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement