Send message Client when kick ,ban and etc
#1

I got a problem in my script, when i kick or ban the player. It doest show the message to the player that got ban or kick it just say "server closed the connection"

How to fix that?
Reply
#2

There is a fix/workaround somewhere on the forums, I can't remember where it is.
Reply
#3

Before 0.3x release the script work fine in 0.3e
Reply
#4

Replace all
Код:
Kick(playerid); => SetTimerEx("KickPlayer",500,false,"i",playerid);
Kick(giveplayerid); => SetTimerEx("KickGPlayer",500,false,"i",giveplayerid);
And add this to you gamemode!
Код:
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}

forward KickGPlayer(giveplayerid);
public KickGPlayer(giveplayerid)
{
    Kick(giveplayerid);
    return 1;
}
Good luck!
Reply
#5

sorry kinda confused where to put it? in this

Код:
CMD:kick(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 2 || PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pBanAppealer] >= 1 || PlayerInfo[playerid][pShopTech] >= 1 || PlayerInfo[playerid][pUndercover] >= 1 || PlayerInfo[playerid][pFactionModerator] >= 1 || PlayerInfo[playerid][pGangModerator] >= 1)
	{
		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_LIGHTRED, string);
				Kick(giveplayerid);
			}
			return 1;
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
Reply
#6

Just delete: Kick(playerid); and replace with this :
SetTimerEx("KickPlayer",500,false,"i",playerid);
and Kick(giveplayerid); replace with this :
SetTimerEx("KickGPlayer",500,false,"i",giveplayeri d);
Reply
#7

Quote:
Originally Posted by niconhan
Посмотреть сообщение
Replace all
Код:
Kick(playerid); => SetTimerEx("KickPlayer",500,false,"i",playerid);
Kick(giveplayerid); => SetTimerEx("KickGPlayer",500,false,"i",giveplayerid);
And add this to you gamemode!
Код:
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}

forward KickGPlayer(giveplayerid);
public KickGPlayer(giveplayerid)
{
    Kick(giveplayerid);
    return 1;
}
Good luck!
Quote:
Originally Posted by Matess
Посмотреть сообщение
Just delete: Kick(playerid); and replace with this :
SetTimerEx("KickPlayer",500,false,"i",playerid);
and Kick(giveplayerid); replace with this :
SetTimerEx("KickGPlayer",500,false,"i",giveplayeri d);
Uh what? Are you both equally uninformed? You don't need two different functions to do the exact same thing ...
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
Uh what? Are you both equally uninformed? You don't need two different functions to do the exact same thing ...
Two fuction for Kick(playerid); and Kick(giveplayerid);
Reply
#9

Add this in your gamemode where the other forward's are:
pawn Код:
forward KickPlayer(playerid);//This set's up the timer, or forward's it.
Add this to the very end of your script:
pawn Код:
public KickPlayer(playerid)//This is the actual kick timer.
{
    Kick(playerid);//Here it kicks the playerid you specified in the timer start.
    return 1;
}
Then replace your kick command with this:
pawn Код:
CMD:kick(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 2 || PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pBanAppealer] >= 1 || PlayerInfo[playerid][pShopTech] >= 1 || PlayerInfo[playerid][pUndercover] >= 1 || PlayerInfo[playerid][pFactionModerator] >= 1 || PlayerInfo[playerid][pGangModerator] >= 1)
    {
        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));
                SetTimerEx("KickPlayer",500,false,"i",playerid);//Here it starts a 1/2 second timer to kick the player that typed the command to kick an admin.
                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_LIGHTRED, string);
                SetTimerEx("KickPlayer",500,false,"i",giveplayerid););//Here it starts a 1/2 second timer to kick the player defined by the admin.


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

Quote:
Originally Posted by niconhan
Посмотреть сообщение
Two fuction for Kick(playerid); and Kick(giveplayerid);
You still don't get it, do you? If I were to write a function KickPlayer(asdf) I would still be able to pass playerid, giveplayerid, target or whatever valid integer I desire. The parameter names are unimportant.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)