Saving Vehicle Modifications
#1

So the way I'm saving vehicle modifications is by the player enum. It's set up to have 13 different arrays in the enum and they're multi dimensional arrays so each array supports up to MAX_PLAYER_VEHICLES, which is currently defined as 5.

CarMod0[MAX_PLAYER_VEHICLES],
CarMod1[MAX_PLAYER_VEHICLES]
etc, etc.

So when the player mods their vehicle, instead of grabbing the component and doing if then or even switch statements I've decided just to make a function that will just save all their vehicle modifications at once. I know, not the most efficient thing in the world, but meh.

Here is where that function is used:
PHP код:
public OnVehicleMod(playeridvehicleidcomponentid)
{
    if(
IsPlayersVehicle(playeridGetPlayerVehicleID(playerid)))
    {
        
GetPlayerCarMods(playerid);
    }
    return 
1;

Here is "GetPlayerCarMods"
PHP код:
GetPlayerCarMods(playerid)
{
    for(new 
iMAX_PLAYER_VEHICLESi++) 
    {
        
Player[playerid][CarMod0][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 0);
        
Player[playerid][CarMod1][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 1);
        
Player[playerid][CarMod2][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 2);
        
Player[playerid][CarMod3][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 3);
        
Player[playerid][CarMod4][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 4);
        
Player[playerid][CarMod5][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 5);
        
Player[playerid][CarMod6][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 6);
        
Player[playerid][CarMod7][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 7);
        
Player[playerid][CarMod8][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 8);
        
Player[playerid][CarMod9][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 9);
        
Player[playerid][CarMod10][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 10);
        
Player[playerid][CarMod11][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 11);
        
Player[playerid][CarMod12][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 12);
        
Player[playerid][CarMod13][i] = GetVehicleComponentInSlot(Player[playerid][CarID][i], 13);
        
printf("%d|%d|%d"Player[playerid][CarMod5][i], GetVehicleComponentInSlot(Player[playerid][CarID][i], 5), Player[playerid][CarID][i]);
    }
    return 
1;

I started to test this by adding nitro which is slot 5, so I decided to add a print at the bottom for the ID that's stored in CarMod5, and the GetVehicleComponentInSlot for that vehicle in slot 5. Both of these output 0 in the log. Finally, I added a check for the car ID itself and it is the car ID in game.

Am I doing something wrong?
Reply


Messages In This Thread
Saving Vehicle Modifications - by BornHuman - 03.06.2016, 16:49
Re: Saving Vehicle Modifications - by Onfroi - 03.06.2016, 17:26
Re: Saving Vehicle Modifications - by Vince - 03.06.2016, 19:58

Forum Jump:


Users browsing this thread: 1 Guest(s)