/kick does not message the kicked player
#1

PHP код:
CMD:kick(playeridparams[])
{
    if (!(
IsPlayerAdmin(playerid))) return 0;
    new 
targetidname1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], kickreason[128];
    if(
sscanf(params"us"targetidkickreason)) return SendClientMessage(playerid, -1"Usage: /kick [ID] [REASON]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,"Invalid ID.");
    
GetPlayerName(playeridname1sizeof(name1));
    
GetPlayerName(targetidname2sizeof(name2));
    new 
kickmsg[128];
    
format(kickmsgsizeof(kickmsg), "[ADMIN] %s was kicked by %s for: %s"name2name1kickreason);
    
SendClientMessageToAll(COLOR_ORANGEkickmsg);
    
Kick(targetid);
    return 
1;

As stated in the title, the kick message returns to all the players but the kicked player. Would a timer between the SendClientMessageToAll and Kick(targetid) work? Or are there any other workarounds? I've started scripting pawno since yesterday so there may be some flaws in the script.
Reply
#2

See here: https://sampwiki.blast.hk/wiki/Kick
Reply
#3

You'll need a timer with a small interval to kick the player so you can send a message/show a dialog before.
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You'll need a timer with a small interval to kick the player so you can send a message/show a dialog before.
Yep, Sadly SA:MP removed the thingy that used to wait a bit after you sent your ban dialog or message, so now we have to use timers.
Reply
#5

PHP код:
forward KickPublic(playerid);
public 
KickPublic(playeridKick(playerid);
stock KickWithMessage(playerid)
{
    
//SendClientMessageToAll(playerid, color, message);
    
SetTimerEx("KickPublic"200"d"playerid);
}
/* TEST */
CMD:kick(playeridparams[])
{
    if (!(
IsPlayerAdmin(playerid))) return 0;
    new 
targetidname1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], kickreason[128];
    if(
sscanf(params"us"targetidkickreason)) return SendClientMessage(playerid, -1"Usage: /kick [ID] [REASON]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,"Invalid ID.");
    
GetPlayerName(playeridname1sizeof(name1));
    
GetPlayerName(targetidname2sizeof(name2));
    new 
kickmsg[128];
    
format(kickmsgsizeof(kickmsg), "[ADMIN] %s was kicked by %s for: %s"name2name1kickreason);
    
SendClientMessageToAll(COLOR_ORANGEkickmsg);
    
KickWithMessage(playerid);
    return 
1;

Code now looks like this and it works, is 20 milliseconds recommended?
Reply
#6

Quote:
Originally Posted by -Jason
Посмотреть сообщение
PHP код:
forward KickPublic(playerid);
public 
KickPublic(playeridKick(playerid);
stock KickWithMessage(playerid)
{
    
//SendClientMessageToAll(playerid, color, message);
    
SetTimerEx("KickPublic"200"d"playerid);
}
/* TEST */
CMD:kick(playeridparams[])
{
    if (!(
IsPlayerAdmin(playerid))) return 0;
    new 
targetidname1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], kickreason[128];
    if(
sscanf(params"us"targetidkickreason)) return SendClientMessage(playerid, -1"Usage: /kick [ID] [REASON]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,"Invalid ID.");
    
GetPlayerName(playeridname1sizeof(name1));
    
GetPlayerName(targetidname2sizeof(name2));
    new 
kickmsg[128];
    
format(kickmsgsizeof(kickmsg), "[ADMIN] %s was kicked by %s for: %s"name2name1kickreason);
    
SendClientMessageToAll(COLOR_ORANGEkickmsg);
    
KickWithMessage(playerid);
    return 
1;

Code now looks like that and it worked, is 20 milliseconds recommended?
Try 1000ms Its 1 sec i think
Reply
#7

Reading the wiki is pretty easy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)