Jump to content

Vehicle Spawn Function Bugged


Recommended Posts

Hello, im creating the vehicles with this function in a team deathmatch gamemode:

function spawnTeamVeh(player, vehicleName) {
    let oldCar = player.data.teamVeh;
    if (oldCar) oldCar.destroy();
    let teamName = player.data.teamName;
    let teamVeh = mp.vehicles.new(mp.joaat(vehicleName), vehicleData[teamName].Location,
            locked: false, 
            heading: vehicleData[teamName].Heading,
            dimension: 0
    teamVeh.setColor(vehicleData[teamName].Color, vehicleData[teamName].Color);
    teamVeh.setMod(11, 3);
    teamVeh.setMod(12, 2);
    teamVeh.setMod(13, 2);
    teamVeh.setMod(15, 3);
    teamVeh.setMod(18, 0);
    setTimeout( () => {
        player.putIntoVehicle(teamVeh, 0);
        }, 200);        
    player.data.teamVeh = teamVeh;

When im solo or we are 2-3 players cars work fine but with 5-10 players cars start bugging, like one player spawns a car and makes another car teleport to their location, or sometimes teleport to random locations.
How could I do the code to make it more efficient and avoid this type of bugs?(1.1)

Edited by fh237
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...