Way to save vehicle info - 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: Way to save vehicle info (
/showthread.php?tid=634498)
Way to save vehicle info -
iBots - 20.05.2017
Alright so i am making a system that allows you to put things in a vehicle's trunk, I want this option available to all of the vehicles not only the owned cars so i want a way to be able to save it to each vehicle.
So i made the variables and stuff, And i cant use like the id of the car that is saved to a players data, because it is different than the vehicle id ingame and it doesnt allow me to save to all of the vehicles, by saying save i mean saving and loading for saved vehicles but for the non owned vehicles it just saves in game not in data, so if a restart occurs they all are reset.
So how can i be able to save all of the cars.should i use the vehicle id like
pawn Код:
Vehiclestuff[vehicle id ingame][....]
or is there any better way because using the vehicle id might make problems because it changes in some cases.
Re: Way to save vehicle info -
Kane - 20.05.2017
If you're creating vehicles into files, you need to grab the file ID and the in game ID in the file. That's how I do it at least and it works fine for saving, loading items like that. Example:
PHP код:
#define MAX_DYNAMIC_VEHICLES 1000
enum DynamicVehicles
{
vehicleID, // File ID.
vehicleIG // Ingame ID.
};
new FacVehicleData[MAX_DYNAMIC_VEHICLES][DynamicVehicles];
And an example of what I've done:
PHP код:
new vehicle = GetPlayerVehicleID(playerid), carid = IsFactionVehicle(vehicle);
if(carid != -1 && FacVehicleData[carid][vehicleFaction] > 0 && FacVehicleData[carid][vehicleCopGuns] && PlayerData[playerid][pFaction] == FacVehicleData[carid][vehicleFaction])
{
ShowPlayerDialog(playerid, DIALOG_USE, DIALOG_STYLE_LIST, title, string, "Ok", "");
}