Speedometer Textdraw shows only for ID 0
#1

Hello everyone, so, I've downloaded AVS (Advanced Vehicle System) to try it and it seems like it works perfectly, but the only thing messing up is the speedometer textdraw which shows only for id 0 ?

Everyone who atleast tries to land me a hand will be surely +repped! x)
Reply
#2

paste the pawn code.
Reply
#3

It shows only for id 0 because you've set the speedo to "playerid" which means only one player you should change "playerid" in your speedo to "i" also show us your code.
Reply
#4

Код:
public Speedometer()
{
	new vehicleid, Float:health;
	new engine, lights, alarm, doors, bonnet, boot, objective;
	new fstring[32], string[512];

	
	for(new i=0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
			vehicleid = GetPlayerVehicleID(i);
			GetVehicleHealth(vehicleid, health);
			GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
			
			string = "~b~~h~vehicle: ~w~";
			strcat(string, VehicleNames[GetVehicleModel(vehicleid)-400], sizeof(string));
			
			strcat(string, "~n~~b~~h~gps: ~w~", sizeof(string));
			strcat(string, GetPlayer3DZone(i), sizeof(string));
			
			strcat(string, "~n~~b~~h~health: ~g~", sizeof(string));
			fstring = "iiiiiiiiii";
			if(health > 1000.0) strins(fstring, "~r~", 10, sizeof(fstring));
			else if(health < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
			else strins(fstring, "~r~", floatround(health/100.0), sizeof(fstring));
			strcat(string, fstring, sizeof(string));
			
			strcat(string, "        ~b~~h~fuel: ~g~", sizeof(string));
			fstring = "iiiiiiiiii";
			if(Fuel[vehicleid] > 100.0) strins(fstring, "~r~", 10, sizeof(fstring));
			else if(Fuel[vehicleid] < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
			else strins(fstring, "~r~", floatround(Fuel[vehicleid]/10.0), sizeof(fstring));
			strcat(string, fstring, sizeof(string));
			
			strcat(string, "        ~b~~h~", sizeof(string));
			if(GetPVarInt(i, "Speedo")) format(fstring,sizeof(fstring),"mph: ~w~%d", GetPlayerSpeed(i, false));
			else format(fstring,sizeof(fstring),"kph: ~w~%d", GetPlayerSpeed(i, true));
			strcat(string, fstring, sizeof(string));
			
			strcat(string, "~n~~b~~h~engine: ", sizeof(string));
			if(engine == 1) strcat(string, "~g~on", sizeof(string));
			else strcat(string, "~r~off", sizeof(string));
			
			strcat(string, "        ~b~~h~alarm: ", sizeof(string));
			if(VehicleSecurity[vehicleid] == 1) strcat(string, "~g~on", sizeof(string));
			else strcat(string, "~r~off", sizeof(string));
			
			strcat(string, "        ~b~~h~doors: ", sizeof(string));
			if(doors == 1) strcat(string, "~r~locked", sizeof(string));
			else strcat(string, "~g~unlocked", sizeof(string));
			
			TextDrawSetString(SpeedoText[i], string);
		}
	}
}
I haven't used playerid.

EDIT: or maybe here's the problem ?

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(IsPlayerInAnyVehicle(playerid) && !IsBicycle(GetPlayerVehicleID(playerid)))
	{
		TextDrawShowForPlayer(playerid, SpeedoBox);
		TextDrawShowForPlayer(, SpeedoText[playerid]);
		new vehicleid = GetPlayerVehicleID(playerid);
		if(VehicleSecurity[vehicleid] == 1)
		{
			ToggleAlarm(vehicleid, VEHICLE_PARAMS_ON);
			SetTimerEx("StopAlarm", ALARM_TIME, false, "d", vehicleid);
		}
	}
	else
	{
		TextDrawHideForPlayer(playerid, SpeedoBox);
		TextDrawHideForPlayer(playerid, SpeedoText[playerid]);
	}
	if(newstate == PLAYER_STATE_DRIVER)
	{
		new vehicleid = GetPlayerVehicleID(playerid);
		new id = GetVehicleID(vehicleid);
		if(IsValidVehicle(id))
		{
			if(VehicleCreated[id] == VEHICLE_DEALERSHIP)
			{
				SetPVarInt(playerid, "DialogValue1", id);
				ShowDialog(playerid, DIALOG_VEHICLE_BUY);
				return 1;
			}
		}
		if(IsBicycle(vehicleid))
		{
			ToggleEngine(vehicleid, VEHICLE_PARAMS_ON);
		}
		if(Fuel[vehicleid] <= 0)
		{
			ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
		}
	}
	return 1;
}
Reply
#5

Here's your problem
pawn Код:
TextDrawShowForPlayer(, SpeedoText[playerid]);
It's always the stupid things that fuck things up. I'm actually surprised that compiled. But seeing as the playerid parameter was empty it probably ended up compiling as 0, interesting.
Reply
#6

I will check it out, thanks in advance!
Reply
#7

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
Here's your problem
pawn Код:
TextDrawShowForPlayer(, SpeedoText[playerid]);
It's always the stupid things that fuck things up. I'm actually surprised that compiled. But seeing as the playerid parameter was empty it probably ended up compiling as 0, interesting.
Yeah, this is probably it.
Happened to me once and it took ages to fix it.
Reply
#8

EDIT: Now it shows the textdraw for everyone, but its not updating (speedometer, fuel, damage) unless someone else enters another vehicle


Where's the problem ?

Код:
UpdateVehicle(vehicleid, removeold)
{
	if(VehicleCreated[vehicleid])
	{
		if(removeold)
		{
			new Float:health;
			GetVehicleHealth(VehicleID[vehicleid], health);
			new engine, lights, alarm, doors, bonnet, boot, objective;
			GetVehicleParamsEx(VehicleID[vehicleid], engine, lights, alarm, doors, bonnet, boot, objective);
			//new panels, doorsd, lightsd, tires;
			//GetVehicleDamageStatus(VehicleID[vehicleid], panels, doorsd, lightsd, tires);
			DestroyVehicle(VehicleID[vehicleid]);
			VehicleID[vehicleid] = CreateVehicle(VehicleModel[vehicleid], VehiclePos[vehicleid][0], VehiclePos[vehicleid][1], 
				VehiclePos[vehicleid][2], VehiclePos[vehicleid][3], VehicleColor[vehicleid][0], VehicleColor[vehicleid][1], 3600);
			SetVehicleHealth(VehicleID[vehicleid], health);
			SetVehicleParamsEx(VehicleID[vehicleid], engine, lights, alarm, doors, bonnet, boot, objective);
			//UpdateVehicleDamageStatus(VehicleID[vehicleid], panels, doorsd, lightsd, tires);
		}
		else
		{
			VehicleID[vehicleid] = CreateVehicle(VehicleModel[vehicleid], VehiclePos[vehicleid][0], VehiclePos[vehicleid][1], 
				VehiclePos[vehicleid][2], VehiclePos[vehicleid][3], VehicleColor[vehicleid][0], VehicleColor[vehicleid][1], 3600);
		}
		LinkVehicleToInterior(VehicleID[vehicleid], VehicleInterior[vehicleid]);
		SetVehicleVirtualWorld(VehicleID[vehicleid], VehicleWorld[vehicleid]);
		SetVehicleNumberPlate(VehicleID[vehicleid], VehicleNumberPlate[vehicleid]);
		for(new i=0; i < sizeof(VehicleMods[]); i++)
		{
			AddVehicleComponent(VehicleID[vehicleid], VehicleMods[vehicleid][i]);
		}
		ChangeVehiclePaintjob(VehicleID[vehicleid], VehiclePaintjob[vehicleid]);
		if(VehicleLock[vehicleid]) ToggleDoors(VehicleID[vehicleid], VEHICLE_PARAMS_ON);
		if(VehicleAlarm[vehicleid]) VehicleSecurity[VehicleID[vehicleid]] = 1;
		UpdateVehicleLabel(vehicleid, removeold);
	}
}
Код:
public Speedometer()
{
	new vehicleid, Float:health;
	new engine, lights, alarm, doors, bonnet, boot, objective;
	new fstring[32], string[512];

	foreach(Player, i)
	for(i=0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
			vehicleid = GetPlayerVehicleID(i);
			GetVehicleHealth(vehicleid, health);
			GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
			
			string = "~b~~h~vehicle: ~w~";
			strcat(string, VehicleNames[GetVehicleModel(vehicleid)-400], sizeof(string));
			
			strcat(string, "~n~~b~~h~gps: ~w~", sizeof(string));
			strcat(string, GetPlayer3DZone(i), sizeof(string));
			
			strcat(string, "~n~~b~~h~health: ~g~", sizeof(string));
			fstring = "iiiiiiiiii";
			if(health > 1000.0) strins(fstring, "~r~", 10, sizeof(fstring));
			else if(health < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
			else strins(fstring, "~r~", floatround(health/100.0), sizeof(fstring));
			strcat(string, fstring, sizeof(string));
			
			strcat(string, "        ~b~~h~fuel: ~g~", sizeof(string));
			fstring = "iiiiiiiiii";
			if(Fuel[vehicleid] > 100.0) strins(fstring, "~r~", 10, sizeof(fstring));
			else if(Fuel[vehicleid] < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
			else strins(fstring, "~r~", floatround(Fuel[vehicleid]/10.0), sizeof(fstring));
			strcat(string, fstring, sizeof(string));
			
			strcat(string, "        ~b~~h~", sizeof(string));
			if(GetPVarInt(i, "Speedo")) format(fstring,sizeof(fstring),"mph: ~w~%d", GetPlayerSpeed(i, false));
			else format(fstring,sizeof(fstring),"kph: ~w~%d", GetPlayerSpeed(i, true));
			strcat(string, fstring, sizeof(string));
			
			strcat(string, "~n~~b~~h~engine: ", sizeof(string));
			if(engine == 1) strcat(string, "~g~on", sizeof(string));
			else strcat(string, "~r~off", sizeof(string));
			
			strcat(string, "        ~b~~h~alarm: ", sizeof(string));
			if(VehicleSecurity[vehicleid] == 1) strcat(string, "~g~on", sizeof(string));
			else strcat(string, "~r~off", sizeof(string));
			
			strcat(string, "        ~b~~h~doors: ", sizeof(string));
			if(doors == 1) strcat(string, "~r~locked", sizeof(string));
			else strcat(string, "~g~unlocked", sizeof(string));
			
			TextDrawSetString(SpeedoText[i], string);
		}
	}
}
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	for(new i=0; i < MAX_PLAYERS; i++)
	if(IsPlayerInAnyVehicle(playerid) && !IsBicycle(GetPlayerVehicleID(playerid)))
	{
		TextDrawShowForPlayer(playerid, SpeedoBox);
		TextDrawShowForPlayer(playerid, SpeedoText[i]);
		new vehicleid = GetPlayerVehicleID(playerid);
		if(VehicleSecurity[vehicleid] == 1)
		{
			ToggleAlarm(vehicleid, VEHICLE_PARAMS_ON);
			SetTimerEx("StopAlarm", ALARM_TIME, false, "d", vehicleid);
		}
	}
	else
	{
		TextDrawHideForPlayer(playerid, SpeedoBox);
		TextDrawHideForPlayer(playerid, SpeedoText[i]);
	}
	if(newstate == PLAYER_STATE_DRIVER)
	{
		new vehicleid = GetPlayerVehicleID(playerid);
		new id = GetVehicleID(vehicleid);
		if(IsValidVehicle(id))
		{
			if(VehicleCreated[id] == VEHICLE_DEALERSHIP)
			{
				SetPVarInt(playerid, "DialogValue1", id);
				ShowDialog(playerid, DIALOG_VEHICLE_BUY);
				return 1;
			}
		}
		if(IsBicycle(vehicleid))
		{
			ToggleEngine(vehicleid, VEHICLE_PARAMS_ON);
		}
		if(Fuel[vehicleid] <= 0)
		{
			ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)