Speedo Meter problem - 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 Meter problem (
/showthread.php?tid=126124)
Speedo Meter problem -
Naruto4 - 07.02.2010
When i enter a car it doesnt shows it to me. I have a timer that runs this public every 1sec.
Код:
public UpdateMeter(playerid)
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i) && speedometer[i] == 1)
{
TextDrawShowForPlayer(playerid,Text:speedo[i]);
new vehicleid = GetPlayerVehicleID(playerid);
new Float:X, Float:Y, Float:Z, Float:KMH;
new Float:hp;
hp = GetVehicleHealth(vehicleid,hp);
GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
KMH = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)), floatpower(Z, 2))), 100.0);
if(KMH == 0)
{
VehicleInfo[vehicleid][Fuel] -= 0.00;
}
else if( KMH >= 1 && KMH <= 65 )
{
VehicleInfo[vehicleid][Fuel] -= 0.01;
}
else if( KMH >= 66 && KMH <= 120 )
{
VehicleInfo[vehicleid][Fuel] -= 0.02;
}
else
{
VehicleInfo[vehicleid][Fuel] -= 0.03;
}
if(VehicleInfo[vehicleid][Fuel] == 0)
{
SCM(playerid,GREY,"No more fuel left.");
RemovePlayerFromVehicle(playerid);
}
new string[128];
format(string, sizeof(string), "~b~~h~~h~Name: ~w~%s~n~~g~~h~Speed: ~w~%0.0f km/h~n~~y~~h~Fuel: ~w~%.1f l~n~~r~~h~Health: ~w~%.2f", CarModels[GetVehicleModel(GetPlayerVehicleID(playerid))-400],floatround(floatdiv(KMH, 1.609344)),VehicleInfo[vehicleid][Fuel],hp);
TextDrawSetString(Text:speedo[i], string);
TextDrawShowForPlayer(i,Text:speedo[i]);
}
}
}
Re: Speedo Meter problem -
mansonh - 07.02.2010
Two things.
One post your settimer
and 2 why are you using playerid for the timer when you loop through players
public UpdateMeter(playerid)
{
for(new i=0; i < MAX_PLAYERS; i++)
?
Re: Speedo Meter problem -
Naruto4 - 07.02.2010
1. som = SetTimer("UpdateMeter",1000,1);
2. woops. ook i removed it and changed all left playerid to i
testing it in game
Re: Speedo Meter problem -
Naruto4 - 07.02.2010
bump
Re: Speedo Meter problem -
MadeMan - 07.02.2010
Show how you create your textdraw.
Re: Speedo Meter problem -
Naruto4 - 09.02.2010
It is fixed peps.