change kick system to warn system.
#1

I have a cbug system but when player cbug it directly kicks the player without giving any warning. here is the code ↓

pawn Код:
forward OnPlayerCBug(playerid);
public OnPlayerCBug(playerid) {
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    new str2[128];
    format(str2, sizeof(str2), "{F81414}[Anti-Cbug] {FFFFFF}has kicked {F81414}%s {FFFFFF}for Crouch bugging with weapon {F81414}(%s)", playername, aWeaponNames[WeaponID[playerid]]);
    SendClientMessageToAll(COLOR_WHITE, str2);
    CheckCrouch[playerid] = 0;
    Kick(playerid);
    return 1;
}
I have tried to add warning system but it was bugged. Help me in changing this to warning system.
Reply
#2

pawn Код:
new CBugWarns[MAX_PLAYERS];


OnPlayerConnects(playerid)
{
         CBugWarns[playerid] = 0;
         return 1;
}



public OnPlayerCBug(playerid) {
    CBugWarns[playerid] += 1;
   
    if(CBugWarns[playerid] == 3){
    Kick(playerid);
    //optional messages
    }
    return 1;
}
Something like that. You store the warnings in a var and every time you detect the player C-bugging you add 1 to it. Once it hits 3 warnins, or any other amount you wish, it'll kick the player.
Reply
#3

thank you Mado. +1 rep.
Reply
#4

Replace the Kick(playerid) function with these:

pawn Код:
stock KickWithMessage(playerid, color, message[])
{
    SendClientMessage(playerid, color, message);
    SetTimerEx("KickPublic", 500, 0, "d", playerid);
    return 1;
}

forward KickPublic(playerid);
public KickPublic(playerid)
{
    Kick(playerid);
    return 1;
}
Reply
#5

@Champ; NP, you're welcome.

@Xabi: That is actually a pretty nice way as well, rather than Kick() and a message system apart from each other.

And Champ, make sure you use a timer on the Kick() so the player willa ctually see the message.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)