[Critical Bug]Vehicle data is messed up
#1

Some days ago my players are reporting that their private vehicles are being messed up. When they use a command to pull/spawn their vehicle, sometimes they will get another vehicle, or other players' private vehicles. Seems that the vehicle are messed up (and I've checked my code a few times and I can't find a bug there).

I did an experiment for this.
Firstly I spawn around 10 Dunes above a vehicle trampoline (with the "kmb_mine" object) by CreateVehicle.
Then they all fall down, lost their health and explode because of crashing the mines and other stuffs.
However, OnVehicleDeath is not called when they are on fire and even explode (I've used printf to debug the callback but nothing is printed).
Sometimes they will respawn after a few seconds, but sometimes it doesn't.

If they don't respawn after a few seconds, they will take a quite long time to disappear, and will not spawn again.
After that I use the same command to spawn a Dozer.
However, the weird thing is that the vehicle information shows that it is a Dune!

I used another command to check its information. The vehicle name, vehicle ID, and even vehicle model belongs to one of the disappeared Dunes.
However I see that bugged vehicle is a Dozer.

I only use the native GetPlayerVehicleID, GetVehicleModel and a custom CreateVehicle function, which is shown below:

pawn Код:
CreateVehicleToInteriorEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2, respawn_delay, interiorid, virtualworld, autogenplate = true, isgmveh = 0)
{
    new vehicleid = INVALID_VEHICLE_ID;
    switch(color1,color2)
    {
        case -1..255:
        {
            if(color1 == -1) color1 = random(187);
            if(color2 == -1) color2 = random(187);
            vehicleid = CreateVehicle(modelid,spawn_x,spawn_y,spawn_z,z_angle,color1,color2,respawn_delay);//As you can see, I'm using CreateVehicle, which is a native function
            vehcolor[0][vehicleid] = color1;
            vehcolor[1][vehicleid] = color2;
        }
        default:
        {
            new col1 = random(187),col2 = random(187);
            vehicleid = CreateVehicle(modelid,spawn_x,spawn_y,spawn_z,z_angle,col1,col2,respawn_delay);
            vehcolor[0][vehicleid] = col1;
            vehcolor[1][vehicleid] = col2;
        }
    }
    LinkVehicleToInterior(vehicleid,interiorid);
    SetVehicleVirtualWorld(vehicleid,virtualworld);
    ChangeVehiclePaintjob(vehicleid,3);
    Iter_Add(Vehicles,vehicleid);
    //Some code here
    KillTimer(entercartimer[vehicleid]);
    switch(modelid)
    {
        case 417,425,430,446,447,452,453,454,460,469,472,473,476,484,487,488,493,497,511,512,513,519,520,537,538,548,553,563,569,570,577,590,592,593,595: {}
        case 407,416,427,432,433,490,523,528,544,596..599,601:
        {
            if(autogenplate)
            {
                //Code to generate a random number plate
            }
        }
        case 441,449,464,465,501,564,594: Iter_Add(TramRC,vehicleid);
        default:
        {
            if(autogenplate)
            {
                //Code to generate a random number plate
            }
        }
    }
    if(isgmveh < 2) SetVehicleParamsEx(vehicleid,-1,-1,0,0,0,0,0);
    return vehicleid;
}
In the attachments, the first and the second picture is showing that both information from command and OnPlayerStateChange tell it is a Dune, while the third one is what it shows without bug (to prove that it is not a scripting bug).

It's critical, because a corrupts vehicle systems, and even messes a car up with aircraft, which may be recognised as using a flying cheat while actually the drivers are not.

Edit:
Donya has also confirmed the problem: http://forum.sa-mp.com/showpost.php?...&postcount=172
His players found that there're two debug labels on the same vehicle, one is the vehicle itself while the other one is the vehicle which is mixed with the original vehicle. http://oi56.tinypic.com/14cwv3s.jpg

Just to add, I've noticed this bug since 0.3b, but I can't find the cause before doing this test.
There's also some other easy ways to destroy the vehicles so as to reproduce the problem, like pushing some vehicles into the water or flipping them upside down with forklift and sawn-off shotgun.

Edit 2:
I made a video to explain the problem:
[ame]http://www.youtube.com/watch?v=vZhWj3nb3Ms[/ame]
Reply
#2

Yeah, i hope they fix this in one of the next versions
Reply
#3

Unsure if I'm meant to post if I haven't experienced this kind of problem, strange really when the server I script is heavily dependant on vehicles.

From looking at the interesting video bug, the problem developes when the vehicles respawn. I know you said it isn't a scripting bug, but maybe show your OnVehicleSpawn() code.

Also, how long have you been using Itter_Add()?

Quote:
Originally Posted by [HLF]Southclaw
if one is destroyed for example and someone tries to teleport it
Are you checking the vehicles owner, while destroying?
DestroyVehicle(thisvehicleid);
When the player teleports to PutPlayerInVehicle(playerid, thisvehicleid, 0), is thisvehicleidid removed from the players private vehicle id. If not, the next CreateVehicle() will take thisvehicleid, thus giving the player the wrong vehicle. Even better, as you said no vehicle at all, if no vehicle was newly created, he wouldn't get a vehicle.

Sorry for trying to answer your bug with scripting solutions, but 9/10 it is a scripting issue.
Reply
#4

Quote:
Originally Posted by leong124
Посмотреть сообщение
Edit:
Donya has also confirmed the problem: http://forum.sa-mp.com/showpost.php?...&postcount=172
His players found that there're two debug labels on the same vehicle, one is the vehicle itself while the other one is the vehicle which is mixed with the original vehicle. http://oi56.tinypic.com/14cwv3s.jpg

Just to add, I've noticed this bug since 0.3b, but I can't find the cause before doing this test.
There's also some other easy ways to destroy the vehicles so as to reproduce the problem, like pushing some vehicles into the water or flipping them upside down with forklift and sawn-off shotgun.
Explain this? @ Rac3r

2 /dl readings on 1 vehicle...
Reply
#5

I have also experienced this problem, however I was able to patch the problem by adding multiple sanity checks to ensure the correct vehicle is spawned, and if it's not, then try respawning the vehicle again, and performing the same checks again, just in case. I've not seen a case of recursion there (as in, the whole thing just never ending, it usually fixes after a respawn) yet, and it usually patches the problem.
Reply
#6

Quote:
Originally Posted by Donya
Посмотреть сообщение
Explain this? @ Rac3r

2 /dl readings on 1 vehicle...
Yes, it is impossible to do that with ordinary functions that have no bugs.
Anyway I'll have a try on a bare script later.
Reply
#7

Quote:
Originally Posted by Donya
Посмотреть сообщение
Explain this? @ Rac3r

2 /dl readings on 1 vehicle...
I can't. Point taken, that's really feckin' weird!

Off topic: Didn't know you could have 2 variables in a switch statement!
Reply
#8

If you think that this is a sa-mp bug and not a problem in your script, you should provide a gamemode which can be used to reproduce this issue easily.
Reply
#9

Is there already something new?
Reply
#10

Quote:
Originally Posted by dugi
Посмотреть сообщение
If you think that this is a sa-mp bug and not a problem in your script, you should provide a gamemode which can be used to reproduce this issue easily.
I will do that ASAP. Thanks for your response (although it is a quite long time after the report).

Edit:
Finally I spent a few hours to make a gamemode that you can easily reproduce the problem. I've reproduced the problem with this and without any other filterscripts and plugins.
http://pastebin.com/e6BWZf5X

How to reproduce the problem:
  1. Click spawn and you'll be at the top of a trampoline.
  2. Turn on /dl so that you can check the /dl bug.
  3. Use /fallcar to spawn some vehicles (about 5 to 10 is enough) there. Spawn Dune(573) is suggested because it can easily be destroyed by the trampoline, i.e. type /v 573. If you aren't at the top of the trampoline, type /top.
  4. Wait for them to explode and rest at the bottom of the trampoline.
  5. Use /bottom to go to the bottom of it.
  6. Wait for them to disappear. If they don't, try the push them and wait for a while.
  7. Now use /v (model ID) to spawn a car. I used /v 486 (Dozer).
  8. You will find that there are 2 3D text labels at sPos and id.
  9. Use /info to check the vehicle data, they will be different to what you see in /dl. /info returns the data of a exploded dune.
  10. After using /removeallvehicle and /v to spawn another car, you will find that everything works fine.
If you can't reproduce the problem, try to wait for all the vehicles (dunes) to disappear, and then spawn a car (dozer). Otherwise, use /removeallvehicle and then try to do the test again.
Reply
#11

Confirmed (Via your tutorial).

EDIT: Seems OnVehicleDeath and OnVehicleSpawn arn't called for every vehicle. OnVehicleSpawn is only called when OnVehicleDeath is called.
Reply
#12

The bug also occurs with vehicles created by AddStaticVehicle.
Reply
#13

Im not 100% sure but I think if OnPlayerExitVehicle isnt called(when player teleports from the burning vehicle or left the server) the vehicle will not respawn, saw this many times on my server.

If you wanna test it go on the server, spawn vehicle, damage the vehicle and then type /Q (you must be in burning vehicle), then rejoin and the vehicle will be there where you left him.
Reply
#14

Judging by the way this has been explained god help Kalcor if he wants to fix it.

In short, what you're saying is, when an unoccupied vehicle explodes, the server doesn't properly recognise the "death" of the vehicle, and as a result when attempting to spawn another vehicle it's fetching an already preoccupied vehicle ID and thus clashing?

EDIT: I'm sure it would also be useful if the SA-MP version in which this issue is occurring was stated.
Reply
#15

Quote:
Originally Posted by Unknownich
Посмотреть сообщение
Im not 100% sure but I think if OnPlayerExitVehicle isnt called(when player teleports from the burning vehicle or left the server) the vehicle will not respawn, saw this many times on my server.

If you wanna test it go on the server, spawn vehicle, damage the vehicle and then type /Q (you must be in burning vehicle), then rejoin and the vehicle will be there where you left him.
I think what you mentioned is not related to this bug. Since you don't have to enter any vehicle to reproduce the bug (check my test script a few posts above), OnPlayerExitVehicle will never be called.

Quote:
Originally Posted by Jay_
Посмотреть сообщение
Judging by the way this has been explained god help Kalcor if he wants to fix it.

In short, what you're saying is, when an unoccupied vehicle explodes, the server doesn't properly recognise the "death" of the vehicle, and as a result when attempting to spawn another vehicle it's fetching an already preoccupied vehicle ID and thus clashing?

EDIT: I'm sure it would also be useful if the SA-MP version in which this issue is occurring was stated.
That's what I mean. My English is not well enough to explain the problem in short, so I talked about the reproduction of the bug.
I've noticed the bug when I play some servers with private car system for a very long time. It has been existing in 0.3b IIRC.
Reply
#16

This problem has been understood for a long time. The client vehicle ID and server vehicle ID can become desynced. Why? Because the server doesn't trust the client to report deaths of vehicles. Doing so would obviously allow players to destroy all vehicles on the server. The ID would be fixed when the vehicle restreams, which is fine for most servers since players are moving right around the map. It may not be fine for servers with small areas.

There are some potential solutions. But honestly, I haven't seen this bug in game often enough to think it's a high priority fix.
Reply
#17

Actually, it frequently occurs in freeroam servers which allow people to spawn their private vehicles by server script. I don't know how it will be desynced, but it usually mixes up 2 vehicle IDs in the same vehicle, making players getting the same vehicle when they use the command the pull their own vehicle.

For example, A and B have an infernus and a turismo respectively. When the bug occurs, the 2 vehicles' IDs will be mixed into the infernus (or turismo). When A tries to pull his car it is fine, but when B pulls his turismo, he will get the infernus and A will be forced to leave the car/ teleported to B, which is the problem.

Also, I remember a case that a truck was mixed up with a helicopter. When one of my player drive it, he see it as a helicopter, but the others see that it is a truck flying in the sky. This make people to think that the driver is a cheater and he was nearly banned before I found the cause. Such misjudgements made by this bug is a quite serious problem.

For the solutions, I think the ID of the dead vehicle reported by players shouldn't be reused until it is restreamed. However, such a solution may not work very well with servers that have 2000 vehicles. For those situations, the ID of the dead vehicles should be save at some other places, or behind the array of 2000 vehicles. MAX_VEHICLES could be increased to something like 2500 or 3000 to provide 500-1000 more spaces to store the dead vehicles' ID, and allow for-loops to loop through those vehicles. However the actual number the vehicles allowed should still be at 2000.

I hope that it could be fixed soon, because we're not willing to have more misjudgements to our players. For the workaround to the bug before it is being fixed/changed, I think respawning/ destroying and spawning the private cars before teleporting it to its owner may work.
Reply
#18

leong: Are you sure it's the same problem? The first problem you described by script has been around for a very long time, since SA-MP 0.1. There was a conscious decision made not to fix it because the problems caused by fixing it were potentially worse than the original problem.

I have never seen the problem Donya described with 2 /dl labels on the same vehicle. None of the SA-MP beta testers (which run some of the largest SA-MP servers) have reported this.

I'll have a look around for any obvious problems with IDs.
Reply
#19

Quote:
Originally Posted by leong124
Посмотреть сообщение
Actually, it frequently occurs in freeroam servers which allow people to spawn their private vehicles by server script...
This is true, but after I make vehicle respawner every 5 minutes I didnt saw this bug anymore, so, as Kalcor said is not "high priority fix", but I hope it will be fixed.

Here is the example video...

[ame]http://www.youtube.com/watch?v=kCAOwPic6k4[/ame]
Reply
#20

Quote:
Originally Posted by Kalcor
Посмотреть сообщение
I have never seen the problem Donya described with 2 /dl labels on the same vehicle. None of the SA-MP beta testers (which run some of the largest SA-MP servers) have reported this.
None of the SA-MP beta testers have reported it, but it has happened on there servers.

Look at the picture again, you'll obviously see it's CrazyBob's Cops And Robbers. The posts that I actually posted we're from his forum.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)