SA-MP Forums Archive
Can't get float value mysql - 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: Can't get float value mysql (/showthread.php?tid=601833)



Can't get float value mysql - Aa12 - 27.02.2016

Код:
enum VehData
{
    Float:VehHealth
};
new PVeh[MAX_VEHICLES][VehData];

public OnPlayerSpawn(playerid)
{
new query[120];
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e'", PlayerNameGet(playerid));
mysql_tquery(mysql, query, "LoadVehicle", "i", playerid);
return 1;
}

forward LoadVehicle(playerid);
public LoadVehicle(playerid)
{
  new vehicleid;
 PVeh[vehicleid][VehModel] = cache_get_field_content_int(0, "VehModel");
 PVeh[vehicleid][VehDestroyed] = cache_get_field_content_int(0, "VehDestroyed");
 PVeh[vehicleid][VehFuel] = cache_get_field_content_int(0, "VehFuel");
 PVeh[vehicleid][VehHealth] = cache_get_field_content_float(0, "VehHealth");
 PVeh[vehicleid][VehX] = cache_get_field_content_float(0, "VehX");
 PVeh[vehicleid][VehY] = cache_get_field_content_float(0, "VehY");
 PVeh[vehicleid][VehZ] = cache_get_field_content_float(0, "VehZ");
 PVeh[vehicleid][VehA] = cache_get_field_content_float(0, "VehA");
 
printf("Health %.2f",PVeh[vehicleid][VehHealth]);

 vehicleid = CreateVehicle(PVeh[playerid][VehModel],PVeh[playerid][VehX], PVeh[playerid][VehY], PVeh[playerid][VehZ],PVeh[playerid][VehA],-1,-1,-1);
 printf("Veh health : %.2f", PVeh[vehicleid][VehHealth]);
}
I get printed
"Health : 1000"
"Veh health : 0"
Picture from database :



Re: Can't get float value mysql - SyS - 27.02.2016

u did'nt set the matrix as float


Re: Can't get float value mysql - Runn3R - 27.02.2016

Check your mysql_log.


Re: Can't get float value mysql - Aa12 - 27.02.2016

Ok, so I noticed 1 thing. I haven't post full code at first because I though it was unnecessary

Код:
new vehicleid;
 PVeh[vehicleid][VehModel] = cache_get_field_content_int(0, "VehModel");
 PVeh[vehicleid][VehDestroyed] = cache_get_field_content_int(0, "VehDestroyed");
 PVeh[vehicleid][VehFuel] = cache_get_field_content_int(0, "VehFuel");
 PVeh[vehicleid][VehHealth] = cache_get_field_content_float(0, "VehHealth");
 PVeh[vehicleid][VehX] = cache_get_field_content_float(0, "VehX");
 PVeh[vehicleid][VehY] = cache_get_field_content_float(0, "VehY");
 PVeh[vehicleid][VehZ] = cache_get_field_content_float(0, "VehZ");
 PVeh[vehicleid][VehA] = cache_get_field_content_float(0, "VehA");
 
printf("Health %.2f",PVeh[vehicleid][VehHealth]);

 vehicleid = CreateVehicle(PVeh[playerid][VehModel],PVeh[playerid][VehX], PVeh[playerid][VehY], PVeh[playerid][VehZ],PVeh[playerid][VehA],-1,-1,-1);
 printf("Veh health : %.2f", PVeh[vehicleid][VehHealth]);
And I get printed

Health 1000.00
Veh health : 0.00

So it gets VehHealth fine but it becomes 0 after creating vehicle


Re: Can't get float value mysql - Runn3R - 27.02.2016

Where do you change your Veh health?

Have you checked your mysql_log yet?


Re: Can't get float value mysql - Aa12 - 27.02.2016

Quote:
Originally Posted by Runn3R
Посмотреть сообщение
Where do you change your Veh health?

Have you checked your mysql_log yet?
Why would I check mysql_log?
I change vehicle health after vehicle has been created


Re: Can't get float value mysql - Aa12 - 27.02.2016

Okay so I fixed VehHealth by using cache_get_andsoon function after creating vehicle. But now I can't get other Vehicle stats

mysql log :

Код:
[20:03:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "VehOwned", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehOwned", data: "1"
[20:03:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "VehModel", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehModel", data: "468"
[20:03:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "VehDestroyed", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehDestroyed", data: "0"
[20:03:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "VehFuel", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehFuel", data: "100"
[20:03:03] [DEBUG] cache_get_field_content_float - row: 0, field_name: "VehX", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehX", data: "193.531"
[20:03:03] [DEBUG] cache_get_field_content_float - row: 0, field_name: "VehY", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehY", data: "1918.18"
[20:03:03] [DEBUG] cache_get_field_content_float - row: 0, field_name: "VehZ", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehZ", data: "17.641"
[20:03:03] [DEBUG] cache_get_field_content_float - row: 0, field_name: "VehA", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehA", data: "0"
[20:03:03] [DEBUG] cache_get_field_content_float - row: 0, field_name: "VehHealth", connection: 1
[20:03:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "VehHealth", data: "500"
[20:03:03] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called