/kick does not message the kicked player -
-Jason - 16.01.2014
PHP код:
CMD:kick(playerid, params[])
{
if (!(IsPlayerAdmin(playerid))) return 0;
new targetid, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], kickreason[128];
if(sscanf(params, "us", targetid, kickreason)) return SendClientMessage(playerid, -1, "Usage: /kick [ID] [REASON]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,"Invalid ID.");
GetPlayerName(playerid, name1, sizeof(name1));
GetPlayerName(targetid, name2, sizeof(name2));
new kickmsg[128];
format(kickmsg, sizeof(kickmsg), "[ADMIN] %s was kicked by %s for: %s", name2, name1, kickreason);
SendClientMessageToAll(COLOR_ORANGE, kickmsg);
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(playerid) Kick(playerid);
stock KickWithMessage(playerid)
{
//SendClientMessageToAll(playerid, color, message);
SetTimerEx("KickPublic", 20, 0, "d", playerid);
}
/* TEST */
CMD:kick(playerid, params[])
{
if (!(IsPlayerAdmin(playerid))) return 0;
new targetid, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], kickreason[128];
if(sscanf(params, "us", targetid, kickreason)) return SendClientMessage(playerid, -1, "Usage: /kick [ID] [REASON]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,"Invalid ID.");
GetPlayerName(playerid, name1, sizeof(name1));
GetPlayerName(targetid, name2, sizeof(name2));
new kickmsg[128];
format(kickmsg, sizeof(kickmsg), "[ADMIN] %s was kicked by %s for: %s", name2, name1, kickreason);
SendClientMessageToAll(COLOR_ORANGE, kickmsg);
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(playerid) Kick(playerid);
stock KickWithMessage(playerid)
{
//SendClientMessageToAll(playerid, color, message);
SetTimerEx("KickPublic", 20, 0, "d", playerid);
}
/* TEST */
CMD:kick(playerid, params[])
{
if (!(IsPlayerAdmin(playerid))) return 0;
new targetid, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], kickreason[128];
if(sscanf(params, "us", targetid, kickreason)) return SendClientMessage(playerid, -1, "Usage: /kick [ID] [REASON]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,"Invalid ID.");
GetPlayerName(playerid, name1, sizeof(name1));
GetPlayerName(targetid, name2, sizeof(name2));
new kickmsg[128];
format(kickmsg, sizeof(kickmsg), "[ADMIN] %s was kicked by %s for: %s", name2, name1, kickreason);
SendClientMessageToAll(COLOR_ORANGE, kickmsg);
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.