Код:
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/kick", true) == 0)
{
new reason[256];
if (PlayerInfo[playerid][pAdminLevel] >= 1 || IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /kick [playerid] [reason]");
SendClientMessage(playerid, ORANGE, "FUNCTION: Will kick the specified player. **PLEASE ENTER THE ID ONLY!**");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
while ((idx < length) && ((idx - offset) < (sizeof(reason) - 1)))
{
reason[idx - offset] = cmdtext[idx];
idx++;
}
reason[idx - offset] = EOS;
if(!strlen(reason))
{
SendClientMessage(playerid, ORANGE, "USAGE: /kick [playerid] [reason]");
return 1;
}
else
{
printf("[ADMIN NEWS]: Admin %s kicked %s. Reason: %s", sendername, giveplayer, reason);
format(string, sizeof(string), "-| Administrator %s kicked %s. [Reason: %s ]|-", sendername,giveplayer,reason);
SendClientMessageToAll(ADMIN_RED, string);
Kick(giveplayerid);
KickLog(string);
format(string, sizeof(string), "** [%i]%s left the server. ( Kicked ) **",playerid,player);
SendClientMessageToAll(GRAY, string);
}
}
else if(giveplayerid == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%d is not an active player.", giveplayerid);
SendClientMessage(playerid, RED, string);
}
}
else
{
SendClientMessage(playerid, RED, "You are not an admin with the required level.");
}
return 1;
}
if (strcmp(cmd,"/ban", true) == 0) // ban command
{
if (PlayerInfo[playerid][pAdminLevel] >= 3 || IsPlayerAdmin(playerid))
{
new reason[256],str[128],namez[24],name1[24],ip[20];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,ORANGE,"USAGE: /ban [name/ip] [reason]");
SendClientMessage(playerid,ORANGE,"FUNCTION: Will ban the player's name/IP following by a reason. !! DO NOT ENTER THE ID !!");
SendClientMessage(playerid,ORANGE,"HELP: Please enter a name or IP. If you're trying to execute a range ban...");
SendClientMessage(playerid,ORANGE,"HELP: ...then make sure you got a valid player IP( /ip ) and replace some characters by * (NOT ALL)");
return 1;
}
reason = strtok(cmdtext,idx);
if(!strlen(reason))
{
SendClientMessage(playerid,ORANGE,"USAGE: /ban [name/ip] [reason]");
SendClientMessage(playerid,RED,"ERROR: You must enter a reason for the ban!");
return 1;
}
new File:file = fopen("Bans.txt",io_append);
if (file)
{
format(str,128,"%s\r\n",tmp);
fwrite(file,str);
fclose(file);
}
new count = 0;
for(new i=0;i<MAX_PLAYERS;i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i,namez,24);
GetPlayerName(playerid,name1,24);
GetPlayerIp(i,ip,sizeof(ip));
if (strcmp(tmp, namez,true)==0)
{
format(str,128,"|- Administrator %s banned %s. [Reason: %s] -|",name1,namez,reason);
SendClientMessageToAll(ADMIN_RED,str);
Kick(i);
}
else if(strcmp(tmp,ip,true)==0)
{
format(str,128,"|- Administrator %s banned %s. [Reason: %s] -|",name1,namez,reason);
SendClientMessageToAll(ADMIN_RED,str);
format(str,128,"|- Banned IP: [ %s ] -|",ip);
SendClientMessageToAdmins(ADMIN_RED,str,1);
IPLog(namez,ip);
Kick(i);
}
}
else
{
GetPlayerIp(i,ip,sizeof(ip));
if (!IsPlayerConnected(i) && strfind(tmp,".",true) != -1 && count == 0)
{
GetPlayerName(playerid,name1,24);
IPLog("[none]",tmp);
format(str,128,"|- Banned IP: [ %s ] by %s -|",tmp,name1);
SendClientMessageToAdmins(ADMIN_RED,str,1);
}
count++;
}
}
}
return true;
}