SA-MP Forums Archive
other way? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: other way? (/showthread.php?tid=286277)



other way? - Unknown123 - 27.09.2011

is there a other (shorter) way to do this because it takes long time to load this onplayerconnect
pawn Код:
//OnPlayerConnect
if(isPlayerRangeBanned(playerid))
    {
        if(!isPlayerWhiteListed(playerid))
        {
            new string[59];
            Format(string, "SELECT * FROM `blacklist` WHERE `IP` = '%s'", splitip(PlayerIP(playerid)));
            mysql_query(string, THREAD_RANGEBANNED, playerid);
            SetPVarInt(playerid, "AlreadyBanned", 1);
        }
        else
        {
            new string[80];
            Format(string, "SELECT `pName` FROM `accs` WHERE `pName` = '%s'", PlayerName(playerid));
            mysql_query(string, THREAD_LOGINREGISTER, playerid);
        }
    }
   
    if(isPlayerTempBanned(playerid))
    {
        if(!isPlayerWhiteListed(playerid))
        {
            new string[72];
            Format(string, "SELECT * FROM `bans` WHERE `ipAddress` = '%s' AND `banTime` > '1'", PlayerIP(playerid));
            mysql_query(string, THREAD_TEMPBANNED1, playerid);
            SetPVarInt(playerid, "AlreadyBanned", 1);
        }
        else
        {
            new string[80];
            Format(string, "SELECT `pName` FROM `accs` WHERE `pName` = '%s'", PlayerName(playerid));
            mysql_query(string, THREAD_LOGINREGISTER, playerid);
        }
    }
   
    if(isPlayerBanned(playerid))
    {
        if(!isPlayerWhiteListed(playerid))
        {
            new string[86];
            Format(string, "SELECT * FROM `bans` WHERE `ipAddress` = '%s' AND `banTime` = '0'", PlayerIP(playerid));
            mysql_query(string, THREAD_WHITELISTED, playerid);
            SetPVarInt(playerid, "AlreadyBanned", 1);
        }
        else
        {
            new string[80];
            Format(string, "SELECT `pName` FROM `accs` WHERE `pName` = '%s'", PlayerName(playerid));
            mysql_query(string, THREAD_LOGINREGISTER, playerid);
        }
    }

    if(!isPlayerRangeBanned(playerid) && !isPlayerTempBanned(playerid) && !isPlayerBanned(playerid))
    {
        new string[80];
        if(isPlayerWhiteListed(playerid))
        {
            Format(string, "SELECT `pName` FROM `accs` WHERE `pName` = '%s'", PlayerName(playerid));
        }
        else
        {
            Format(string, "SELECT `pName` FROM `accs` WHERE `pName` = '%s'", PlayerName(playerid));
        }
        mysql_query(string, THREAD_LOGINREGISTER, playerid);
    }



Re: other way? - sleepysnowflake - 27.09.2011

I see no other way ... You gotta check that when player connects, right ? My knowleadge leads me to belive that you can't do it other way.


Re: other way? - Unknown123 - 27.09.2011

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
I see no other way ... You gotta check that when player connects, right ? My knowleadge leads me to belive that you can't do it other way.
yes, um, i mean i gonna use it onplayerconnect. but is there a faster way to do the mysql thing, without checking isplayerbanned > isplayerwhitelisted
istempbanned > iswhitelisted ect..
like a faster and shorter way to do the mysql part, my internet frient did it on a shorter way, but hes never on


Re: other way? - sleepysnowflake - 27.09.2011

Um .... JunkBuster ?


Re: other way? - Unknown123 - 27.09.2011

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
Um .... JunkBuster ?
no, i want my own mysql whitelist/blacklist

there must be a way to make the code better


Re: other way? - sleepysnowflake - 27.09.2011

Mi apologizes. I can't help '-'. MySQL is not my area of expertisse ...


Re: other way? - GrimR - 27.09.2011

And unless you need specific sized char arrays why don't you
declare one string[80] at the start instead of 1 in each conditional
branch?