09.07.2011, 13:29
(
Последний раз редактировалось leong124; 26.11.2011 в 16:13.
)
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:
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]
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;
}
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]