Undetectable bug? (Vehicle system - Car ID's - Won't despawn correctly)
#4

I have rescripted the vehicle system;

SpawnPlayerVehicle is a function I call in all places where there is a player-vehicle spawned (to avoid car spam)

PHP код:
stock SpawnPlayerVehicle(playeridvehicleidFloat:x,Float:y,Float:z,Float:anglecolor1313,color2323respawn = -1,putinvehicle)
{
    
#pragma unused respawn
    
if(IsValidVehicle(AccInfo[playerid][SpawnedCarID]))
    {
 
        
printf("SpawnPlayerVehicle: Old spawned car ID = %d  BY Playerid = %d (Destroyed)",AccInfo[playerid][SpawnedCarID],playerid);
        
DestroyVehicle(AccInfo[playerid][SpawnedCarID]);
        
AccInfo[playerid][SpawnedCarID] = -1;
    }
 
    
AccInfo[playerid][SpawnedCarID] = CreateVehicle(vehicleidx,y,zanglecolor1313color2323240);
    
printf("SpawnPlayerVehicle: New spawned car ID = %d  BY Playerid = %d (Created)",AccInfo[playerid][SpawnedCarID],playerid);
    if(
AccInfo[playerid][SpawnedCarID] == 255)
    {
        print(
"IT WAS Vehicle ID 255, was sent to hell (World 255)");
        
SetVehicleVirtualWorld(255255);
        
AccInfo[playerid][SpawnedCarID] = CreateVehicle(vehicleidx,y,zanglecolor1313color2323240);
        
printf("SpawnPlayerVehicle: New spawned car ID = %d  BY Playerid = %d (Created)",AccInfo[playerid][SpawnedCarID],playerid);
        if(!
IsPlayerInRace[playerid])
            
putinvehicle 0;
    }
    if(
AccInfo[playerid][SpawnedCarID] == 255)
    {
        print(
"IT WAS Vehicle ID 255, was sent to hell AGAIN (World 255)\nFATAL ERROR VEHICLE 255 !!!!");
        
SetVehicleVirtualWorld(255255);
        return 
scm(playeridred"An Error Occured. Please contact one of the scripters! (Vehicle 255)");
    }
    
SetVehicleVirtualWorld(AccInfo[playerid][SpawnedCarID], GetPlayerVirtualWorld(playerid));
    
LinkVehicleToInterior(AccInfo[playerid][SpawnedCarID], GetPlayerInterior(playerid));
    if(
putinvehicle == 1)
    {
        
PutPlayerInVehicle(playeridAccInfo[playerid][SpawnedCarID], 0);
    }
    return 
1;

However, it did also end up with:

Код:
//here is the paste from my log, first occurrence in the i could find, appears randomly from /carmenu
 
[15:07:36] SpawnPlayerVehicle: Old spawned car ID = 470  BY Playerid = 6 (Destroyed)
[15:07:36] SpawnPlayerVehicle: New spawned car ID = 255  BY Playerid = 6 (Created)
[15:07:36] IT WAS Vehicle ID 255, was sent to hell (World 255) //I set the Virtual world of the vehicle, and tries to spawn a new one, as a temporary "patch".
[15:07:36] SpawnPlayerVehicle: New spawned car ID = 456  BY Playerid = 6 (Created)
But, i got help on the scripting channel, where they told me to redifine the destroyvehicle and createvehicle functions, so i did (in order to log)

PHP код:
#undef CreateVehicle
#undef DestroyVehicle
stock Log_CreateVehicle(vehicletype,Float:x,Float:y,Float:z,Float:rotation,color1,color2,respawn_delay) {
        new 
vehicleid CreateVehicle(vehicletype,x,y,z,rotation,color1,color2,respawn_delay);
        
printf("CreateVehicle(%d,%f,%f,%f,%f,%d,%d,%d) = %d",vehicletype,x,y,z,rotation,color1,color2,respawn_delay,vehicleid);
        return 
vehicleid;
}
#define CreateVehicle Log_CreateVehicle
stock Log_DestroyVehicle(vehicleid)
{
    if(!
IsValidVehicle(vehicleid))
        return 
0;
    else
    {
        
printf("><>><><><<<<<>><  DestroyVehicle(%d) >><<<<>><<><<<<<><>>"vehicleid);
        
DestroyVehicle(vehicleid);
        return 
1;
    }
}
#define DestroyVehicle Log_DestroyVehicle 
But, still i end up with this:

Код:
[18:47:49] SpawnPlayerVehicle: Old spawned car ID = 458  BY Playerid = 1 (Destroyed)
[18:47:49] ><>><><><<<<<>><  DestroyVehicle(458) >><<<<>><<><<<<<><>>
[18:47:49] CreateVehicle(444,1807.247070,-1297.331298,132.105606,0.000000,-1,-1,240) = 255
[18:47:49] SpawnPlayerVehicle: New spawned car ID = 255  BY Playerid = 1 (Created)
[18:47:49] IT WAS Vehicle ID 255, was sent to hell (World 255)
[18:47:49] CreateVehicle(444,1807.247070,-1297.331298,132.105606,0.000000,-1,-1,240) = 458
[18:47:49] SpawnPlayerVehicle: New spawned car ID = 458  BY Playerid = 1 (Created)
As you can see, there nothing wrong happening, besides that 255...
Why is the vehicle id returned as to be 255, and mess up the entire vehicle system?

Any suggestions what to do further?
Thanks
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)