Getting Mysql ID of new vehicle? - 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: Getting Mysql ID of new vehicle? (
/showthread.php?tid=316764)
Getting Mysql ID of new vehicle? -
Dokins - 08.02.2012
Basically, I need to get the ID of this newly created vehicle that I've inserted into MySQL that way I can set the player's vehicle owned to the ID of the vehicle in this table.
pawn Код:
new query[550];
format(query, sizeof(query), "INSERT INTO `vehicles` (VehModel, VehOwner, VehSpawnX, VehSpawnY, VehSpawnZ,VehSpawnAngle, VehColour1, VehColour2, VehFuel, VehPlate, VehWep1,VehWepA1,VehWep2,VehWepA2, VehCash, VehArmour, VehFaction, VehFRank, VehOwned, VehFactioned) VALUES (%d, '%s', -199.5428,1224.1710,19.5659,180.0,%d,%d,%d,'%s',0,0,0,0,0,0,0,0,1,0)",model, GetName(playerid),colour1, colour2, VehFuel[vehicleid], string);
mysql_query(query);
I need the ID so I can do this:
pawn Код:
if(VehicleSlot1[playerid] == 0)
{
VehicleSlot1[playerid] = VehicleSQLID[vehicleid];
MySQL_SetInteger(PlayerSQLID[playerid], "VehSlot1", VehicleSQLID[vehicleid], "accounts");
}
else if(VehicleSlot2[playerid] == 0)
{
VehicleSlot2[playerid] = VehicleSQLID[vehicleid];
MySQL_SetInteger(PlayerSQLID[playerid], "VehSlot2", VehicleSQLID[vehicleid], "accounts");
}
else if(VehicleSlot3[playerid] == 0)
{
VehicleSlot3[playerid] = VehicleSQLID[vehicleid];
MySQL_SetInteger(PlayerSQLID[playerid], "VehSlot3", VehicleSQLID[vehicleid], "accounts");
}
Re: Getting Mysql ID of new vehicle? -
Vince - 08.02.2012
Didn't I already tell you in another topic to use
mysql_insert_id() ?
Re: Getting Mysql ID of new vehicle? -
Dokins - 08.02.2012
I don't think so, otherwise I apologise, I'll have a look at the SYNTAX of it, thanks, I'll get back to you in a few minutes.