SA-MP Forums Archive
2 problems with MySQL R40 - 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: 2 problems with MySQL R40 (/showthread.php?tid=647449)



2 problems with MySQL R40 - Kraeror - 05.01.2018

Hello guys can you help me please?
I'm using R40 as I said!
I have two problems, so the first one is:
PHP код:
new hcache_get_row_count(h);
new 
query[2048];
mysql_format(zMySQLquerysizeof(query), "INSERT INTO `houses`(`ID`, `Owner`, `Price`, `X`, `Y`, `Z`, `World`, `X2`, `Y2`, `Z2`, `A2`, `Int:X`, `Int:Y`, `Int:Z`, `Int:X2`, `Int:Y2`, `Int:Z2`, `Int:A2`, `Interior`, `Spawn:X`, `Spawn:Y`, `Spawn:Z`, `Spawn:A`, `Status`) VALUES ('%d', '%e', '%d', '%f', '%f', '%f', '%d', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%f', '%f', '%f', '%f', '%d')",
hHouseInfo[h][hOwner], HouseInfo[h][hPrice], HouseInfo[h][hX], HouseInfo[hY], HouseInfo[h][hZ], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
mysql_tquery(zMySQLquery); 
Output: X: 151.123201, Y: 0, Z: 13.05541 and etc.
The problem is that, the database set the Y coordinate to 0, I tried it to save with dini and dini is saving it correct, but there is problem with my mysql code I'm sure that the table is creating the table with float value. I have already checked it!

And the second is that houses can't be loaded
Here is loading(OnGameModeInit callback):
PHP код:
for(new 1MAX_HOUSESh++)
    {
        new 
house[64], query[1024];
        
mysql_format(zMySQLquerysizeof(query), "SELECT * FROM `houses` WHERE `ID` = %d"h);
          
mysql_tquery(zMySQLquery"LoadHouses""h");
        if( 
strcmp(HouseInfo[h][hOwner], "No"true) == )
        {
            
HouseInfo[h][hPickup] = CreatePickup(12731HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]);
            
HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ], 310,0,0);
        }
        else
        {
            
HouseInfo[h][hPickup] = CreatePickup(195221HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]);
            
HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ], 320,0,0);
        }
    } 
and here is my LoadHouses callback:
PHP код:
forward LoadHouses(houseid);
public 
LoadHouses(houseid)
{
    
cache_get_value_name(houseid"Owner"HouseInfo[houseid][hOwner]);
    
cache_get_value_name_float(houseid"X"HouseInfo[houseid][hX]);
    
cache_get_value_name_float(houseid"Y"HouseInfo[houseid][hY]);
    
cache_get_value_name_float(houseid"Z"HouseInfo[houseid][hZ]);
    
cache_get_value_name_float(houseid"Int:X"HouseInfo[houseid][hiX]);
    
cache_get_value_name_float(houseid"Int:Y"HouseInfo[houseid][hiY]);
    
cache_get_value_name_float(houseid"Int:Z"HouseInfo[houseid][hiZ]);
    
cache_get_value_name_float(houseid"X2"HouseInfo[houseid][hX2]);
    
cache_get_value_name_float(houseid"Y2"HouseInfo[houseid][hY2]);
    
cache_get_value_name_float(houseid"Z2"HouseInfo[houseid][hZ2]);
    
cache_get_value_name_float(houseid"A2"HouseInfo[houseid][hA2]);
    
cache_get_value_name_float(houseid"Int:X2"HouseInfo[houseid][hiX2]);
    
cache_get_value_name_float(houseid"Int:Y2"HouseInfo[houseid][hiY2]);
    
cache_get_value_name_float(houseid"Int:Z2"HouseInfo[houseid][hiZ2]);
    
cache_get_value_name_float(houseid"Int:A2"HouseInfo[houseid][hiA2]);
    
cache_get_value_name_float(houseid"Spawn:X"HouseInfo[houseid][hsX]);
    
cache_get_value_name_float(houseid"Spawn:Y"HouseInfo[houseid][hsY]);
    
cache_get_value_name_float(houseid"Spawn:Z"HouseInfo[houseid][hsZ]);
     
cache_get_value_name_float(houseid"Spawn:A"HouseInfo[houseid][hsA]);
    
cache_get_value_name_int(houseid"Interior"HouseInfo[houseid][hInt]);
    
cache_get_value_name_int(houseid"World"HouseInfo[houseid][hVW]);
    
cache_get_value_name_int(houseid"Price"HouseInfo[houseid][hPrice]);
    
cache_get_value_name_int(houseid"Status"HouseInfo[houseid][hStatus]);
    return 
1;

Sorry for my realy bad english!


Re: 2 problems with MySQL R40 - iLearner - 05.01.2018

About question 1, debug the HouseInfo[hY] value (
PHP код:
printf("%f"HouseInfo[hY]); 
) and post it.

Second one goes this way:
PHP код:
for(new 1MAX_HOUSESh++) 

    new 
house[64], query[1024]; 
    
mysql_format(zMySQLquerysizeof(query), "SELECT * FROM `houses` WHERE `ID` = %d"h); 
    
mysql_tquery(zMySQLquery"LoadHouses""i",h);  
}  
forward LoadHouses(houseid); 
public 
LoadHouses(houseid

    
cache_get_value_name(houseid"Owner"HouseInfo[houseid][hOwner]); 
    
cache_get_value_name_float(houseid"X"HouseInfo[houseid][hX]); 
    
cache_get_value_name_float(houseid"Y"HouseInfo[houseid][hY]); 
    
cache_get_value_name_float(houseid"Z"HouseInfo[houseid][hZ]); 
    
cache_get_value_name_float(houseid"Int:X"HouseInfo[houseid][hiX]); 
    
cache_get_value_name_float(houseid"Int:Y"HouseInfo[houseid][hiY]); 
    
cache_get_value_name_float(houseid"Int:Z"HouseInfo[houseid][hiZ]); 
    
cache_get_value_name_float(houseid"X2"HouseInfo[houseid][hX2]); 
    
cache_get_value_name_float(houseid"Y2"HouseInfo[houseid][hY2]); 
    
cache_get_value_name_float(houseid"Z2"HouseInfo[houseid][hZ2]); 
    
cache_get_value_name_float(houseid"A2"HouseInfo[houseid][hA2]); 
    
cache_get_value_name_float(houseid"Int:X2"HouseInfo[houseid][hiX2]); 
    
cache_get_value_name_float(houseid"Int:Y2"HouseInfo[houseid][hiY2]); 
    
cache_get_value_name_float(houseid"Int:Z2"HouseInfo[houseid][hiZ2]); 
    
cache_get_value_name_float(houseid"Int:A2"HouseInfo[houseid][hiA2]); 
    
cache_get_value_name_float(houseid"Spawn:X"HouseInfo[houseid][hsX]); 
    
cache_get_value_name_float(houseid"Spawn:Y"HouseInfo[houseid][hsY]); 
    
cache_get_value_name_float(houseid"Spawn:Z"HouseInfo[houseid][hsZ]); 
    
cache_get_value_name_float(houseid"Spawn:A"HouseInfo[houseid][hsA]); 
    
cache_get_value_name_int(houseid"Interior"HouseInfo[houseid][hInt]); 
    
cache_get_value_name_int(houseid"World"HouseInfo[houseid][hVW]); 
    
cache_get_value_name_int(houseid"Price"HouseInfo[houseid][hPrice]); 
    
cache_get_value_name_int(houseid"Status"HouseInfo[houseid][hStatus]);
    if( 
strcmp(HouseInfo[h][hOwner], "No"true) == 
    { 
        
HouseInfo[h][hPickup] = CreatePickup(12731HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]); 
        
HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ], 310,0,0); 
    } 
    else 
    { 
        
HouseInfo[h][hPickup] = CreatePickup(195221HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]); 
        
HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ], 320,0,0); 
    } 
    return 
1




Re: 2 problems with MySQL R40 - Kraeror - 05.01.2018

Quote:
Originally Posted by iLearner
Посмотреть сообщение
About question 1, debug the HouseInfo[hY] value (
PHP код:
printf("%f"HouseInfo[hY]); 
) and post it.

Second one goes this way:
PHP код:
for(new 1MAX_HOUSESh++) 

    new 
house[64], query[1024]; 
    
mysql_format(zMySQLquerysizeof(query), "SELECT * FROM `houses` WHERE `ID` = %d"h); 
    
mysql_tquery(zMySQLquery"LoadHouses""i",h);  
}  
forward LoadHouses(houseid); 
public 
LoadHouses(houseid

    
cache_get_value_name(houseid"Owner"HouseInfo[houseid][hOwner]); 
    
cache_get_value_name_float(houseid"X"HouseInfo[houseid][hX]); 
    
cache_get_value_name_float(houseid"Y"HouseInfo[houseid][hY]); 
    
cache_get_value_name_float(houseid"Z"HouseInfo[houseid][hZ]); 
    
cache_get_value_name_float(houseid"Int:X"HouseInfo[houseid][hiX]); 
    
cache_get_value_name_float(houseid"Int:Y"HouseInfo[houseid][hiY]); 
    
cache_get_value_name_float(houseid"Int:Z"HouseInfo[houseid][hiZ]); 
    
cache_get_value_name_float(houseid"X2"HouseInfo[houseid][hX2]); 
    
cache_get_value_name_float(houseid"Y2"HouseInfo[houseid][hY2]); 
    
cache_get_value_name_float(houseid"Z2"HouseInfo[houseid][hZ2]); 
    
cache_get_value_name_float(houseid"A2"HouseInfo[houseid][hA2]); 
    
cache_get_value_name_float(houseid"Int:X2"HouseInfo[houseid][hiX2]); 
    
cache_get_value_name_float(houseid"Int:Y2"HouseInfo[houseid][hiY2]); 
    
cache_get_value_name_float(houseid"Int:Z2"HouseInfo[houseid][hiZ2]); 
    
cache_get_value_name_float(houseid"Int:A2"HouseInfo[houseid][hiA2]); 
    
cache_get_value_name_float(houseid"Spawn:X"HouseInfo[houseid][hsX]); 
    
cache_get_value_name_float(houseid"Spawn:Y"HouseInfo[houseid][hsY]); 
    
cache_get_value_name_float(houseid"Spawn:Z"HouseInfo[houseid][hsZ]); 
    
cache_get_value_name_float(houseid"Spawn:A"HouseInfo[houseid][hsA]); 
    
cache_get_value_name_int(houseid"Interior"HouseInfo[houseid][hInt]); 
    
cache_get_value_name_int(houseid"World"HouseInfo[houseid][hVW]); 
    
cache_get_value_name_int(houseid"Price"HouseInfo[houseid][hPrice]); 
    
cache_get_value_name_int(houseid"Status"HouseInfo[houseid][hStatus]);
    if( 
strcmp(HouseInfo[h][hOwner], "No"true) == 
    { 
        
HouseInfo[h][hPickup] = CreatePickup(12731HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]); 
        
HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ], 310,0,0); 
    } 
    else 
    { 
        
HouseInfo[h][hPickup] = CreatePickup(195221HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]); 
        
HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ], 320,0,0); 
    } 
    return 
1

It prints correct!
There is problem with table or code
Can you help me pls! I checked the table and the all floats, that I created are recreated to "double", but X and Z coordinates are saved without any problems!


Re: 2 problems with MySQL R40 - iLearner - 05.01.2018

Can you show your table structure?


Re: 2 problems with MySQL R40 - Kraeror - 05.01.2018

Here you are: https://imgur.com/a/DV1bP


Re: 2 problems with MySQL R40 - Kraeror - 05.01.2018

Fixed bro :X, realy stupid mistake... Look HouseInfo[hY] it have to be HouseInfo[h][hY]...


Re: 2 problems with MySQL R40 - Kraeror - 05.01.2018

About the loading system, it loads all of the houses to coordinates 0,0,0! Please help! I think it is because of the houses IDs, so in the table the IDs are started from 17! It was started from 1 or 0, but when I delete any house there is some problem Please help me brother


Re: 2 problems with MySQL R40 - iLearner - 05.01.2018

PHP код:
// whereever you load your houses   
mysql_tquery(zMySQL"SELECT * FROM `houses`""LoadHouses");     

forward LoadHouses();  
public 
LoadHouses()  
{  
    for(new 
i=0i<cache_num_rows(); i++)
    {
        
cache_get_value_name(i"Owner"HouseInfo[i][hOwner]);  
        
cache_get_value_name_float(i"X"HouseInfo[i][hX]);  
        
cache_get_value_name_float(i"Y"HouseInfo[i][hY]);  
        
cache_get_value_name_float(i"Z"HouseInfo[i][hZ]);  
        
cache_get_value_name_float(i"Int:X"HouseInfo[i][hiX]);  
        
cache_get_value_name_float(i"Int:Y"HouseInfo[i][hiY]);  
        
cache_get_value_name_float(i"Int:Z"HouseInfo[i][hiZ]);  
        
cache_get_value_name_float(i"X2"HouseInfo[i][hX2]);  
        
cache_get_value_name_float(i"Y2"HouseInfo[i][hY2]);  
        
cache_get_value_name_float(i"Z2"HouseInfo[i][hZ2]);  
        
cache_get_value_name_float(i"A2"HouseInfo[i][hA2]);  
        
cache_get_value_name_float(i"Int:X2"HouseInfo[i][hiX2]);  
        
cache_get_value_name_float(i"Int:Y2"HouseInfo[i][hiY2]);  
        
cache_get_value_name_float(i"Int:Z2"HouseInfo[i][hiZ2]);  
        
cache_get_value_name_float(i"Int:A2"HouseInfo[i][hiA2]);  
        
cache_get_value_name_float(i"Spawn:X"HouseInfo[i][hsX]);  
        
cache_get_value_name_float(i"Spawn:Y"HouseInfo[i][hsY]);  
        
cache_get_value_name_float(i"Spawn:Z"HouseInfo[i][hsZ]);  
        
cache_get_value_name_float(i"Spawn:A"HouseInfo[i][hsA]);  
        
cache_get_value_name_int(i"Interior"HouseInfo[i][hInt]);  
        
cache_get_value_name_int(i"World"HouseInfo[i][hVW]);  
        
cache_get_value_name_int(i"Price"HouseInfo[i][hPrice]);  
        
cache_get_value_name_int(i"Status"HouseInfo[i][hStatus]); 
        if( 
strcmp(HouseInfo[i][hOwner], "No"true) == )  
        {  
            
HouseInfo[i][hPickup] = CreatePickup(12731HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);  
            
HouseInfo[i][hIcon] = CreateDynamicMapIcon(HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 310,0,0);  
        }  
        else  
        {  
            
HouseInfo[i][hPickup] = CreatePickup(195221HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);  
            
HouseInfo[i][hIcon] = CreateDynamicMapIcon(HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 320,0,0);  
        }
    }  
    return 
1;  




Re: 2 problems with MySQL R40 - Kraeror - 05.01.2018

You are PROOO! Thank s a lot! And sorry for my stupid questions, can I send you private messages for MySQL help, because I'm still learning it!

+1 REP!!!