SA-MP Forums Archive
3dTextLabel not loading right - 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: 3dTextLabel not loading right (/showthread.php?tid=627848)



3dTextLabel not loading right - AndreiWow - 02.02.2017

Here is a photo of the 3dTextLabel in game: http://imgur.com/a/mqGTL (Left desktop, too lazy to cut off the photo)

As you can see, Everything is loading right expect the owner name


Here is the code:

PHP код:
LoadBuildings()
{
    new 
DB_Query[256], string[120];
    for(new 
0MAX_BUILDINGSi++)
    {
        
mysql_format(DatabaseDB_Querysizeof(DB_Query), "SELECT * FROM `Buildings` WHERE `ID` = %d"i);
         
mysql_query(DatabaseDB_Query);
        
cache_get_value_int(0"ID"BuildingInfo[i][ID]);
        
cache_get_value(0"Owner"BuildingInfo[i][bOwner], 24);
        
cache_get_value(0"Name"BuildingInfo[i][bName], 120);
        
cache_get_value_int(0"VirtualWorld"BuildingInfo[i][bVW]);
        
cache_get_value_int(0"Pickup"BuildingInfo[i][bPickup]);
        
cache_get_value_int(0"InteriorID"BuildingInfo[i][bInt]);
        
        
cache_get_value_float(0"EntranceX"BuildingInfo[i][bEntranceX]);
        
cache_get_value_float(0"EntranceY"BuildingInfo[i][bEntranceY]);
        
cache_get_value_float(0"EntranceZ"BuildingInfo[i][bEntranceZ]);
        
        
cache_get_value_float(0"ExitX"BuildingInfo[i][bExitX]);
        
cache_get_value_float(0"ExitY"BuildingInfo[i][bExitY]);
        
cache_get_value_float(0"ExitZ"BuildingInfo[i][bExitZ]);
        
        
buildings[BuildingInfo[i][ID]] = CreatePickup(BuildingInfo[i][bPickup], 1BuildingInfo[i][bEntranceX], BuildingInfo[i][bEntranceY], BuildingInfo[i][bEntranceZ], 0);
        
format(stringsizeof(string), ""COL_LIGHTBLUE"%s\n"COL_WHITE"-----\n"COL_LIGHTBLUE"Owned by: "COL_WHITE"%s"BuildingInfo[i][bName], BuildingInfo[i][bOwner]);
        
buildings3d[BuildingInfo[i][ID]] = Create3DTextLabel(stringCOLOR_WHITEBuildingInfo[i][bEntranceX], BuildingInfo[i][bEntranceY], BuildingInfo[i][bEntranceZ], 15.000);
        
    }
    return 
1;




Re: 3dTextLabel not loading right - princejeet1510 - 02.02.2017

((Please PM your mods xD.... Especially the HUD + Map please...))


Re: 3dTextLabel not loading right - Vince - 02.02.2017

This is a horrible way to load multiple rows. Instead of sending 100 queries and retrieving one result at a time, send one query and retrieve all results simultaneously. Also you are not freeing the result here which leads to memory leaks.

PHP код:
LoadBuildings()
{
    
mysql_tquery(Database"SELECT * FROM Buildings LIMIT" #MAX_BUILDINGS, "OnBuildingsAvailable");
}

public 
OnBuildingsAvailable()
{
    new 
rows;
    
cache_get_row_count(rows);
    
    for(new 
irowsi++)
    {
        
cache_get_value_int(i"ID"BuildingInfo[i][ID]); 
        
        
// etc
    
}

Screenshot is too small to make out anything meaningful. It's probably related to charsets. Are you using any special non-Latin characters?


Re: 3dTextLabel not loading right - AndreiWow - 02.02.2017

Quote:
Originally Posted by Vince
Посмотреть сообщение
This is a horrible way to load multiple rows. Instead of sending 100 queries and retrieving one result at a time, send one query and retrieve all results simultaneously. Also you are not freeing the result here which leads to memory leaks.

PHP код:
LoadBuildings()
{
    
mysql_tquery(Database"SELECT * FROM Buildings LIMIT" #MAX_BUILDINGS, "OnBuildingsAvailable");
}
public 
OnBuildingsAvailable()
{
    new 
rows;
    
cache_get_row_count(rows);
    
    for(new 
irowsi++)
    {
        
cache_get_value_int(i"ID"BuildingInfo[i][ID]); 
        
        
// etc
    
}

Screenshot is too small to make out anything meaningful. It's probably related to charsets. Are you using any special non-Latin characters?
Nope, at the owner row in database it is 'Noone' the default one, also can you show me how to free the result too? or which function is used to free the result


#EDIT
Here is a better photo: http://imgur.com/a/dN8Yd

#EDIT 2, Fixed, it was due to the low string.. still not sure why as the name wasn't going over the string but idk

I still want to know how to free the result because I dont find anything regarding that in the r40 mysql wiki, I use mysql r41-2