Car Spawning Bug
#1

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
Reply
#2

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?
Reply
#3

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
Reply
#4

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?
Reply
#5

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 .
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)