Kick / Ban without message for banned / kicked player ?
#1

Here is my code:

pawn Код:
CMD:kick(playerid, params[])
{
    {
        if(PlayerInfo[playerid][pAdmin] >= 3) {
            new PID;
            new reason[64];
            new str[128];
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Adminname, sizeof(Adminname));
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, DEEPPINK, "USAGE: /kick <playerid> <reason>");
            if(!IsPlayerConnected(PID))return SendClientMessage(playerid, DEEPPINK, "Player is not connected!");
            format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
            SendClientMessageToAll(ORANGE, str);
            Kick(PID);
        }
        else
        {
            SendClientMessage(playerid, DEEPPINK, "ERROR: You have to be level 3 to use that command!");
        }
        return 1;
    }
}

CMD:ban(playerid, params[])
{
    {
        if(PlayerInfo[playerid][pAdmin] >= 5) {
            new PID;
            new reason[64];
            new str[128];
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Adminname, sizeof(Adminname));
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, DEEPPINK, "USAGE: /ban <playerid> <reason>");
            if( PlayerInfo[ playerid ][ pAdmin ] < 5 ) return SendClientMessage( playerid, DEEPPINK, "ERROR: You must be level 5 to use this command!" );
            if(!IsPlayerConnected(PID))
            return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
            format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
            SendClientMessageToAll(ORANGE, str);
            Ban(PID);
        }
        else
        {
            SendClientMessage(playerid, ORANGE, "ERROR: You have to be level 5 to use that command!");
        }
        return 1;
    }
}
I also added 2 timers..

pawn Код:
forward KickPublic(playerid);
public KickPublic(playerid) { Kick(playerid); }

stock KickWithMessage(playerid, message[])
{
    SendClientMessage(playerid, RED, "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
    SetTimerEx("KickPublic", 1000, 0, "d", playerid);
}

forward BanPublic(playerid);
public BanPublic(playerid) { Ban(playerid); }

stock BanWithMessage(playerid, message[])
{
    SendClientMessage(playerid, RED, "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
    SetTimerEx("BanPublic", 1000, 0, "d", playerid);
}
What do i do? i have been doing this all day, but dunno how to make player kicked / banned get the message :S
Reply
#2

Change your Kick to BanWithMessage
Reply
#3

Код:
CMD:kick(playerid, params[])
{
    {
        if(PlayerInfo[playerid][pAdmin] >= 3) {
            new PID;
            new reason[64];
            new str[128];
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Adminname, sizeof(Adminname));
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, DEEPPINK, "USAGE: /kick <playerid> <reason>");
            if(!IsPlayerConnected(PID))return SendClientMessage(playerid, DEEPPINK, "Player is not connected!");
            format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
            SendClientMessageToAll(ORANGE, str);
            SetTimerEx( "KickPublic",100, false, "i", PID);
        }
        else
        {
            SendClientMessage(playerid, DEEPPINK, "ERROR: You have to be level 3 to use that command!");
        }
        return 1;
    }
}

forward KickPublic(playerid);
	return Kick(playerid);
Reply
#4

doesn't work :/

player kicked / banned still wont get kicked / banned message
Reply
#5

Here's all you need to know, this helped me and it worked. https://sampwiki.blast.hk/wiki/Kick
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)