pawn Код:
if(strcmp(cmd,"/irc",true)==0)
{
if(IsPlayerConnected(playerid))
{
new x_nr[256];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password]) (/irc Leave) (/irc Admins)");
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
return 1;
}
if(strcmp(x_nr,"join",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
return 1;
}
new channel = strval(tmp);
if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, " Channel Number can't be below 1 or above the amount !"); return 1; }
channel -= 1;
if(IRCInfo[channel][iLock] == 0)
{
if(IRCInfo[channel][iNeedPass] == 0)
{
JoinChannelNr(playerid, channel);
}
else
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
return 1;
}
JoinChannel(playerid,channel,tmp);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That Channel is Locked, please choose a different one !");
return 1;
}
}
else if(strcmp(x_nr,"status",true) == 0)
{
for(new i = 0; i < sizeof(IRCInfo); i++)
{
format(string, sizeof(string), "Channel %d: %d Players Connected.",i + 1, IRCInfo[i][iPlayers]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}
else if(strcmp(x_nr,"password",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
return 1;
}
new channel = strval(tmp);
if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, " Channel Number can't be below 1 or above the amount !"); return 1; }
channel -= 1;
new wstring[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s", sendername);
strmid(wstring, string, 0, strlen(string), 255);
if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
return 1;
}
strmid(IRCInfo[channel][iPassword], tmp, 0, strlen(tmp), 255);
format(string, sizeof(string), "You've changed the IRC Channel's Password to: %s.",IRCInfo[channel][iPassword]);
SendClientMessage(playerid, COLOR_YELLOW, string);
SaveIRC();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not the Admin of that Channel !");
return 1;
}
}
else if(strcmp(x_nr,"needpass",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc needpass [channelnr]");
return 1;
}
new channel = strval(tmp);
if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, " Channel Number can't be below 1 or above the amount !"); return 1; }
channel -= 1;
new wstring[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s", sendername);
strmid(wstring, string, 0, strlen(string), 255);
if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
{
if(IRCInfo[channel][iNeedPass] != 0)
{
IRCInfo[channel][iNeedPass] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "Players won't have to fill in a password in order to join the IRC Channel now.");
}
else
{
IRCInfo[channel][iNeedPass] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "Players must fill in a password in order to join the IRC Channel now.");
}
SaveIRC();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not the Admin of that Channel !");
return 1;
}
}
else if(strcmp(x_nr,"lock",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc lock [channelnr]");
return 1;
}
new channel = strval(tmp);
if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, " Channel Number can't be below 1 or above the amount !"); return 1; }
channel -= 1;
new wstring[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s", sendername);
strmid(wstring, string, 0, strlen(string), 255);
if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
{
if(IRCInfo[channel][iLock] != 0)
{
IRCInfo[channel][iLock] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You've unlocked the IRC Channel.");
}
else
{
IRCInfo[channel][iLock] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "You've locked the IRC Channel.");
}
SaveIRC();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not the Admin of that Channel !");
return 1;
}
}
else if(strcmp(x_nr,"lock",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc lock [channelnr]");
}
new channel = strval(tmp);
if(channel < 1 || channel > SCRIPT_MAXIRC) SendClientMessage(playerid, COLOR_GREY, " Channel Number can't be below 1 or above the amount !");
channel -= 1;
new wstring[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s", sendername);
strmid(wstring, string, 0, strlen(string), 255);
if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
{
if(IRCInfo[channel][iLock] != 0)
{
IRCInfo[channel][iLock] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You've unlocked the IRC Channel.");
}
else
{
IRCInfo[channel][iLock] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "You've locked the IRC Channel.");
SaveIRC();
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not the Admin of that Channel !");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not the admin of that Channel !");
return 1;
}
else if(strcmp(x_nr,"leave",true) == 0)
{
if(PlayersChannel[playerid] < 999)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s has left the Channel.", sendername);
SendIRCMessage(PlayersChannel[playerid], COLOR_GREEN, string);
IRCInfo[PlayersChannel[playerid]][iPlayers] -= 1;
PlayersChannel[playerid] = 999;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in an IRC Channel !");
return 1;
}
}
else if(strcmp(x_nr,"admins",true) == 0)
{
for(new i = 0; i < sizeof(IRCInfo); i++)
{
format(string, sizeof(string), "Channel %d: %s.", i + 1, IRCInfo[i][iAdmin]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}
else if(strcmp(x_nr,"kick",true) == 0)
{
if(PlayersChannel[playerid] == 999)
{
SendClientMessage(playerid, COLOR_GREY, " You are not in an IRC Channel !");
return 1;
}
new wstring[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s", sendername);
strmid(wstring, string, 0, strlen(string), 255);
if(strcmp(IRCInfo[PlayersChannel[playerid]][iAdmin],wstring, true ) == 0 )
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc kick [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(PlayersChannel[giveplayerid] == PlayersChannel[playerid])
{
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "* You've kicked %s out of your IRC Channel.",giveplayer);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "* You've been kicked out of the IRC Channel by Channel Admin: %s.",sendername);
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
format(string, sizeof(string), "* %s has left the Channel (Kicked).", sendername);
SendIRCMessage(PlayersChannel[playerid], COLOR_GREEN, string);
IRCInfo[PlayersChannel[giveplayerid]][iPlayers] -= 1;
PlayersChannel[giveplayerid] = 999;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is not in your IRC Channel !");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not the Admin of the Channel !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Invalid IRC Channel Number ! ");
return 1;
}
}
}
return 1;
}