/kick & /ban don't show the reason
#1

Hello all,

I kicked and banned a player from my game and it did not say the reason....

Can anyone help me?
Thanks.

EDIT: It doesn't show the reason to the player all it said was: "Server closed the connection".

Kick CMD:
Quote:

CMD:kick(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pDonateRank] == 6)
{
new string[128], giveplayerid, reason[64];
if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");

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);
format(string, sizeof(string), "PlayerKick: %s was kicked by %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;
}

Ban CMD:
Quote:

CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
if (PlayerInfo[playerid][pAdmin] >= 1)
{
new string[128], giveplayerid, reason[64];
if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");

if(IsPlayerConnected(giveplayerid))
{
if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
{
format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
ABroadCast(COLOR_YELLOW,string,2);
PlayerInfo[playerid][pBanned] = 1;
new ip[32];
GetPlayerIp(playerid,ip,sizeof(ip));
AddBan(ip);
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 banned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
Log("logs/ban.log", string);
format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
PlayerInfo[giveplayerid][pBanned] = 1;
format(PlayerInfo[giveplayerid][pFlag], 128, "");
new ip[32];
GetPlayerIp(giveplayerid,ip,sizeof(ip));
AddBan(ip);
Kick(giveplayerid);
return 1;
}

}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

Reply
#2

It didn't just show Reason or didn't show X was banned by X, Reason : X? (Did it send string to you?)
Reply
#3

Quote:
Originally Posted by Alpay0098
Посмотреть сообщение
It didn't just show Reason or didn't show X was banned by X, Reason : X? (Did it send string to you?)
I didn't show the reason for the player, that got kick/banned.
Reply
#4

What do you mean reason?
Did it SendClientMessage to you or not?
Reply
#5

Read wiki: https://sampwiki.blast.hk/wiki/Kick
Reply
#6

Quote:
Originally Posted by Alpay0098
Посмотреть сообщение
What do you mean reason?
Did it SendClientMessage to you or not?
It didn't a message to me or the player, that got kicked.
Reply
#7

Hello!

After the message you have to start a timer. In the callback of the timer you have to kick the player.
Read also the wiki.
Reply
#8

You must make a timer for 1000 sec like this

this put in your code kick then add the public

pawn Код:
SetTimerEx("KickPublic",1000,0,"d",giveplayerid);
here's the public
pawn Код:
forward KickPublic(playerid);
public KickPublic(playerid)
{
    Kick(playerid);
}
also you can use that for ban or just make a banpublic and inside the banpublic put Ban(playerid). This should work pretty god I use it.
Reply
#9

Quote:
Originally Posted by Luca12
Посмотреть сообщение
You must make a timer for 1000 sec like this

this put in your code kick then add the public

pawn Код:
SetTimerEx("KickPublic",1000,0,"d",id);
here's the public
pawn Код:
forward KickPublic(playerid);
public KickPublic(playerid)
{
    Kick(playerid);
}
also you can use that for ban or just make a banpublic and inside the banpublic put Ban(playerid). This should work pretty god I use it.
1000 milliseconds are to long. 100 is ok.
Reply
#10

Quote:
Originally Posted by Mencent
Посмотреть сообщение
1000 milliseconds are to long. 100 is ok.
I use this and it's fine for me when I kick the player he get the reason fast.
Reply


Forum Jump:


Users browsing this thread: