Getting Mysql ID of new vehicle?
#1

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");
            }
Reply
#2

Didn't I already tell you in another topic to use mysql_insert_id() ?
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)