Speedometer - 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: Speedometer (
/showthread.php?tid=246648)
Speedometer -
ajwar - 05.04.2011
Hi, i made a speedometer and every thing works fine, but it show's not the players speed but all players speed, so while you are playing alone it works fine. I use:
pawn Код:
public Speed(playerid)
{
new
vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid != 0)
{
new string[64],string1[32];
format(string1,sizeof(string1), "Fuel: %il", VehicleFuel[vehicleid]);
format(string,sizeof(string), "Speed: %d km/h", GetPlayerSpeed(playerid,false));
TextDrawSetString(textdraws[Textdraw0][playerid],string);
TextDrawSetString(textdraws[Textdraw2][playerid],string1);
return 1;
}
else
{
TextDrawSetString(textdraws[Textdraw0][playerid],"");
TextDrawSetString(textdraws[Textdraw2][playerid],"");
}
return 1;
}
I don't have idea's what may be wrong.
Re: Speedometer -
Feverlander - 05.04.2011
Could you show us the GetPlayerSpeed function?
public Speed is a timer, right? Do you use SetTimerEx?
Re: Speedometer -
ajwar - 05.04.2011
pawn Код:
stock GetPlayerSpeed(playerid,bool:kmh) // by misco
{
new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
Re: Speedometer -
Feverlander - 05.04.2011
Код:
forward Speed();
public Speed()
{
for(new playerid, p = GetMaxPlayers(); playerid < p; playerid++)
{
new
vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid != 0)
{
new string[64],string1[32];
format(string1,sizeof(string1), "Fuel: %il", VehicleFuel[vehicleid]);
format(string,sizeof(string), "Speed: %d km/h", GetPlayerSpeed(playerid,false));
TextDrawSetString(textdraws[Textdraw0][playerid],string);
TextDrawSetString(textdraws[Textdraw2][playerid],string1);
return 1;
}
else
{
TextDrawSetString(textdraws[Textdraw0][playerid],"");
TextDrawSetString(textdraws[Textdraw2][playerid],"");
}
}
return 1;
}
Give it a try.