OnPlayerConnect
#1

Hello,

For my ban system my server is checking at OnPlayerConnect if the person is banned or not.
But when he isn't banned he need to get the text and the other part of the OnPlayerConnect.
This is the ban check:
pawn Код:
new name[24],ip[16];
    GetPlayerIp(playerid,ip,sizeof ip);
    GetPlayerName(playerid,name,sizeof name);
    for(new id; id < 24; id++)
    {
        if(!strcmp(name,TempBans[id][BannedName]))
        {   // ban type is name
            SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
            Kick(playerid);
            return 1;
        }
       
        if(!strcmp(ip,TempBans[id][BannedIP]))
        {   // ban type is ip !
            SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
            Kick(playerid);
            return 1;
        }
    }
Other part of the code:
pawn Код:
SendClientMessage(playerid,COLOR_WHITE,"Welcome at the server! ");
        .....
Probably it's something like this:
pawn Код:
new name[24],ip[16];
    GetPlayerIp(playerid,ip,sizeof ip);
    GetPlayerName(playerid,name,sizeof name);
    for(new id; id < 24; id++)
    {
        if(!strcmp(name,TempBans[id][BannedName]))
        {   // ban type is name
            SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
            Kick(playerid);
            return 1;
        }
       
        if(!strcmp(ip,TempBans[id][BannedIP]))
        {   // ban type is ip !
            SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
            Kick(playerid);
            return 1;
        }
    }
        else
        //Other part of code
But that doens't work really.
Reply
#2

nvm,
pawn Код:
public OnPlayerConnect(playerid)
{
    new name[24],ip[16];
    GetPlayerIp(playerid,ip,sizeof ip);
    GetPlayerName(playerid,name,sizeof name);
    for(new id; id < 24; id++)
    {
        if(!strcmp(name,TempBans[id][BannedName]))
        {   // ban type is name
            SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
            Kick(playerid);
            return 1;
        } else if(!strcmp(ip,TempBans[id][BannedIP]))
        {   // ban type is ip !
            SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
            Kick(playerid);
            return 1;
        }
    }

    SendClientMessage(playerid, -1, "Welcome to the serva!);
    return 1;
}
Doesn't this work?
Reply
#3

That isn't working, then I'm getting directly the message that I'm banned.
Reply
#4

Add this protection: (Any sort of Length check) using strlen, strlen > somenumber etc..

pawn Код:
if( !strcmp(name,TempBans[id][BannedName]) && strlen(TempBans[id][BannedName]) > 7 )
//I guess that those vars are empty so strcmp returns true.
Reply
#5

nvm .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)