Mysql have big bytes
#1

Hello when i add the code to CheckBan Mysql i get this Problem

PHP код:
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
Header size
:           9988 bytes
Code size
:           490368 bytes
Data size
:          3181236 bytes
Stack
/heap size:      16384 bytesestimated maxusage=4414 cells (17656 bytes)
Total requirements3697976 bytes 
This is the code

PHP код:
stock CheckBan(playerid)
{
       new 
Query[500],playerIP[16],timeBanned[256],largestringtwo[256],adminName[24],bannedName[24],reasonBanned[128];
    
GetPlayerIp(playeridplayerIPsizeof(playerIP));
    
format(Querysizeof(Query), "SELECT * FROM `banlog` WHERE ( `Name` = '%s' OR `pIPBanned` = '%s' ) AND `pAccountLock` = '1' LIMIT 1",PlayerName(playerid),playerIP);
    
mysql_query(Query);
    
mysql_store_result();
    if(
mysql_num_rows() != 0)
    {
        while(
mysql_fetch_row(Query))
        {
                
mysql_fetch_field_row(reasonBanned"pBannedReason");
                
mysql_fetch_field_row(adminName"pBannedBy");
                
mysql_fetch_field_row(timeBanned"pTime");
                
mysql_fetch_field_row(playerIP"pIPBanned");
                
mysql_fetch_field_row(bannedName"Name");
        }
        
format(largestringtwosizeof(largestringtwo), "You are currently banned from this server. \r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s"bannedNameplayerIPtimeBannedadminNamereasonBanned);
        
ShowPlayerDialog(playeridDIALOG_BANNEDDIALOG_STYLE_MSGBOX"You are banned from this server"largestringtwo"Leave""");
        
Kick(playerid);
        
printf("Username %s || IP %s is banned!",PlayerName(playerid),playerIP);
    }
    return 
1;

Fast help mee
Reply
#2

Try to add this on your script

#pragma dynamic 145000

That should work
Reply
#3

Thank you broo ) You're best scripter
Add mee on skype Armando.Gjoni1
Reply
#4

That is not a solution, that's a workaround.

That select query is only 97 characters long, not accounting for the placeholder. Given that maximum length of a player's name is 24 characters and the maximum length of an ip address is 15 characters, the total maximum length for that query is 97 + 24 + 15 + 1 null terminator = 137 characters. Yet you declare a string 500 characters in size to hold that.

Then you declare another 256 character string to hold "timeBanned" which should realistically only contain something like 16 characters.

Then you declare yet another 256 character to format the message sent to the client, even though the maximum chat output is 144 characters.

In short: decrease your string sizes wherever you can and don't scatter them around carelessly.
Reply
#5

Vince is also right, I didn't check your script before xD
There is no need for a Query of 500 characters.
Any string you define should be defined as long as it really is or around that.
I mean if you need to hold that timeBanned there is no need for 256 variable length. Use around 16-32 as Vince said. This way you will end up saving Ram usage/cpu cache of the server. (I guess xD)
Reply
#6

Fixed

But have problem if

I add Query more than 256 ?
What will happend? I have to add more now
Reply
#7

Nothing will happen, you just waste bytes to nothing there. There is no need. 150-200 for your query would be good.
Reply
#8

Thank you
You added mee on skype ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)