Multiple Cars per 'Character' - 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: Multiple Cars per 'Character' (
/showthread.php?tid=554608)
Multiple Cars per 'Character' -
JonathanW - 04.01.2015
Title says it all. The gamemode I'm developing has a Masteraccount and characters integrated with it. So, Yeah well. I need multiple Vehicles Per Character. I'll start step by step.
The define having the Maximum car Slots Per character.
The Enumerator having all the vehicles within Characters.
pawn Код:
enum OwnedCarSlot
{
id,
bool:loaded
}
new OwnedVehicle[MAX_PLAYERS][MAX_CARSLOTS][OwnedCarSlot];
So, After the Player has Chosen a character and Spawned. The System is supposed to spawn All The 3 Vehicles owned by him. Using this.
pawn Код:
mysql_format(handle, query, sizeof(query), "SELECT * FROM `Vehicles` WHERE `vOwner`='%e'", name);
mysql_tquery(handle, query, "SpawnPlayerVehicle", "i", playerid);
under SpawnPlayervehicle(playerid), I'm spawning the vehicles loaded at Loadvehicle. i.e Above ^
pawn Код:
new rows, fields;
cache_get_data(rows, fields);
if(rows) //If the player was found when LoadVehicle() was called
{
for(new i; i != MAX_CARSLOTS-1; i++) //-1 because 0 ,1, 2;
{
// Spawn the vehicle here.....
// What am I supposed to do here? It creates the vehicles, but I need help assigning them to the enum I mentioned above.
//After getting the cache,
VehicleInfo[playerid][vActualID] = CreateVehicle(VehicleInfo[playerid][vModel], VehicleInfo[playerid][vX], VehicleInfo[playerid][vY], VehicleInfo[playerid][vZ], VehicleInfo[playerid][vA], VehicleInfo[playerid][vColor1], VehicleInfo[playerid][vColor2], -1);
Re: Multiple Cars per 'Character' -
JonathanW - 04.01.2015
Dang.
Re: Multiple Cars per 'Character' -
Lordzy - 04.01.2015
Simply do a loop through the number of rows retrieved and assign the arrays.
pawn Код:
//Once the data is retrieved, loop through the rows:
for(new i = 0; i< rows i++)
{
VehicleInfo[playerid][i][id] = CreateVehicle(...); // I assume "id" is supposed to store the vehicle ID, so store it.
VehicleInfo[playerid][i][loaded] = true; //Once if things are done, set "loaded" boolean to true.
}