Player doesn't get kicked!
#1

Hello, I'm working on WARN command and I got this issuse while testing the command.

First problem is: player doesn't get kicked once he crossed warn limit.
Second problem is: Instead of maximum 3 warns it keeps going to four.

Код:
COMMAND:warn(playerid, params[])
{
	if (Player[playerid][IsLoggedIn] == true)
	{
		if(IsPlayerAdmin(playerid))
		{
			new id, msg1[128], name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], reason[128];
			if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, -1, "Invalid Syntax, Usage: /warn (id) (Reason");
			if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "That player doesn't exist!");
			GetPlayerName(playerid, name, sizeof(name));
			GetPlayerName(id, name1, sizeof(name1));
			format(msg1, sizeof(msg1), "{FFFFFF}(INFO): {FF8F17}You have been warned by admin %s(%d) for %s", name, playerid, reason);
			SendClientMessage(id, -1, msg1);
			format(msg1, sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}%s has been warned by %s(%d) for %s", name1, name, playerid, reason);
			SendClientMessageToAll(-1, msg1);
			if(Player[playerid][TotalWarns] == 3)
			{
				SetTimerEx("WarnTimerKick", 500, false, "i", name1);
				//SendClientMessage(name1, -1, "{FFFFFF}(INFO): {FF8F17}You have been kicked for forbbiden level of warns!");
				format(msg1, sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}% has been kicked for forbbiden level of warns!", name1);
				SendClientMessageToAll(-1, msg1);
			}
			else
			{
				Player[playerid][TotalWarns]++;
			}
		} else SendClientMessage(playerid, -1, "You are no admin");
	} else SendClientMessage(playerid, -1, "You are no logged");
 return 1;
}
forward WarnTimeKick(name1);
public WarnTimeKick(name1)
{
	Kick(name1);
}
I'm also little bit tired (No it isn't an exuse for my scripting), so I might be missing basic thing but still.
Reply
#2

1. You passed in the name of the player to the kick function instead of the id.
2. You were adding the Warning in an else statement. So it becomes 4 instead of 3.
This should fix it.
PHP код:
COMMAND:warn(playeridparams[])
{
    if (
Player[playerid][IsLoggedIn] == true)
    {
        if(
IsPlayerAdmin(playerid))
        {
            new 
idmsg1[128], name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], reason[128];
            if(
sscanf(params"us"idreason)) return SendClientMessage(playerid, -1"Invalid Syntax, Usage: /warn (id) (Reason");
            if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"That player doesn't exist!");
            
GetPlayerName(playeridnamesizeof(name));
            
GetPlayerName(idname1sizeof(name1));
            
format(msg1sizeof(msg1), "{FFFFFF}(INFO): {FF8F17}You have been warned by admin %s(%d) for %s"nameplayeridreason);
            
SendClientMessage(id, -1msg1);
            
format(msg1sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}%s has been warned by %s(%d) for %s"name1nameplayeridreason);
            
SendClientMessageToAll(-1msg1);
            
Player[playerid][TotalWarns]++;
            if(
Player[playerid][TotalWarns] == 3)
            {
                
SetTimerEx("WarnTimerKick"500false"i"id);
                
//SendClientMessage(name1, -1, "{FFFFFF}(INFO): {FF8F17}You have been kicked for forbbiden level of warns!");
                
format(msg1sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}%s has been kicked for forbbiden level of warns!"name1);
                
SendClientMessageToAll(-1msg1);
            }
        } else 
SendClientMessage(playerid, -1"You are no admin");
    } else 
SendClientMessage(playerid, -1"You are no logged");
 return 
1;
}
forward WarnTimeKick(id);
public 
WarnTimeKick(id)
{
    
Kick(id);

Reply
#3

Why do you even need a timer while you can check in cmd , so if the player's warning is 3 or bigger than 3 it will kick him.

Код:
COMMAND:warn(playerid, params[])
{
	if (Player[playerid][IsLoggedIn] == true)
	{
		if(IsPlayerAdmin(playerid))
		{
			new id, msg1[128], name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], reason[128];
			if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, -1, "Invalid Syntax, Usage: /warn (id) (Reason");
			if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "That player doesn't exist!");
			GetPlayerName(playerid, name, sizeof(name));
			GetPlayerName(id, name1, sizeof(name1));
			format(msg1, sizeof(msg1), "{FFFFFF}(INFO): {FF8F17}You have been warned by admin %s(%d) for %s", name, playerid, reason);
			SendClientMessage(id, -1, msg1);
			format(msg1, sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}%s has been warned by %s(%d) for %s", name1, name, playerid, reason);
			SendClientMessageToAll(-1, msg1);
			if(Player[playerid][TotalWarns] => 3)
			{
				Kick(id);
				format(msg1, sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}% has been kicked for forbbiden level of warns!", name1);
				SendClientMessageToAll(-1, msg1);
			}
			else
			{
				Player[playerid][TotalWarns]++;
			}
		} else SendClientMessage(playerid, -1, "You are no admin");
	} else SendClientMessage(playerid, -1, "You are no logged");
 return 1;
}
Edit:Ups, Dark was faster but anyway test this if others wont work.
Reply
#4

@Lazzy, your code has some errors.
@Skull, I still don't get kicked.
Reply
#5

You miss spelt the callback:

Код:
forward WarnTimeKick(id);
Код:
SetTimerEx("WarnTimerKick", 500, false, "i", id);
Reply
#6

Quote:
Originally Posted by LazzyBoy
Посмотреть сообщение
Why do you even need a timer while you can check in cmd , so if the player's warning is 3 or bigger than 3 it will kick him.

Код:
COMMAND:warn(playerid, params[])
{
	if (Player[playerid][IsLoggedIn] == true)
	{
		if(IsPlayerAdmin(playerid))
		{
			new id, msg1[128], name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], reason[128];
			if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, -1, "Invalid Syntax, Usage: /warn (id) (Reason");
			if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "That player doesn't exist!");
			GetPlayerName(playerid, name, sizeof(name));
			GetPlayerName(id, name1, sizeof(name1));
			format(msg1, sizeof(msg1), "{FFFFFF}(INFO): {FF8F17}You have been warned by admin %s(%d) for %s", name, playerid, reason);
			SendClientMessage(id, -1, msg1);
			format(msg1, sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}%s has been warned by %s(%d) for %s", name1, name, playerid, reason);
			SendClientMessageToAll(-1, msg1);
			if(Player[playerid][TotalWarns] => 3)
			{
				Kick(id);
				format(msg1, sizeof(msg1), "{FFFFFF}(PUBLIC INFO): {FF8F17}% has been kicked for forbbiden level of warns!", name1);
				SendClientMessageToAll(-1, msg1);
			}
			else
			{
				Player[playerid][TotalWarns]++;
			}
		} else SendClientMessage(playerid, -1, "You are no admin");
	} else SendClientMessage(playerid, -1, "You are no logged");
 return 1;
}
Edit:Ups, Dark was faster but anyway test this if others wont work.
He needs to put the timer or else the player being kicked will not get the message.
Reply
#7

Quote:
Originally Posted by LEOTorres
Посмотреть сообщение
You miss spelt the callback:

Код:
forward WarnTimeKick(id);
Код:
SetTimerEx("WarnTimerKick", 500, false, "i", id);
You have to be kidding be! Niiiice!!!
Reply
#8

It's working now

Also, can you guys take a look on this post too: https://sampforum.blast.hk/showthread.php?tid=632656
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)