Show kick reason
#1

When i kick someone from my server for the id i kick it's only say "server closed connection" i want it's says the reason how to make?

Quote:

CMD:kick(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 4)
{
new string[128], giveplayerid, reason[64];
if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");
if(giveplayerid == playerid)
{
new string2[128];
format(string, sizeof(string), "AdmCmd: %s has kicked himself.", GetPlayerNameEx(playerid));
format(string2,sizeof(string2),"%s has kicked himself. Reason: %s",GetPlayerNameEx(playerid),reason);
SendClientMessageToAll(COLOR_RED,string2);
ABroadCast(COLOR_YELLOW,string, (PlayerInfo[playerid][pAdmin] == 1) ? (1) : (2));
Kick(playerid);
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= 2 || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid)
{
format(string, sizeof(string), "AdmCmd: %s has been auto-kicked, reason: Trying to /kick a higher admin.", GetPlayerNameEx(playerid));
ABroadCast(COLOR_YELLOW,string, (PlayerInfo[playerid][pAdmin] == 1) ? (1) : (2));
Kick(playerid);
return 1;
}
else
{
new year, month,day;
getdate(year, month, day);
new playerip[32];
GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
format(string, sizeof(string), "AdmCmd: %s (IP:%s) was kicked by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
Log("logs/kick.log", string);
if(PlayerInfo[playerid][pAdmin] == 1) Log("logs/moderator.log", string);
if(PlayerInfo[playerid][pAdmin] == 1)
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Server Moderator %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] == 2)
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Junior Admin %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] == 3)
{
format(string, sizeof(string), "AdmCmd: %s was kicked by General Admin %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] >= 4 && PlayerInfo[playerid][pAdmin] < 1337)
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Senior Admin %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] == 1337)
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Head Admin %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] >= 1338 && PlayerInfo[playerid][pAdmin] < 9999
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Community Manager %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] == 9999
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Server Co Owner %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
else if(PlayerInfo[playerid][pAdmin] == 99999)
{
format(string, sizeof(string), "AdmCmd: %s was kicked by Server Owner %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
}
return 1;
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

Reply
#2

execute the kick function through a timer. But its unbelievable how you haven't read anything about this, many before you had the same problem.
Reply
#3

You gotta set a timer of a few or 1 second to show the message and then use the kick function.
Reply
#4

https://sampwiki.blast.hk/wiki/Kick Bottom.
Reply
#5

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
You gotta set a timer of a few or 1 second to show the message and then use the kick function.
Where in GM i going to set that timer? I'll make like you will se the /kick text 2 second then "server closed connection"
Reply
#6

Quote:
Originally Posted by dannyk0ed
Посмотреть сообщение
Where i going to put it? Which text i going to copy?
Reply
#7

Paste this code outside any callback.

pawn Код:
new KickTimer[MAX_PLAYERS];
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}
In the /kick command:

pawn Код:
KickTimer[playerid] = SetTimerEx("KickPlayer",500,false,"d",playerid);
Reply
#8

Quote:
Originally Posted by Face9000
Посмотреть сообщение
pawn Код:
KickTimer[playerid] = SetTimerEx("KickPlayer",500,false,"d",playerid);
There's no need to name a timer that you will never kill.
Reply
#9

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
There's no need to name a timer that you will never kill.
In my gamemode i use it, i like organized things.
Reply
#10

Quote:
Originally Posted by Face9000
Посмотреть сообщение
In my gamemode i use it, i like organized things.
Useless is not what I call organised.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)