Banned user message bug
#1

So, I have the following code in onPlayerConnect();

pawn Код:
if(pInfo[playerid][Banned] == 0){
       
    ShowDialog(playerid, DIALOG_EXISTINGPLAYER);
       
} else {
    new banstring[128];
    new allmessage[128];
    format(banstring, sizeof(banstring), "You were banned from this server for: %s", pInfo[playerid][Reason]);
    format(allmessage, sizeof(allmessage), "%s tried to login but is banned!", pInfo[playerid][Name]);
    SendClientMessage(playerid, COLOR_RED, banstring);
    SendClientMessageToAllBut(playerid, COLOR_RED, allmessage);
    Kick(playerid);
}
However, when the banned user logs in, it kicks them before the sending them the message. If I comment out the line "Kick(playerid);", The "banstring" message is displayed to the banned user. I know a timer would probably do the trick, but I don't know how to set one up, have never used one. Any ideas guys?
Reply
#2

pawn Код:
if(pInfo[playerid][Banned] == 0){
       
    ShowDialog(playerid, DIALOG_EXISTINGPLAYER);
       
} else {
    new banstring[128];
    new allmessage[128];
    format(banstring, sizeof(banstring), "You were banned from this server for: %s", pInfo[playerid][Reason]);
    format(allmessage, sizeof(allmessage), "%s tried to login but is banned!", pInfo[playerid][Name]);
    SendClientMessage(playerid, COLOR_RED, banstring);
    SendClientMessageToAllBut(playerid, COLOR_RED, allmessage);
    SetTimerEx("Kicks",1000,false,"i",playerid);
}
Put this under the command (not in it)
pawn Код:
forward Kicks(playerid);
public Kicks(playerid)
{
Kick(playerid);
}
Reply
#3

Simple :

Change this

pawn Код:
Kick(playerid);
To :

pawn Код:
SetTimerEx("KickPlayer", 1000, false, "i", playerid);
In the bottom of your GameMode :

pawn Код:
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}
EDIT : I just realized i'm stupid in writing fast
Reply
#4

pawn Код:
banEx(playerid, const reason[])
{
    SendClientMessage(playerid, -1, reason);
    SetTimerEx("call_banEx", 200, false, "i", playerid);
    return 0x01;
}

forward call_banEx(p_); public call_banEx(p_) return Ban(p_);
pawn Код:
if(pInfo[playerid][Banned] == 0) ShowDialog(playerid, DIALOG_EXISTINGPLAYER);
else
{  
    new banstring[128];
    format(banstring, sizeof(banstring), "You were banned from this server for: %s", pInfo[playerid][Reason]);
    banEx(playerid, banstring);
   
    format(banstring, sizeof(banstring), "%s tried to login but is banned!", pInfo[playerid][Name]);
    SendClientMessageToAllBut(playerid, COLOR_RED, banstring);
}
Reply
#5

Thanks all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)