Help making an unkick function. -
Alsarty - 27.01.2015
I wanted to make a kick command with timer, but I can't make the unkick public function. Can you edit the script below to make it work properly? I'd be grateful.
pawn Код:
CMD:kick(playerid, params[])
{
new targetid, minutes, reason[128], string[128];
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "Kick: /Kick (id) (minutes) (reason)");
format(string, sizeof(string), "Administrator %s kicked %s for %d minutes: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
SendClientMessageToAll(COLOR_RED, string);
Ban(targetid);
KickTimer = SetTimerEx("Unkick", minutes*60000, false, "i", targetid);
kicked[targetid] = true;
return 1;
}
public Unkick(playerid)
{
new string[128], ip[16];
format(string,sizeof(string),"unbanip %f",ip);
SendRconCommand(format);
kicked[playerid] = false;
return 1;
}
Re: Help making an unkick function. -
Schneider - 27.01.2015
Well, you are not formatting the IP addess. I'm not sure if it works, but you should try to get the players IP when you use the kick command and pass it to the Unkick-function (instead of the playerid).
There's also no use to the kicked[playerid]-variable since players probably have a different playerid when they re-join the server.
But I think you're better of storing the unban-time in the player-file. Because if the server is shutdown while that timer is running, the player won't get unbanned.
pawn Код:
CMD:kick(playerid, params[])
{
new targetid, minutes, reason[128], string[128], ip[16];
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "Kick: /Kick (id) (minutes) (reason)");
format(string, sizeof(string), "Administrator %s kicked %s for %d minutes: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
SendClientMessageToAll(COLOR_RED, string);
GetPlayerIp(targetid, ip, 16);
Ban(targetid);
SetTimerEx("Unkick", minutes*60000, false, "s", ip);
return 1;
}
forward Unkick(ip[]);
public Unkick(ip[])
{
new string[32];
format(string,sizeof(string),"unbanip %s", ip);
SendRconCommand(string);
return 1;
}
Re: Help making an unkick function. -
Alsarty - 27.01.2015
Thanks, appreciated!
+Rep
Re: Help making an unkick function. -
Jefff - 27.01.2015
Use
https://sampwiki.blast.hk/wiki/BlockIpAddress it will automatically unbanned player after this time
pawn Код:
CMD:kick(playerid, params[])
{
new targetid, minutes, reason[128];
if(PlayerInfo[playerid][pAdmin] < 2) SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
else if(sscanf(params,"uis[128]", targetid, minutes, reason)) SendClientMessage(playerid, COLOR_RED, "Kick: /Kick (id) (minutes) (reason)");
else if(targetid == INVALID_PLAYER_ID || !IsPlayerConnected(targetid)) SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
else{
new string[128], IP[16];
format(string, sizeof(string), "Administrator %s kicked %s for %d minutes: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
SendClientMessageToAll(COLOR_RED, string);
GetPlayerIp(targetid, IP, sizeof(IP));
BlockIpAddress(IP, minutes*60000);
Kick(targetid);
}
return 1;
}