SendClientMessage on /kick doesn't work
#1

Upon banning a player it crashes the server/closing the rcon and I don't know the issue.

Код:
[23:14:15] {6a696a}[cmd]: /ban {9c9a9c}<playerid/name> [reason]
[23:14:16] <Whiskey> (0) .
[23:14:16] <Whiskey> .
[23:14:20] {E0E0E0}You are no longer protected against spawn-killing.
[23:14:36] Lost connection to the server. Reconnecting..
[23:14:36] The server is restarting..
[23:14:36] Connecting to 192.168.1.72:7777...
Код:
CMD:ban(playerid, params[])
{
    new targetid;
    new reason;
    new string[200];
    new ip[50];
    GetPlayerIp(targetid, ip, 50);
    if(pInfo[playerid][Adminlevel] < 3) return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: You are not allowed to use this command!");
    if(sscanf(params, "us[50]", targetid, reason))return SendClientMessage(playerid, COLOR_GREY, "{6a696a}[cmd]: /ban {9c9a9c}<playerid/name> [reason]");
    if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: Player not found!");
    format(string, sizeof string, "{FF0000}[Admin] {FF6347}%s(%d) has banned %s(%d). Reason: %s", GetName(playerid), playerid, GetName(targetid), targetid, reason);
	SendClientMessageToAll(COLOR_YELLOW, string);
	SendClientMessage(targetid, COLOR_GREY, "  ");
	SendClientMessage(targetid, COLOR_WHITE, "> BANNED FROM {A10000}BLOODS {FFFFFF} VS {000096}CRIPS");
	SendClientMessage(targetid, COLOR_GREY, "``````````````````````````````````````````````````````````````````");
	format(string, sizeof(string), " > {31AA31}Name{E5E5E5}: %s", GetName(targetid));
	SendClientMessage(targetid, COLOR_GREEN, string);
	format(string, sizeof(string), " > {31AA31}Banned By{E5E5E5}: %s", GetName(playerid));
	SendClientMessage(targetid, COLOR_GREEN, string);
	format(string, sizeof(string), " > {31AA31}Reason{E5E5E5}: %s", reason);
    SendClientMessage(targetid, COLOR_GREEN, string);
    SendClientMessage(targetid, COLOR_GREY, "  ");
    SendClientMessage(targetid, COLOR_WHITE, "You {F7CE00}must {FFFFFF}take a screen-shot {F7CE00}(F8) {FFFFFF}for your ban appeal");
    SendClientMessage(targetid, COLOR_GREY, "``````````````````````````````````````````````````````````````````");
    GameTextForPlayer(targetid,"~r~Banned",9000,0);
	SetTimerEx("PauseBan", 1000, false, "d", playerid);
	new message2[125];
	format(message2, sizeof(message2), "banip %s",ip);
	SendRconCommand(message2);
    return 1;
}
Reply
#2

Replace:
pawn Код:
SetTimerEx("KickEx",10000,0,"i",targetid);
Kick(targetid);
to:
pawn Код:
SetTimerEx("KickEx",10000,0,"i",targetid);
That's why you use the timer, so it will call kick the player delayed and the messages will be shown.
Reply
#3

ffs am retarded, didn't see it XD

thanks man

Changed OP as I'm having a issue with /ban too.
Reply
#4

You should get the IP after sscanf and after checking if the "targetid" is valid/connected otherwise you get the IP from player with ID 0.

pawn Код:
new message2[25];
GetPlayerIp(targetid, message2, 16);
format(message2, sizeof(message2), "banip %s", message2);
SendRconCommand(message2);
Reply
#5

I've fixed it.

I basically removed the whole script and copied the "kick player" script and revamped it to ban.

Although, thanks for your efforts & help, Konstantinos xd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)