Autocheck if a person was banned previously
#7

Quote:
Originally Posted by dusk
Посмотреть сообщение
These two functions are for you to use when you want to ban someone.

It may be a command:
pawn Код:
CMD:banplayername(playerid, params[])
{
    if(isnull(params))
       SendClientMessage(playerid, -1, "Usage /banplayername [ name ]");
   // You should also validate if the user used a valid player name.
    BanName(params);
    return 1;
}
Also, I added a useless parameter to those functions, so change them to:

pawn Код:
BanIp(name[])
{
    new File:file = fopen("bans_name.txt", io_append); // io_append will create the file it does not exist
    if(file)
    {
        fwrite(file, name);
        fwrite(file, "\r\n"); // a new line
    }
    fclose(file);
}

BanName(ip[])
{
    new File:file = fopen("bans_ip.txt", io_append); // io_append will create the file it does not exist
    if(file)
    {
        fwrite(file, ip);
        fwrite(file, "\r\n"); // a new line
    }
    fclose(file);
}

Код:
CMD:kick(playerid, params[])
{
	new id, reason[128];
	if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_WHITE, "You need to be a admin to use that command!");
	else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_WHITE, "Usage: /kick [id/name][reason]");
	else if(id==playerid)SendClientMessage(playerid,COLOR_WHITE,"Error: You can not kick yourself!");
	else if(IsPlayerAdmin(id))SendClientMessage(playerid,COLOR_WHITE,"Error: You can not kick another admin!");
 	else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_WHITE,"Error: Player is not connected!");
 	else {
 	    new Name[MAX_PLAYER_NAME], KickMessage[128];
		new Name2[MAX_PLAYER_NAME];
		GetPlayerName(playerid, Name, sizeof(Name));
		GetPlayerName(id, Name2, sizeof(Name2));
		format(KickMessage, sizeof(KickMessage), "%s(%d) has kicked player %s(%d). Reason: %s", Name, playerid, Name2, id);
		SendClientMessageToAll(COLOR_WHITE, KickMessage);
		Kick(id);
	}
	return 1;
}

CMD:ban(playerid, params[])
{
	new id, reason[128];
	if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_WHITE, "You need to be a admin to use that command!");
	else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban [id/name][reason]");
	else if(id==playerid)SendClientMessage(playerid,COLOR_WHITE,"Error: You can not ban yourself!");
	else if(IsPlayerAdmin(id))SendClientMessage(playerid,COLOR_WHITE,"Error: You can not ban another admin!");
 	else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_WHITE,"Error: Player is not connected!");
 	else {
 	    new Name3[MAX_PLAYER_NAME], BanMessage[128];
		new Name4[MAX_PLAYER_NAME];
		GetPlayerName(playerid, Name3, sizeof(Name3));
		GetPlayerName(id, Name4, sizeof(Name4));
		format(BanMessage, sizeof(BanMessage), "%s(%d) has Banned player %s(%d). Reason: %s", Name3, playerid, Name4, id);
		SendClientMessageToAll(COLOR_WHITE, BanMessage);
		Ban(id);
	}
	return 1;
}
I already have my ban and kick code, how to implement yours to mine?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)