Posts: 1,534
Threads: 179
Joined: Apr 2009
pawn Код:
stock SetSpeed(playerid)
{
for(new b = 0;b<currentid +1;b++)
{
new speed = floatround(GetVehicleSpeed(GetPlayerVehicleID(playerid),SpeedCameras[b][_usemph]));
new string[140];
if(speed < 100)
{
format(string, sizeof(string), "Speed: ~g~%d KM/h", speed);
TextDrawSetString(Speedo0[playerid],string);
}
if(speed > 100)
{
format(string, sizeof(string), "Speed: ~y~%d KM/h", speed);
TextDrawSetString(Speedo0[playerid],string);
}
if(speed > 119)
{
format(string, sizeof(string), "Speed: ~r~%d KM/h", speed);
TextDrawSetString(Speedo0[playerid],string);
}
}
}
pawn Код:
Speedo0[i] = TextDrawCreate(496.000000,336.000000,"Speed: ~g~0 KM/h");
The textdraw is showing, but it always says "Speed: 0 KM/h"
Posts: 40
Threads: 1
Joined: Oct 2011
Reputation:
0
Make sure it updates OnPlayerUpdate or on a repeating timer every second.
Posts: 1,534
Threads: 179
Joined: Apr 2009
Quote:
Originally Posted by The DeLuca
Make sure it updates OnPlayerUpdate or on a repeating timer every second.
|
I have it at a timer which updates every 1 second
SetSpeed(i);
Posts: 40
Threads: 1
Joined: Oct 2011
Reputation:
0
Make SetSpeed a public callback and forward it. See if that works for ya.
Posts: 1,534
Threads: 179
Joined: Apr 2009
But what will be the difference =/
I also have a same thing with SetHealth (vehicle health), and it updates
Posts: 1,534
Threads: 179
Joined: Apr 2009
Quote:
Originally Posted by Jonny5
you have not defined currentid
not sure if this is a global or not, only error i spotted.
|
If i wouldn't have defined it, i would get errors at compiling...
// EDIT, lol your code works, but i get one warning
warning 219: local variable "currentid" shadows a variable at a preceding level
What should i change?
Posts: 1,534
Threads: 179
Joined: Apr 2009
It works now, thank you.
+rep