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

re-create the whole script from TextDraw to PlayerTextDraw.
Reply
#3

Ok, I try. Wait.
Reply
#4

This isn't the problem, it not works.
Reply
#5

okay I'll re-create this for u.
Reply
#6

agh wait, there's not a full code and I checked the link u gave, but from this link, it's everything working perfectly, so problem must not be here, do u use a whole filterscript or just took some of the codes?
Reply
#7

I've put just some of the codes in my GM, not all things
Reply
#8

yeah, here is a problem that u put "some" of the codes and not the whole code.
every code is connected to each other, so now put the whole code and try again.
Reply
#9

Ok, but there is a comment in that thread that reports the same problem I have...
Reply
#10

Indeed no, maybe you're right. Do I have to put all the TextDraws then?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)