Vehicles despawning randomly
#1

After a uptime of 1-2 days the vehicles on my server begins to despawn short after you create them with CreateVehicle. It also seems, that when creating them the vehicle, someone else's despawns.
I got a /v command which lets you create a vehicle per player.

I'm handling the vehicles via variables, so when someone creates a vehicle the old one gets destroyed.
I'm also using number plates...

respawn_delay is -1 in all cases
Reply
#2

This happens a lot on my server, basically you need to do checks under OnPlayerDisconnect and under the command /v. For example:

pawn Код:
CMD:v(playerid, params[])
{
    //Whatever you have here
    if(PlayerCar[playerid] != -1) //If they have a car spawned
    {
        DestroyVehicle(PlayerCar[playerid]); //Destroy the car they have spawned
        PlayerCar[playerid] = -1; //Reset for debugging purposes
    }
    PlayerCar[playerid] = CreateVehicle(...
    //Code continues...
}
Same on Onplayerdisconnect...
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(PlayerCar[playerid] != -1)
    {
        DestroyVehicle(PlayerCar[playerid]);
        PlayerCar[playerid] = -1;
    }
    return 1;
}
Also make sure you reset the variable to an INVALID_VEHICLE_ID OnPlayerConnect.
Reply
#3

Of course im doing all of this, also setting the var to -1 at OnPlayerConnect.
Reply
#4

Can you show your v command? :S
Reply
#5

its not because of that, they also despawn in derby and races ....
Reply
#6

...then show ALL your DestroyVehicle lines in your entire script+filterscript(s).
it looks like a memory leak, caused by variables not being reset, or maybe an array/pointer problem (using wrong variables in the vehicle array, like vehicle[id] instead vehicleid[playerid]. this can happen anytime when using variables as pointers in array cells.
Reply
#7

I check them all once again but found nothing
Also crashdetect doesnt print any warnings.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)