Message not showing (/kick)
#1

I have this codes:

pawn Код:
dcmd_kick(playerid,params[])
{
    if(PInfo[playerid][Level] >= 1 || IsPlayerAdmin(playerid))
    {
        //Variables and stuff
        new id, pName[MAX_PLAYER_NAME], pAdminName[MAX_PLAYER_NAME];
        new tmp[256], Index, str[512];
        tmp = strtok(params,Index), id = strval(tmp);
        GetPlayerName(playerid, pAdminName, sizeof(pAdminName));
        GetPlayerName(id,pName, sizeof(pName));
       
        //Checking
        if(!strlen(params)) return SendClientMessage(playerid, -1, ""COL_ORANGE"Usage: "COL_GREY"/kick <id>");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, INCORRECT_ID);

        //Main code
        format(str,sizeof(str),""MESSAGE_TAG" "COL_GREY"Admin "COL_LBLUE"%s "COL_GREY"has kicked "COL_RED"%s", pAdminName, pName);
        SendClientMessageToAll(-1,str);
        new str2[512];
        format(str2, sizeof(str2), ""MESSAGE_TAG" "COL_GREY"You have been "COL_RED"kicked "COL_GREY"by admin "COL_LBLUE"%s", pAdminName);
        SendClientMessage(id, -1, str2);
   
        Kick(id);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, NOT_ALLOWED);
        return 1;
    }
}
The thing is, the player that is kicked can't see the message indicating that he is kicked:

pawn Код:
new str2[512];
format(str2, sizeof(str2), ""MESSAGE_TAG" "COL_GREY"You have been "COL_RED"kicked "COL_GREY"by admin "COL_LBLUE"%s", pAdminName);
SendClientMessage(id, -1, str2);
Any help?
Reply
#2

You need to use a timer to kick the player.

Put the milliseconds at about 1000. This should be enough time for the message to show for the player.
Reply
#3

Use this:

Код:
stock F_Kick(playerid)
{
    return SetTimerEx("kicktimer", 500, false, "u", playerid);
}

forward kicktimer(playerid);
public kicktimer(playerid) return Kick(playerid);

#if defined _ALS_Kick
    #undef Kick
#else
#define _ALS_Kick
    #endif
#define Kick F_Kick
And not because you have to use another function, so that problem is fixed.
Reply
#4

Quote:
Originally Posted by iNetX
Посмотреть сообщение
Use this:

Код:
stock F_Kick(playerid)
{
    return SetTimerEx("kicktimer", 500, false, "u", playerid);
}

forward kicktimer(playerid);
public kicktimer(playerid) return Kick(playerid);

#if defined _ALS_Kick
    #undef Kick
#else
#define _ALS_Kick
    #endif
#define Kick F_Kick
And not because you have to use another function, so that problem is fixed.
Thanks, but where do I need to put those codes? I tried it but it still not working, perhaps I might have done it wrong.
Reply
#5

Quote:
Originally Posted by roar
Посмотреть сообщение
Thanks, but where do I need to put those codes? I tried it but it still not working, perhaps I might have done it wrong.
Below include a_samp.
Reply
#6

Nevermind, it is fixed, thanks for your help though.

I tried this:
pawn Код:
forward KickPlayer(playerid);

public KickPlayer(playerid)
{
    if(IsPlayerConnected(playerid))
        Kick(playerid);

    return 1;
}
pawn Код:
SetTimerEx("KickPlayer",200,false,"d", playerid);
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)