Speedo problem with timer - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Speedo problem with timer (
/showthread.php?tid=186380)
Speedo problem with timer -
gamer931215 - 28.10.2010
Hello guys, i have a problem with my speedo meter.
Im using
ONE timer with a loop to update everyone's textdraw. But this only works for playerid 0 !
pawn Код:
forward update();
public update()
{
for(new i =0;i<MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i) != 1) return 1;
new veh = GetPlayerVehicleID(i);
//updating speed
new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,string[128];
GetVehicleVelocity(veh,speed_x,speed_y,speed_z);
final_speed = floatsqroot(speed_x*speed_x + speed_y*speed_y + speed_z*speed_z)*85.4166672; // 136.666667 = kmph // 85.4166672= mph
final_speed = floatround(final_speed,floatround_round);
if(floatround(final_speed,floatround_round) > 100)
{
format(string,sizeof string,"%iMph",floatround(final_speed,floatround_round));
} else {
format(string,sizeof string,"%i Mph",floatround(final_speed,floatround_round));
}
TextDrawSetString(speedo[i][speedo_speed],string);
//update health
new Float:health;
GetVehicleHealth(veh,health);
if(floatround(health,floatround_round) > 999)
{
format(string,sizeof string,"%i%",floatround(health /10,floatround_round));
} else {
format(string,sizeof string,"%i %",floatround(health /10,floatround_round));
}
TextDrawSetString(speedo[i][speedo_health],string);
}
return 1;
}
Also other players will get the textdraw of playerid 0. Did i made any mistake here

?
Please help
Re: Speedo problem with timer -
PilotXtreme - 28.10.2010
A BIG Mistake! Posting!
Re: Speedo problem with timer -
Jefff - 28.10.2010
pawn Код:
if(IsPlayerInAnyVehicle(i) != 1) return 1;
to
pawn Код:
if(!IsPlayerInAnyVehicle(i)) continue;