03.09.2011, 14:55
I have a big issue that started occuring randomly after updating to the newest version of the plugin.
Every now and then, this randomly gets spammed in my owner echo channel:
But according to Popz, there are no more than five bots connecting. So this means that IRC_OnDisconnect returns the wrong botids.
Code:
Why is this happening? This code has been the same for over a year now and this never happend before the latest update.
Every now and then, this randomly gets spammed in my owner echo channel:
Quote:
[16:49] <12~YosBot3> 3Bot ID 165 Attempting To Reconnect... [16:49] <12~YosBot1> 3Bot ID 234 Attempting To Reconnect... [16:49] <12~YosBot2> 3Bot ID 322 Disconnected. [16:49] <12~YosBot3> 3Bot ID 145 Disconnected. [16:49] <12~YosBot1> 3Bot ID 378 Disconnected. [16:49] <12~YosBot2> 3Bot ID 632 Attempting To Reconnect... [16:49] <12~YosBot3> 3Bot ID 102 Attempting To Reconnect... [16:49] <12~YosBot1> 3Bot ID 319 Attempting To Reconnect... [16:49] <12~YosBot2> 3Bot ID 368 Disconnected. [16:49] <12~YosBot3> 3Bot ID 48 Disconnected. [16:49] <12~YosBot1> 3Bot ID 109 Disconnected. [16:49] <12~YosBot2> 3Bot ID 185 Attempting To Reconnect... [16:49] <12~YosBot3> 3Bot ID 356 Attempting To Reconnect... [16:49] <12~YosBot1> 3Bot ID 28 Attempting To Reconnect... [16:49] <12~YosBot2> 3Bot ID 478 Disconnected. |
Code:
pawn Код:
public OnGameModeInit()
{
if(IsCorrectServer())
{
SetTimerEx("IRC_ConnectDelay", 5000, 0, "d", 1);
SetTimerEx("IRC_ConnectDelay", 7000, 0, "d", 2);
SetTimerEx("IRC_ConnectDelay", 9000, 0, "d", 3);
SetTimerEx("IRC_ConnectDelay", 11000, 0, "d", 4);
SetTimerEx("IRC_ConnectDelay", 13000, 0, "d", 5);
gGroupID = IRC_CreateGroup();
}
}
pawn Код:
stock IsCorrectServer()
{
if(!strcmp(ReturnServerStringVar("bind"), SERVER_IP, false) && GetServerVarAsInt("port") == SERVER_PORT) return 1;
else return 0;
}
pawn Код:
function IRC_ConnectDelay(tempid)
{
if(IsCorrectServer())
{
switch(tempid)
{
case 1: gBotID[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
case 2: gBotID[1] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_2_NICKNAME, BOT_2_REALNAME, BOT_2_USERNAME);
case 3: gBotID[2] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_3_NICKNAME, BOT_3_REALNAME, BOT_3_USERNAME);
case 4: gBotID[3] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_4_NICKNAME, BOT_4_REALNAME, BOT_4_USERNAME);
case 5: gBotID[4] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_5_NICKNAME, BOT_5_REALNAME, BOT_5_USERNAME);
}
}
return 1;
}
pawn Код:
public IRC_OnConnect(botid)
{
if(IsCorrectServer())
{
new string[150];
format(string, sizeof(string), "Bot ID %d Connected.", botid);
SendOwnerMessageToIRC(string);
format(string, sizeof(string), "IDENTIFY %s", BOT_PASSWORD);
IRC_SendRaw(botid, string);
format(string, sizeof(string), "Bot ID %d Identified.", botid);
SendOwnerMessageToIRC(string);
IRC_JoinChannel(botid, IRC_CHANNEL);
IRC_JoinChannel(botid, IRC_NORMALCHANNEL);
IRC_JoinChannel(botid, IRC_NORMALADMINCHANNEL);
IRC_JoinChannel(botid, IRC_NORMALOWNERCHANNEL);
IRC_JoinChannel(botid, IRC_ADMINCHANNEL);
IRC_JoinChannel(botid, IRC_LOGCHANNEL);
IRC_JoinChannel(botid, IRC_COMMANDSCHANNEL);
IRC_JoinChannel(botid, IRC_OWNERCHANNEL);
IRC_JoinChannel(botid, "#yoshi");
IRC_AddToGroup(gGroupID, botid);
if(botid == gBotID[0]) format(BotName[0], 10, BOT_1_NICKNAME);
if(botid == gBotID[1]) format(BotName[1], 10, BOT_2_NICKNAME);
if(botid == gBotID[2]) format(BotName[2], 10, BOT_3_NICKNAME);
if(botid == gBotID[3]) format(BotName[3], 10, BOT_4_NICKNAME);
if(botid == gBotID[4]) format(BotName[4], 10, BOT_5_NICKNAME);
}
return 1;
}
pawn Код:
public IRC_OnDisconnect(botid) // Code that causes the spam messages.
{
if(IsCorrectServer())
{
new string[150];
format(string, sizeof(string), "Bot ID %d Disconnected.", botid);
SendOwnerMessageToIRC(string);
if(botid == gBotID[0])
{
gBotID[0] = 0;
SetTimerEx("IRC_ConnectDelay", 8000, 0, "d", 1);
}
else if(botid == gBotID[1])
{
gBotID[1] = 0;
SetTimerEx("IRC_ConnectDelay", 10000, 0, "d", 2);
}
else if(botid == gBotID[2])
{
gBotID[2] = 0;
SetTimerEx("IRC_ConnectDelay", 15000, 0, "d", 3);
}
else if(botid == gBotID[3])
{
gBotID[3] = 0;
SetTimerEx("IRC_ConnectDelay", 20000, 0, "d", 4);
}
else if(botid == gBotID[4])
{
gBotID[4] = 0;
SetTimerEx("IRC_ConnectDelay", 25000, 0, "d", 5);
}
format(string, sizeof(string), "Bot ID %d Attempting To Reconnect...", botid);
SendOwnerMessageToIRC(string);
IRC_RemoveFromGroup(gGroupID, botid);
}
return 1;
}