SA-MP Forums Archive
/kick does not message the kicked player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /kick does not message the kicked player (/showthread.php?tid=487978)



/kick does not message the kicked player - -Jason - 16.01.2014

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.


Re: /kick does not message the kicked player - Vince - 16.01.2014

See here: https://sampwiki.blast.hk/wiki/Kick


Re: /kick does not message the kicked player - Konstantinos - 16.01.2014

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


Re: /kick does not message the kicked player - Excelize - 16.01.2014

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.


Re: /kick does not message the kicked player - -Jason - 16.01.2014

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?


Re: /kick does not message the kicked player - UnknownOwner - 16.01.2014

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


Re: /kick does not message the kicked player - Beckett - 16.01.2014

Reading the wiki is pretty easy.