Small problem with Speedometer
#1

Hello, I've that problem:
I use this fs in order to have the speedometer for vehicles, but it works only for the player with id 0. For example I (with id 0) am in a Nrg-500, meanwhile another player in the Sanchez. The other player (id 1) sees my speedometer, that is the Nrg. Is that problem solvable?

Link: https://sampforum.blast.hk/showthread.php?tid=349159

Source:

Quote:

#include <a_samp>

new Text:NAME[MAX_PLAYERS];
new Text:Textdraw1;
new Text:Textdraw2;
new Text:Textdraw3;
new Text:Textdraw4;
new Text:Textdraw5;
new Text:Textdraw6;
new Text:Textdraw7;
new Text:Textdraw8;
new Text:Textdraw9;
new Text:Textdraw10;
new Text:Textdraw11;
new Text:SPEEDOS[MAX_PLAYERS];
new Text:HEALTH[MAX_PLAYERS];

new VehicleName[][] =
{
"Landstalker", "Bravura", "Buffalo", etc....

};
forward Speedometer(playerid);

public Speedometer(playerid)
{
new vehicleid,Floatpeed_x,Floatpeed_y,Floatpeed_ z,Float:final_speed,speed_string[256],final_speed_int;
vehicleid = GetPlayerVehicleID(playerid);
new Float:vehicle_health,final_vehicle_health,health_s tring[256],string[257];
if(vehicleid != 0)
{
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed _z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+ (speed_z*speed_z))*151.2; // 250.666667 = kmph // 199,4166672= mph
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"Speed : ~w~%i.0",final_speed_int);
TextDrawSetString(SPEEDOS[playerid], speed_string);
GetVehicleHealth(vehicleid,vehicle_health);
final_vehicle_health = floatround(floatround(vehicle_health)); //This will make the health show at 100 when the vehicle is not damaged and at 0 when it is in fire.
format(health_string,256,"Health : ~w~%i.0", final_vehicle_health);
TextDrawSetString(HEALTH[playerid], health_string);
format(string,257,"Name :~w~ %s", VehicleName[GetVehicleModel(vehicleid)-400]);
TextDrawSetString(NAME[playerid], string);
}
else
{
TextDrawSetString(SPEEDOS[playerid], " ");
TextDrawSetString(HEALTH[playerid], " ");
}
return 1;
}

public OnFilterScriptInit()
{
// Create the textdraws:
SetTimer("Speedometer", 300, true); //change 100 to what pleases you,but i'd say it's better to keep it like that.
Textdraw1 = TextDrawCreate(497.000000, 95.000000, "-");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 3);
ETC ETC...
}

return 1;
}

public OnFilterScriptExit()
{
// TextDrawHideForAll(NAME[i]);
// TextDrawDestroy(NAME[i]);
ETC ETC...
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2);
ETC.. ETC...
}
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, Textdraw1);
TextDrawHideForPlayer(playerid, Textdraw2);
ETC... ETC....
}
}
return 1;
}

Reply


Messages In This Thread
Small problem with Speedometer - by spyro9696 - 11.02.2018, 19:19
Re: Small problem with Speedometer - by Mugala - 11.02.2018, 20:06
Re: Small problem with Speedometer - by spyro9696 - 11.02.2018, 20:15
Re: Small problem with Speedometer - by spyro9696 - 11.02.2018, 20:53
Re: Small problem with Speedometer - by Mugala - 11.02.2018, 20:56
Re: Small problem with Speedometer - by Mugala - 11.02.2018, 21:00
Re: Small problem with Speedometer - by spyro9696 - 11.02.2018, 21:04
Re: Small problem with Speedometer - by Mugala - 11.02.2018, 21:06
Re: Small problem with Speedometer - by spyro9696 - 11.02.2018, 21:07
Re: Small problem with Speedometer - by spyro9696 - 11.02.2018, 21:10

Forum Jump:


Users browsing this thread: 1 Guest(s)