Query problem -
TwinkiDaBoss - 04.12.2015
Okay so the problem is simple as it can be. The query will always insert FactionID as 0.
I printed the result
[pawn][23:22:43] INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`Po sY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,` FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,` Owned`,`VirtualWorld`,`Interior`,`FactionID`) VALUES ('0','411','0','0','1585.514','-1625.23','13.383','273.748','0','220000','1000','0 ','0','0.0',0,1,0,0,'0')[/php]
Code used
PHP код:
mysql_format(mysql, query, sizeof(query),"INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`PosY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,`FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,`Owned`,`VirtualWorld`,`Interior`,`FactionID`,`Locked`) VALUES ('%i','%i','%i','%i','%f','%f','%f','%f','%i','%i','%i','%i','%i','%f',0,1,0,0,'%i',0)",\
0,vid,0,0,Pos[0],Pos[1],Pos[2],Pos[3],0,GetVehiclePrice(vid),1000,0,0,0,0,0,0,0,AccInfo[playerid][PlayerFaction],0);
mysql_tquery(mysql, query, "OnVehicleCreation", "i", playerid);
Everything gets inserted correctly besides AccInfo[playerid][PlayerFaction], which always stores as 0. I printed out the AccInfo[playerid][PlayerFaction] and it gave me correct result
PHP код:
printf("%i faction ID || 2nd %i ",VehInfo[vehicleid][VehFaction],AccInfo[playerid][PlayerFaction]);
[23:22:43] 1 faction ID || 2nd 1
No errors inside the SQL log
Re: Query problem -
Abagail - 04.12.2015
Print the query. Also, integer values shouldn't be treated as strings. As such you don't need to wrap them in single quotes.
Re: Query problem -
TwinkiDaBoss - 04.12.2015
PHP код:
[23:22:43] INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`PosY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,`FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,`Owned`,`VirtualWorld`,`Interior`,`FactionID`) VALUES ('0','411','0','0','1585.514','-1625.23','13.383','273.748','0','220000','1000','0','0','0.0',0,1,0,0,'0')
This was before I added last parameter to it (locked) so dont mind missing 1 var in it
Re: Query problem -
Vince - 04.12.2015
What is "MasterID"? Is this set to auto increment? As far as I know when any of 0, NULL or DEFAULT are used the auto increment value is used. But since you're listing columns anyway that column can just be omitted from the list.
Re: Query problem -
TwinkiDaBoss - 04.12.2015
Quote:
Originally Posted by Vince
What is "MasterID"? Is this set to auto increment? As far as I know when any of 0, NULL or DEFAULT are used the auto increment value is used. But since you're listing columns anyway that column can just be omitted from the list.
|
Master ID represents player Account ID (instead of using name) but in this case, Im using this for faction vehicles therefore im leave the master ID to be 0.
SQL ID is
pawn Код:
VehInfo[vid][VID] = cache_insert_id();
Used OnVehicleCreation