Vehicle Issues
#1

Hello there SA-MP forum.

I'm currently having a few issues with vehicles on my server. Peoples' vehicle IDs are mixing with each other and duplicate vehicles seem to be spawning.

The code below is from a function, I've only grabbed one if statement as all the rest are the same (just with different variables).

pawn Код:
if( Player[playerid][PlayerCarModel2] >= 1 )
            {
              if( Player[playerid][Car2LinkID] >= 1 )
              {
                DestroyVehicle( Player[playerid][Car2LinkID] );
                Player[playerid][Car2LinkID] = 0;
              }
             
                  CarCount++;
                  OwnedCarCount++;
                  Player[playerid][Car2LinkID] = CreateVehicle( Player[playerid][PlayerCarModel2], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z], Player[playerid][Car2ZAngle], Player[playerid][Car2Col1], Player[playerid][Car2Col2], -1);

                    if( GetVehicleModel( Player[playerid][Car2LinkID] ) != Player[playerid][PlayerCarModel2] )
                    {
                DestroyVehicle( Player[playerid][Car2LinkID] );
                Player[playerid][Car2LinkID] = 0;
                      Player[playerid][Car2LinkID] = CreateVehicle( Player[playerid][PlayerCarModel2], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z], Player[playerid][Car2ZAngle], Player[playerid][Car2Col1], Player[playerid][Car2Col2], -1 );
                    }

                  ChangeVehiclePaintjob( Player[playerid][Car2LinkID], Player[playerid][Car2PaintJobID] );

                    if( Player[playerid][Car2OwnedCarModSlot0] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot0]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot1] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot1]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot2] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot2]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot3] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot3]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot4] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot4]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot5] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot5]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot6] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot6]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot7] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot7]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot9] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot9]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot10] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot10]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot11] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot11]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot12] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot12]);
                  }

                    if( Player[playerid][Car2OwnedCarModSlot13] > 0 )
                  {
                    AddVehicleComponent( Player[playerid][Car2LinkID], Player[playerid][Car2OwnedCarModSlot13]);
                  }
            }
Each player has 6 vehicle slots, for some reason slots 2, 3, 4, 5 and 6 get bugged. I haven't seen any issues with slot 1.

If I recall, people used to add -1 to vehicle IDs, I can't remember why.... help please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)