Advertisement
Guest User

Doerfler

a guest
Mar 31st, 2009
1,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define MAX_MESSAGES 50
  4.  
  5. #define BOTTIMER 120000 // <-Set the timer lengh here (60000 = 1 min)
  6.  
  7. #define COLOR_BOT 0xFF0000AA // <- set the color here
  8.  
  9. new botname[16] = "BotName"; //<- set the name here
  10. new RandomMessages = 1; // 1 = on; 0 = off ( 0 = only SendBotMessage() without Randommessages )
  11. new max_msg;
  12. new BotMessages[MAX_MESSAGES][128];
  13.  
  14. public OnFilterScriptInit()
  15. {
  16. if(RandomMessages == 1)
  17. {
  18. SetTimer("SendRandomMessage",BOTTIMER,1);
  19. }
  20. //Examples
  21. AddRandomMessage("Cheating = Ban");
  22. AddRandomMessage("Hello, i'm a ChatBot");
  23. return 1;
  24. }
  25.  
  26. public OnPlayerConnect(playerid)
  27. {
  28. //Example
  29. SendBotMessage("Welcome to xyz Server. Read the /rules");
  30. return 1;
  31. }
  32.  
  33. forward SendRandomMessage();
  34. public SendRandomMessage()
  35. {
  36. for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
  37. {
  38. if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
  39. {
  40. new name[20];
  41. format(name,sizeof(name),"%s",PlayerName(playerid));
  42. new ColorSave = GetPlayerColor(playerid);
  43. SetPlayerColor(playerid,COLOR_BOT);
  44. SetPlayerName(playerid,botname);
  45. SendPlayerMessageToAll(playerid,BotMessages[random(max_msg)]);
  46. SetPlayerColor(playerid,ColorSave);
  47. SetPlayerName(playerid,name);
  48. return 1;
  49. }
  50. }
  51. return 1;
  52. }
  53.  
  54. forward SendBotMessage(msg[]);
  55. public SendBotMessage(msg[])
  56. {
  57. for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
  58. {
  59. if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
  60. {
  61. new name[20];
  62. format(name,sizeof(name),"%s",PlayerName(playerid));
  63. new ColorSave = GetPlayerColor(playerid);
  64. SetPlayerColor(playerid,COLOR_BOT);
  65. SetPlayerName(playerid,botname);
  66. SendPlayerMessageToAll(playerid,msg);
  67. SetPlayerColor(playerid,ColorSave);
  68. SetPlayerName(playerid,name);
  69. return 1;
  70. }
  71. }
  72. return 1;
  73. }
  74.  
  75. stock AddRandomMessage(msg[])
  76. {
  77. format(BotMessages[max_msg],128,"%s",msg);
  78. max_msg++;
  79. return 1;
  80. }
  81.  
  82. stock PlayerName(playerid)
  83. {
  84. new name2[MAX_PLAYER_NAME];
  85. GetPlayerName(playerid, name2, MAX_PLAYER_NAME);
  86. return name2;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement