Vehicle IDs cross
#1

Sometimes, the ID certain vehicles cross, and they end up taking eachothers properties. I made it to create all vehicles, dispite if they exist, and then delete those vehicles if they're not supposed to exist. Which works when the server starts.

pawn Код:
if(vInfo[vid][Model] == 0 && vid != 0)
    {
        vid = CreateVehicle(400, 1529.6, -1691.2, 13.3, 0, 0, 0, -1);
        SetVehicleVirtualWorld(vid, 9929);
        return 1;
    }
After they are all loaded:

pawn Код:
public DelCars()
{
    for(new i; i<MAX_VEHICLES; i++)
    {
        if(GetVehicleVirtualWorld(i) == 9929) DestroyVehicle(i);
    }
    return 1;
}
Now, i'm sure there is a better way to handle that, besides creating and removing. But anyhow, it seems that the odd time, ids will swap. For example, there was a vehicle with model 490, that ended up as a freeway.

I think it might happen on vehicle park.

pawn Код:
CMD:vpark(playerid, params[])
{
    if(GetPlayerState(playerid) == 2)
     {
        new vid = GetPlayerVehicleID(playerid);
        if(strmatch(vInfo[vid][Owner], pInfo[playerid][Name]))
         {
            new Float:X, Float:Y, Float:Z, Float:A;
            GetVehiclePos(vid, X, Y, Z);
            GetVehicleZAngle(vid, A);
            if(X == 1529.6 && Y == -1691.2 && Z == 13.3) return ErrorMessage(playerid, "You cannot park your vehicle here.");
            vInfo[vid][SpawnX] = X;
            vInfo[vid][SpawnY] = Y;
            vInfo[vid][SpawnZ] = Z;
            vInfo[vid][SpawnA] = A;
            vInfo[vid][SpawnVW] = GetPlayerVirtualWorld(playerid);
            vInfo[vid][SpawnInt] = GetPlayerInterior(playerid);

            DestroyVehicle(vid);

            vid = CreateVehicle(vInfo[vid][Model], vInfo[vid][SpawnX], vInfo[vid][SpawnY], vInfo[vid][SpawnZ], vInfo[vid][SpawnA], vInfo[vid][Col1], vInfo[vid][Col2], -1);
            LinkVehicleToInterior(vid, vInfo[vid][SpawnInt]);
            SetVehicleVirtualWorld(vid, vInfo[vid][SpawnVW]);

            SetVehicleParamsEx(vid, 0, 0, 0, 1, 0, 0, 0);

            SaveVehicle(vid);
           
            return 1;
           }
    }
    return 1;
}
Reason being is, if vehicle ID 3 was deleted, then if you park vehicle id 5, it will take id 3, and therefore save to id 3. Is there a way to force a vehicle to have the proper id?
Reply


Messages In This Thread
Vehicle IDs cross - by TakeiT - 24.01.2015, 16:37
Re: Vehicle IDs cross - by Dignity - 24.01.2015, 16:41
Re: Vehicle IDs cross - by PowerPC603 - 24.01.2015, 17:20
Re: Vehicle IDs cross - by TakeiT - 25.01.2015, 13:56

Forum Jump:


Users browsing this thread: 1 Guest(s)