[MySQL BlueG R7]: Want to load id after insert
#1

Hey guys.
I'm currently using the MySQL R7 Plugin from BlueG and I have a fraction-vehicle system, so I'll be able to create fraction vehicles ingame and let them save and load, so the fraction leader can delete them or buy some vehicles if he wants.

But there's a little problem when I'll create the vehicles.
I save the database-ID of the vehicle (`id`, A_I is on) and when the vehicle get's created I have to save the id into my global variable. (fVehicle[fV][dbID])

But I really don't know how to get the new created id.

Here's a little preview how I've made the insertion.
pawn Код:
format(Query, sizeof(Query), "INSERT INTO `script_fvehicles` (`vehFraktion`, `modelid`, `vehPosX`, `vehPosY`, `vehPosZ`, `vehPosA`, `vehInterior`, `vehWorld`, `vehHealth`, `vehNumberPlate`, `vehPaintjob`, `vehPreis`, `vehColor1`, `vehColor2`, `vehNeonID`) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%f', '%s', '%d', '%d', '%d', '%d', '%d')",
            fVehicle[fV][vehFraktion], fVehicle[fV][modelid], fVehicle[fV][vehPosX], fVehicle[fV][vehPosY], fVehicle[fV][vehPosZ], fVehicle[fV][vehPosA], fVehicle[fV][vehInterior], fVehicle[fV][vehWorld], fVehicle[fV][vehHealth], fVehicle[fV][vehNumberPlate], fVehicle[fV][vehPaintjob], fVehicle[fV][vehPreis], fVehicle[fV][vehColor1], fVehicle[fV][vehColor2], fVehicle[fV][vehNeonID]);
            mysql_tquery(myCon, Query, "", "");
            SetVehicleToRespawn(fVehicle[fV][vehID]);
            Vehicle[fVehicle[fV][vehID]][vehFuel] = VehicleData[vehmodel-400][vehMaxTank];
            SaveFVehicles();
            return 1;
        }
    }
    return 1;
}
After "mysql_tquery([..])" I want to load the dbID, because I want to Save the vehicle directly to prevent mistakes.
But there I'll need the dbID.
So how can I load the dbID after the insertion DIRECTLY ?

Thank you very well.
If you don't understand anything, please tell it to me.
I'm from germany, and I'm not the best in english so there will be some mistakes in the language at me..
Reply
#2

Hah, one thread higher: http://forum.sa-mp.com/showthread.ph...23#post2921923
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)