Some annoying bug
#1

anytimes a player type /nrg or /car, it created. then when a other player type one of the following commands, it destroy the player who spawned the vehicle first and that vehicle create to the second player. i dont know if it is a bug between id 0 and id 1. but it's totally annoying my server. it seen like i cant fix it.
Reply
#2

Show the command
Reply
#3

It seems to me that you use a global variable (not array [per-player]) to store the vehicle ID and that can only hold one value.

Another reason could be that you indeed use an array as it's supposed to but you never reset the variable when the vehicle is destroyed.
Reply
#4

Код:
CMD:nrg(playerid, params[])
{
    new Float:x, Float:y, Float:z, Float:angle;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, angle);
    if(PlayerAcc[playerid][Log] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
	{
		if(CarId[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(CarId[playerid]);
	    CarId[playerid] = CreateVehicle(522, x, y, z, angle, -1, -1, 6000);
		PutPlayerInVehicle(playerid, CarId[playerid], 0);
	    SendClientMessage(playerid, COLOR_LIME, "You spawn an nrg!");
	}
	return 1;
}

CMD:car(playerid, params[])
{
    new Float:x, Float:y, Float:z, Float:angle;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, angle);
    if(PlayerAcc[playerid][Log] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
	{
		if(CarId[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(CarId[playerid]);
	    CarId[playerid] = CreateVehicle(411, x, y, z, angle, -1, -1, 6000);
		PutPlayerInVehicle(playerid, CarId[playerid], 0);
	    SendClientMessage(playerid, COLOR_LIME, "You spawn an infernus!");
	}
	return 1;
}
Код:
CMD:v(playerid, params[])
{
	new string[128], vID[32], vid, Float:x, Float:y, Float:z, Float:ang;
	if(sscanf(params, "s[32]", vID)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /v (carname)");
	if(isnumeric(vID)) vid = strval(vID);
	else vid = GetVehicleModelIDFromName(vID);
	if (vid < 400 || vid > 611) return SendClientMessage(playerid, COLOR_RED, "Vehicle ID Maxium (Left): 400 - Maxium (Right): 611");
	GetPlayerPos(playerid,x,y,z);
	GetPlayerFacingAngle(playerid,ang);
	if(CarId[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(CarId[playerid]);
	CarId[playerid] = CreateVehicle(vid, x, y, z, ang, -1, -1, 6000);
	LinkVehicleToInterior(CarId[playerid], GetPlayerInterior(playerid));
	SetVehicleVirtualWorld(CarId[playerid], GetPlayerVirtualWorld(playerid));
	PutPlayerInVehicle(playerid, CarId[playerid], 0);
	format(string, sizeof(string), "You've spawned vehicle id %i - %s", vid, VehicleName[vid - 400]);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	return 1;
}
and some dialog bug

when im in a vehicle and i type a command that display a message dialog, when i click on ok or press esc, my vehicle destroy
Reply
#5

It's the second reason I mentioned.

Player A spawns a vehicle with vehicle ID 1.
Player A's vehicle gets destroyed.
Player B spawns a vehicle with ID 1.
Player A spawns a vehicle with vehicle ID 2 but the server destroys Player B's vehicle as the variable was never reset (previous vehicle of Player A was the vehicle with ID 1).

Whenever the vehicle is destroyed, find who player had it stored and reset the variable CarId[playerid] to INVALID_VEHICLE_ID.
Reply
#6

is there a way to solve it?
Reply
#7

Код:
new PlayerVehicle[MAX_PLAYERS];

DestroyVehicle(PlayerVehicle[playerid]);
PlayerVehicle[playerid] = CreateVehicle(...);
Reply
#8

Delete this code from the cmds

Код:
DestroyVehicle(CarId[playerid]
Reply
#9

Quote:
Originally Posted by SoFahim
Посмотреть сообщение
Delete this code from the cmds

Код:
DestroyVehicle(CarId[playerid]
so replace that code with this?

Код:
DestroyVehicle(PlayerVehicle[playerid]);
Reply
#10

Quote:
Originally Posted by suni
Посмотреть сообщение
so replace that code with this?

Код:
DestroyVehicle(PlayerVehicle[playerid]);
Delete this code for avoid destroy spawned car destroy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)