0.3x kick bugged?
#1

Hello, ever since I upgraded my server to 0.3x, whenever a player gets kicked, it just says "server closed the connection" an it doesn't give the reason. It worked fine in 0.3e and I haven't changed anything...
Here is the /kick command. please help me fix this so players are able to see the reason why that were kicked.

Quote:

{
if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 2)
{
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), "AdmCmd: %s was kicked by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_RED, string);
Kick(giveplayerid);
}
return 1;
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

Reply
#2

Kick() was changed/fixed in 0.3x to close the connection immediately. So if you want send a message you have to kick with a small delay. Something like this should work:

pawn Код:
forward KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);

//Then when you want to kick someone with a message:

SendClientMessage(blah);
SetTimerEx("KickPlayer", 500, "i", id);
Reply
#3

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Kick() was changed/fixed in 0.3x to close the connection immediately. So if you want send a message you have to kick with a small delay. Something like this should work:

pawn Код:
forward KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);

//Then when you want to kick someone with a message:

SendClientMessage(blah);
SetTimerEx("KickPlayer", 500, "i", id);
Thanks man, but can you please show me where I can add the code into my kick() script please?
Reply
#4

Just put the forward anywhere in your script, above the command if you want. (Not inside the command) Then replace Kick(giveplayerid) with SetTimer("KickPlayer", 500, "i", giveplayerid);
Reply
#5

Sorry to sound noob, but would this work?

Quote:

forward KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);

CMD:kick(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 2)
{
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), "AdmCmd: %s was kicked by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_RED, string);
SendClientMessage(blah); // what would go where (blah) is? (playerid)?
SetTimerEx("KickPlayer", 500, "i", id);
}
return 1;
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;

}

Reply
#6

Delete :

pawn Код:
SendClientMessage(blah); // what would go where (blah) is?
And replace this :

pawn Код:
SetTimerEx("KickPlayer", 500, "i", id);
With :

pawn Код:
SetTimerEx("KickPlayer", 500, "i", giveplayerid);
This should work fine i think.
Reply
#7

Thanks both of you! It's recompiling I'll tell you if it worked
Reply
#8

Damn

Quote:

C:\Users\Josh\Desktop\Server422 - Copy\gamemodes\NGRP2.pwn(3436 : warning 202: number of arguments does not match definition
C:\Users\Josh\Desktop\Server422 - Copy\gamemodes\NGRP2.pwn(41381) : error 035: argument type mismatch (argument 3)
C:\Users\Josh\Desktop\Server422 - Copy\gamemodes\NGRP2.pwn(90302) : warning 203: symbol is never used: "RconAttempts"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#9

Quote:
Originally Posted by Josh_Main
Посмотреть сообщение
Damn
Can you post the lines which have the errors?
Reply
#10

Quote:

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), "AdmCmd: %s was kicked by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_RED, string);
SendClientMessage(playerid);
SetTimerEx("KickPlayer", 500, "i", playerid);
}
return 1;
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

thats the last couple of lines, the error is on the SetTimerEx line
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)