Car Spawning Bug - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car Spawning Bug (
/showthread.php?tid=263757)
Car Spawning Bug -
ScottCFR - 23.06.2011
There's a weird bug in my server when you spawn a car or an admin spawns a car. There are two different commands as I only allow players to spawn NRGs. But, when a player dies it'll wipe out all the NRGs also happens when a player leaves. Admins can only spawn one car at a time. If one admin spawns a car, then another, it will delete the car the first admin spawned. I use "pCar[playerid]" to keep track of vehicle IDs. It seems it spawns a car with "pCar[playerid]" but playerid being plain text.
Код:
// Command
COMMAND:nrg(playerid, params[])
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
Destroy(pCar[playerid]);
pCar[playerid] = CreateVehicle(522, X, Y, Z, A, -1, -1, -1);
LinkVehicleToInterior(pCar[playerid], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, pCar[playerid], 0);
return 1;
}
// OnPlayerDisconnect
DestroyCar(pCar[playerid]);
// OnPlayerDeath
DestroyCar(pCar[playerid]);
- Thanks
ScottCFR
Re: Car Spawning Bug -
[HiC]TheKiller - 23.06.2011
Make sure that pCar[playerid] is actually set to a value before removing it to start with. There could be a vehicle under the ID 0 and it would be removed since you are getting rid of a blank variable. Also, can we see the function for DestroyCar?
Re: Car Spawning Bug -
ScottCFR - 23.06.2011
Here's DestroyCar:
Код:
stock DestroyCar(vehicleid)
{
DestroyVehicle(vehicleid);
return 1;
}
EDIT: Looking back, not sure what the point of this was.
Also, nice to see you back
Re: Car Spawning Bug -
Sasino97 - 23.06.2011
Quote:
Originally Posted by ScottCFR
Here's DestroyCar:
Код:
stock DestroyCar(vehicleid)
{
DestroyVehicle(vehicleid);
return 1;
}
|
o.O and what's that for?
A better way for renaming the functions is to use the preprocessor
#define DestroyCar DestroyVehicle
And can we also see the "Destroy" function?
Re: Car Spawning Bug -
[HiC]TheKiller - 23.06.2011
It could be something else on OnPlayerDeath / OnPlayerDisconnect. Would you be able to post / pm me the whole section so that I can see if it's something else? I probably won't reply until tomorrow though, tired as and I need sleep
.
Re: Car Spawning Bug -
ScottCFR - 23.06.2011
Umm, I think I may have fixed it. Made a check to see if there is a car, if there is it will delete it. If it doesn't work I'll be sure to PM you Killer.
@Sasino didn't you see my edit :P