SA-MP Forums Archive
[MYSQL] Loading teleports stucking the server - 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: [MYSQL] Loading teleports stucking the server (/showthread.php?tid=634971)



[MYSQL] Loading teleports stucking the server - Lirbo - 29.05.2017

PHP код:
stock ReloadTeleports()
{
    new 
String[64], query[128], Cache:resultgetintgetstr[32], Float:getfloat;
    for(new 
0MAX_TELEPORTSi++)
    {
        
mysql_format(sqlquerysizeof query"SELECT * FROM `Teleports` WHERE `ID` = %d"i);
        
result mysql_query(sqlquery);
        if(
cache_num_rows())
        {
        
getint cache_get_field_content_int(0"ID"); TPDB[i][ID] = getint;
        
cache_get_field_content(0"Description"getstr); format(TPDB[i][Description], 32getstr);
        
getfloat cache_get_field_content_float(0"X1"); TPDB[i][X1] = getfloat;
        
getfloat cache_get_field_content_float(0"Y1"); TPDB[i][Y1] = getfloat;
        
getfloat cache_get_field_content_float(0"Z1"); TPDB[i][Z1] = getfloat;
        
getfloat cache_get_field_content_float(0"A1"); TPDB[i][A1] = getfloat;
        
getint cache_get_field_content_int(0"Interior1"); TPDB[i][Interior1] = getint;
        
getint cache_get_field_content_int(0"VirtualWorld1"); TPDB[i][VirtualWorld1] = getint;
        
getfloat cache_get_field_content_float(0"X2"); TPDB[i][X2] = getfloat;
        
getfloat cache_get_field_content_float(0"Y2"); TPDB[i][Y2] = getfloat;
        
getfloat cache_get_field_content_float(0"Z2"); TPDB[i][Z2] = getfloat;
        
getfloat cache_get_field_content_float(0"A2"); TPDB[i][A2] = getfloat;
        
getint cache_get_field_content_int(0"Interior2"); TPDB[i][Interior2] = getint;
        
getint cache_get_field_content_int(0"VirtualWorld2"); TPDB[i][VirtualWorld2] = getint;
        
        
format(String,sizeof(String),"[Teleport: %d]\n%s"iTPDB[i][Description]);
        
TPEnter[i] = CreateDynamic3DTextLabel(String0xFFFFFFFFTPDB[i][X1], TPDB[i][Y1], TPDB[i][Z1], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID1TPDB[i][VirtualWorld1], TPDB[i][Interior1], -150.0);
        
TPExit[i] = CreateDynamic3DTextLabel(String0xFFFFFFFFTPDB[i][X2], TPDB[i][Y2], TPDB[i][Z2], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID1TPDB[i][VirtualWorld2], TPDB[i][Interior2], -150.0);
        }
        
cache_delete(result);
    }

there is any way to make it work faster?


Re: [MYSQL] Loading teleports stucking the server - StrikerZ - 30.05.2017

Do you even know what're you trying to do with just a single integer and float for every value?
It'll keep changing its value to the new get querry. Use more floats for example.
PHP код:
new Float:getfloat[9]; 
Then using
PHP код:
getfloat[0] =
getfloat[1] = 
So on till 8.
And yes you can increase it by increasing the array size.


Re: [MYSQL] Loading teleports stucking the server - Lirbo - 30.05.2017

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Do you even know what're you trying to do with just a single integer and float for every value?
It'll keep changing its value to the new get querry. Use more floats for example.
PHP код:
new Float:getfloat[9]; 
Then using
PHP код:
getfloat[0] =
getfloat[1] = 
So on till 8.
And yes you can increase it by increasing the array size.
Why would I do it? I don't need it since if you will take a look I store them at the teleport enum.
It's something with the MySQL, not variables


Re: [MYSQL] Loading teleports stucking the server - StrikerZ - 30.05.2017

Nevermind, didn't saw the part ahead of it.
So what do you mean by "making faster" ? Try to elaborate more.


Re: [MYSQL] Loading teleports stucking the server - Lirbo - 30.05.2017

Well because it's gotta check 200 times if teleport exists it's lagging af and sticking the server for like 20 seconds


Re: [MYSQL] Loading teleports stucking the server - StrikerZ - 30.05.2017

PHP код:
stock ReloadTeleports()
{
    
mysql_tquery(sql"SELECT * FROM `Teleports`""ReloadTPS");
    return 
1;
}
forward ReloadTPS();
public 
ReloadTPS()
{
        new 
rows,fields;
        
cache_get_data(rows,fields);
        if(
rows)
        {
            for(new 
0;rows;i++)
            {
                new 
String[64], query[128], Cache:resultgetintgetstr[32], Float:getfloat;
                
getint cache_get_field_content_int(i"ID"); TPDB[i][ID] = getint;
                
cache_get_field_content(i"Description"getstr); format(TPDB[i][Description], 32getstr);
                
getfloat cache_get_field_content_float(i"X1"); TPDB[i][X1] = getfloat;
                
getfloat cache_get_field_content_float(i"Y1"); TPDB[i][Y1] = getfloat;
                
getfloat cache_get_field_content_float(i"Z1"); TPDB[i][Z1] = getfloat;
                
getfloat cache_get_field_content_float(i"A1"); TPDB[i][A1] = getfloat;
                
getint cache_get_field_content_int(i"Interior1"); TPDB[i][Interior1] = getint;
                
getint cache_get_field_content_int(i"VirtualWorld1"); TPDB[i][VirtualWorld1] = getint;
                
getfloat cache_get_field_content_float(i"X2"); TPDB[i][X2] = getfloat;
                
getfloat cache_get_field_content_float(i"Y2"); TPDB[i][Y2] = getfloat;
                
getfloat cache_get_field_content_float(i"Z2"); TPDB[i][Z2] = getfloat;
                
getfloat cache_get_field_content_float(i"A2"); TPDB[i][A2] = getfloat;
                
getint cache_get_field_content_int(i"Interior2"); TPDB[i][Interior2] = getint;
                
getint cache_get_field_content_int(i"VirtualWorld2"); TPDB[i][VirtualWorld2] = getint;
                
format(String,sizeof(String),"[Teleport: %d]\n%s"iTPDB[i][Description]);
                
TPEnter[i] = CreateDynamic3DTextLabel(String0xFFFFFFFFTPDB[i][X1], TPDB[i][Y1], TPDB[i][Z1], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID1TPDB[i][VirtualWorld1], TPDB[i][Interior1], -150.0);
                
TPExit[i] = CreateDynamic3DTextLabel(String0xFFFFFFFFTPDB[i][X2], TPDB[i][Y2], TPDB[i][Z2], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID1TPDB[i][VirtualWorld2], TPDB[i][Interior2], -150.0);
            }
        }
        return 
1;

Why looping through 200 tps while you just have to loop through just the created tps? Makes sense huh?


Re: [MYSQL] Loading teleports stucking the server - ShihabSoft - 31.05.2017

Put this outside the loop with this simple modified query

PHP код:

mysql_format
(sqlquerysizeof query"SELECT * FROM `Teleports`"); 
        
result mysql_query(sqlquery);