2000 cells big array - 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: 2000 cells big array (
/showthread.php?tid=542860)
2000 cells big array -
Joey^ - 22.10.2014
I wanted to make an inventory system for every vehicle on the server. For that I would need an array big enough for every vehicle and that is a 2000 cells big array. So my question is: is there any better way of doing that?
Re: 2000 cells big array -
Pottus - 22.10.2014
Depends how many vehicles you really have and what kind of data you need to store.
Re: 2000 cells big array -
Joey^ - 22.10.2014
It should be a dynamic system where you can add any vehicle on the server and a player can automatically use inventory system for that vehicle.
Re: 2000 cells big array -
Pottus - 22.10.2014
Then you probably won't need 2000 vehicles I made a quick mock-up to give you an idea of what you will need to do.
pawn Код:
#define MAX_DYNAMIC_VEHICLES 1000
enum VEHICLEINFO
{
p_PlayerID,
p_CarVID,
p_CarModel,
Float:p_CarX,
Float:p_CarY,
Float:p_CarZ,
Float:p_CarFA,
}
static VehicleData[MAX_DYNAMIC_VEHICLES][VEHICLEINFO];
static Iterator:DynCars<MAX_DYNAMIC_VEHICLES>;
AddVehicle(playerid, model, Float:x, Float:y, Float:z, Float:fa)
{
new index = Iter_Free(DynCars);
if(index > -1)
{
Iter_Add(DynCars, index);
VehicleData[index][p_CarVID] = CreateVehicle(...);
VehicleData[index][p_CarModel] = model;
VehicleData[index][p_CarX] = x;
VehicleData[index][p_CarY] = y;
VehicleData[index][p_CarZ] = z;
VehicleData[index][p_CarFA] = fa;
return index;
}
print("AddVehicle::Tried to add too many vehicles");
return -1;
}
RemoveVehicle(index)
{
if(Iter_Contains(DynCars, index))
{
new next;
Iter_SafeRemove(DynCars, index, next);
return next;
}
print("RemoveVehicle::Tried to remove a vehicle that does not exist");
return -1;
}
Re: 2000 cells big array -
Joey^ - 22.10.2014
Yeah, I thought something like that as well. But I thought it could be made with less than 1000 cells, but it can't. Thanks for the help.