Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define MAX_MESSAGES 50
- #define BOTTIMER 120000 // <-Set the timer lengh here (60000 = 1 min)
- #define COLOR_BOT 0xFF0000AA // <- set the color here
- new botname[16] = "BotName"; //<- set the name here
- new RandomMessages = 1; // 1 = on; 0 = off ( 0 = only SendBotMessage() without Randommessages )
- new max_msg;
- new BotMessages[MAX_MESSAGES][128];
- public OnFilterScriptInit()
- {
- if(RandomMessages == 1)
- {
- SetTimer("SendRandomMessage",BOTTIMER,1);
- }
- //Examples
- AddRandomMessage("Cheating = Ban");
- AddRandomMessage("Hello, i'm a ChatBot");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- //Example
- SendBotMessage("Welcome to xyz Server. Read the /rules");
- return 1;
- }
- forward SendRandomMessage();
- public SendRandomMessage()
- {
- for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
- {
- if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
- {
- new name[20];
- format(name,sizeof(name),"%s",PlayerName(playerid));
- new ColorSave = GetPlayerColor(playerid);
- SetPlayerColor(playerid,COLOR_BOT);
- SetPlayerName(playerid,botname);
- SendPlayerMessageToAll(playerid,BotMessages[random(max_msg)]);
- SetPlayerColor(playerid,ColorSave);
- SetPlayerName(playerid,name);
- return 1;
- }
- }
- return 1;
- }
- forward SendBotMessage(msg[]);
- public SendBotMessage(msg[])
- {
- for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
- {
- if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
- {
- new name[20];
- format(name,sizeof(name),"%s",PlayerName(playerid));
- new ColorSave = GetPlayerColor(playerid);
- SetPlayerColor(playerid,COLOR_BOT);
- SetPlayerName(playerid,botname);
- SendPlayerMessageToAll(playerid,msg);
- SetPlayerColor(playerid,ColorSave);
- SetPlayerName(playerid,name);
- return 1;
- }
- }
- return 1;
- }
- stock AddRandomMessage(msg[])
- {
- format(BotMessages[max_msg],128,"%s",msg);
- max_msg++;
- return 1;
- }
- stock PlayerName(playerid)
- {
- new name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name2, MAX_PLAYER_NAME);
- return name2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement