Loading owners name MYSQL -
Blademaster680 - 03.07.2014
How can I load the owner's name of the vehicle as a string? So when someone gets into the car it will display the owner's name?
I have tried this way, but when I get into the vehicle it displays the name as '0'... Why?
here is the code:
Код:
Load_Vehicles()
{
new count;
new Query[512], savestr[50], rows, fields;
for(new i=1; i < MAX_DVEHICLES; i++)
{
mysql_format(dbHandle,Query, sizeof(Query), "SELECT * FROM `Vehicles` WHERE `ID` = '%d'", i);
mysql_query(dbHandle,Query);
cache_get_data(rows, fields);
if(rows)
{
cache_get_field_content(0, "ID", savestr); vInfo[i][vID] = strval(savestr);
cache_get_field_content(0, "Owner", vInfo[i][vOwner]);
cache_get_field_content(0, "Model", savestr); vInfo[i][vModel] = strval(savestr);
cache_get_field_content(0, "PosX", savestr); vInfo[i][Pos][vX] = floatstr(savestr);
cache_get_field_content(0, "PosY", savestr); vInfo[i][Pos][vY] = floatstr(savestr);
cache_get_field_content(0, "PosZ", savestr); vInfo[i][Pos][vZ] = floatstr(savestr);
cache_get_field_content(0, "PosA", savestr); vInfo[i][Pos][vR] = floatstr(savestr);
cache_get_field_content(0, "Color1", savestr); vInfo[i][vColor1] = strval(savestr);
cache_get_field_content(0, "Color2", savestr); vInfo[i][vColor2] = strval(savestr);
count++;
}
AddStaticVehicleEx(vInfo[i][vModel], vInfo[i][Pos][vX], vInfo[i][Pos][vY], vInfo[i][Pos][vZ], vInfo[i][Pos][vR], vInfo[i][vColor1], vInfo[i][vColor2], 60000);
}
printf("Loaded %d vehicles", count);
}
Re : Loading owners name MYSQL -
iLegendary - 03.07.2014
Try
cache_get_field_content(0, "Owner", savestr);
format(vInfo[i][vOwner], 32,savestr);
Re: Loading owners name MYSQL -
Blademaster680 - 03.07.2014
Nope still when I get into the car I am using this:
Код:
new str[128];
format(str, sizeof(str), "Vehicle Owner: %d %s", vInfo[vehicleid][vOwner], vInfo[vehicleid][vOwner]);
SendClientMessage(playerid, -1, str);
I am using %d just to test, but the %s isnt displaying anything... the %d is still displaying '0' though...
AW: Loading owners name MYSQL -
rospar - 03.07.2014
Код:
format(str, sizeof(str), "Vehicle Owner: %d %s", vInfo[vehicleid][vOwner], vInfo[vehicleid][vOwner]);
why the same variable ?
did you want to do it that way?
Код:
format(str, sizeof(str), "Vehicle Owner: %d %s",vehicleid, vInfo[vehicleid][vOwner]);
Re: Loading owners name MYSQL -
Blademaster680 - 03.07.2014
Yeah same variable. just using both as a test, so I can see what its loading, and it seems to be loading as an integer I think, and need it to load as a string.

.
Anyone that can help?
AW: Loading owners name MYSQL -
rospar - 03.07.2014
which mysql plugin version your are using ?
Re: Loading owners name MYSQL -
Blademaster680 - 04.07.2014
R33 BlueG's I think
Re: Loading owners name MYSQL -
Blademaster680 - 04.07.2014
Got it working

thanks everyone for the help