kick bug
#1

Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME+1];
        GetPlayerName(playerid, name, sizeof(name));
        new player[200];
        format(player,sizeof(player),"/whitelist/%s.txt",name);
        if(!dini_Exists(player))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "You are not whitelisted.");
            Kick(playerid);
        }
        else
        {
            // Allow player to log in.
        }
    ResetDamages(playerid);
	PlayAudioStreamForPlayer(playerid, RandMusic[random(sizeof(RandMusic))]);
	SetPlayerColor(playerid, COLOR_CONNECT);
	ResetPlayerVariables(playerid);
	RemoveBuildingsForMall(playerid);
	CreateAllTextDraws(playerid);
	Delete3DTextLabel(death[playerid]);
 	SeatBelt[playerid] = 0;
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
	SetIntVar(playerid, "VehicleBuyConfirm", 0);  // Allow player to log in.
	return 1;
}

Okay so i removed the kick(playerid); code so i could whitelist myself that works but when i login and im not whitelisted it just kicks me without sending the message any idea?
Reply
#2

Quote:
Originally Posted by alexanderjb918
Посмотреть сообщение
Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME+1];
        GetPlayerName(playerid, name, sizeof(name));
        new player[200];
        format(player,sizeof(player),"/whitelist/%s.txt",name);
        if(!dini_Exists(player))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "You are not whitelisted.");
            Kick(playerid);
        }
        else
        {
            // Allow player to log in.
        }
    ResetDamages(playerid);
	PlayAudioStreamForPlayer(playerid, RandMusic[random(sizeof(RandMusic))]);
	SetPlayerColor(playerid, COLOR_CONNECT);
	ResetPlayerVariables(playerid);
	RemoveBuildingsForMall(playerid);
	CreateAllTextDraws(playerid);
	Delete3DTextLabel(death[playerid]);
 	SeatBelt[playerid] = 0;
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
	SetIntVar(playerid, "VehicleBuyConfirm", 0);  // Allow player to log in.
	return 1;
}

Okay so i removed the kick(playerid); code so i could whitelist myself that works but when i login and im not whitelisted it just kicks me without sending the message any idea?
Create a file on registration of player. Otherwise, you'll go in the file does not exist and will kick you.

OR

Create a file at server startup when you register adds the nicknames of players

..\Server\filescripts\whitelist.txt
Код:
[WHITELIST]
name_0 = alexanderjb918
name_1 = Logofero
name_2 = Nick
Check there is name in the file, if so - skip the players on server, not - kick.

But I would advise you not white and black list, and add it in violation /bl [playerid] [reason]

..\Server\filescripts\blacklist.txt
Код:
[alexanderjb918]
ip = 255.255.255.255
reason = cheater

[Logofero]
ip = 255.255.255.255
reason = bad support

[Nick]
ip = 255.255.255.255
reason = well bot
Reply
#3

You need to make a delayed kick. Since 0.3e, the 'Kick' function completely ends all communication between server and client almost instantaneously. So if the message has not been received by the time 'Kick' is called, they won't receive the message at all. Easiest way of doing this is:
pawn Код:
forward KickPlayer(playerid)
public KickPlayer(playerid) return Kick(playerid);
And replacing all 'Kick(playerid)' functions with:
pawn Код:
SetTimerEx("KickPlayer", 200, false, "i", playerid);
Or you can make a macro for it, lets call it 'KickEx'.
pawn Код:
#define KickEx(%0) SetTimerEx("KickPlayer", 200, false, "i", (%0))
Example:
pawn Код:
#define KickEx(%0) SetTimerEx("KickPlayer", 200, false, "i", (%0))

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME + 1], player[40];
    GetPlayerName(playerid, name, sizeof(name));
    format(player, sizeof(player), "/whitelist/%s.txt", name);
    if(!dini_Exists(player))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "You are not whitelisted.");
        KickEx(playerid);
    }
    else
    {
        // Allow player to log in.
    }
    ResetDamages(playerid);
    PlayAudioStreamForPlayer(playerid, RandMusic[random(sizeof(RandMusic))]);
    SetPlayerColor(playerid, COLOR_CONNECT);
    ResetPlayerVariables(playerid);
    RemoveBuildingsForMall(playerid);
    CreateAllTextDraws(playerid);
    Delete3DTextLabel(death[playerid]);
    SeatBelt[playerid] = 0;
    SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
    SetIntVar(playerid, "VehicleBuyConfirm", 0);  // Allow player to log in.
    return 1;
}

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


Forum Jump:


Users browsing this thread: 1 Guest(s)