HELP car's disappear when creating another
#1

Sometimes when I create a car it will erase it from another player

here the code, help me pls
Код:
enum _@en@cuenta
{
    cCoche 
};
/////////////////
new static cuenta[MAX_PLAYERS][_@en@cuenta];
/////////////////
public OnVehicleSpawn(vehicleid)
{
	for(new i=0,t=GetMaxPlayers(); i<t; i++)
	{
		if(!IsPlayerConnected(i)) continue;
		{
			if(vehicleid == cuenta[i][cCoche])
			{
				DestroyVehicle(vehicleid);
			}
		}
	}
	return 1;
}
stock GenerarAuto(playerid, modelo, Float:vida)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		Mensaje(playerid, Rojo, "[Advertencia]: Usted ya esta dentro de un vehiculo, baje para crear uno!.");
		return false;
	}
	else
	{
		new Float:x, Float:y, Float:z, Float:angle;
		GetPlayerPos(playerid, x, y, z);
		GetPlayerFacingAngle(playerid, angle);
		
		DestroyVehicle(cuenta[playerid][cCoche]);

		cuenta[playerid][cCoche] = CreateVehicle(modelo, x, y, z+2, angle, -1, -1, -1);
		SetVehicleHealth(cuenta[playerid][cCoche], vida);
		SetVehicleVirtualWorld(cuenta[playerid][cCoche], GetPlayerVirtualWorld(playerid));
		LinkVehicleToInterior(cuenta[playerid][cCoche], GetPlayerInterior(playerid));
		PutPlayerInVehicle(playerid, cuenta[playerid][cCoche], 0);
	    return true;

	}
}
Reply
#2

Not everyone understands Spanish or whatever this language is.
Reply
#3

pawn Код:
DestroyVehicle(cuenta[playerid][cCoche]);
Probably because you aren't resetting this variable. When you call GenerarAuto() it will destroy that vehicle without checking if it's valid, even if another player now has that vehicle ID assigned to their car.

Also..
pawn Код:
enum _@en@cuenta
{
    cCoche
};
/////////////////
new static cuenta[MAX_PLAYERS][_@en@cuenta];
Why?!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)