SA-MP Forums Archive
Speedometer 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: Speedometer problem. (/showthread.php?tid=137949)



Speedometer problem. - Carlton - 30.03.2010

I'm having trouble getting a speedometer working. The mph is coming up in 10 thousands.

pawn Код:
new Float:ppos[3];
                new Float:vpos[3];
                new Float:pDist;
                GetPlayerPos(i, ppos[0], ppos[1], ppos[2]);
                pDist = floatsqroot(floatpower(floatabs(floatsub(ppos[0],vpos[0])),2)+floatpower(floatabs(floatsub(ppos[1],vpos[1])),2)+floatpower(floatabs(floatsub(ppos[2],vpos[2])),2));
                value = floatround(pDist, floatround_round);
                format(string, sizeof(string), "~g~ MPH: %d~n~ Fuel: %d", value, CarData[GetPlayerVehicleID(i)][Fuel]);



Re: Speedometer problem. - RyDeR` - 30.03.2010

Keep it simple: >>

pawn Код:
new
    Float: vX,
    Float: vY,
    Float: vZ,
    Float: Speed,
    string[32] // If you have mor chars just higher this..
;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
Speed = floatsqroot(floatpower(vX, 2) + floatpower(vY, 2) + floatpower(vZ, 2)) * 99;
format(string, sizeof(string), "Speed: %0.0f mp/h", Speed);
//TextDrawSetString(TD, string), TextDrawShowForPlayer(playerid, TD);



Re: Speedometer problem. - Carlton - 30.03.2010

Quote:
Originally Posted by » RyDeR «
Keep it simple: >>

pawn Код:
new
    Float: vX,
    Float: vY,
    Float: vZ,
    Float: Speed,
    string[32] // If you have mor chars just higher this..
;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
Speed = floatsqroot(floatpower(vX, 2) + floatpower(vY, 2) + floatpower(vZ, 2)) * 99;
format(string, sizeof(string), "Speed: %0.0f mp/h", Speed);
//TextDrawSetString(TD, string), TextDrawShowForPlayer(playerid, TD);
Can you explain the float functions I'm not too good with floats.


Re: Speedometer problem. - RyDeR` - 31.03.2010

lol, if your not good with floats how did you made Mapicon and Pickup streamer? :P
_________________________________________________
It's not difficult, you'll understand soon; For more info just surf to the wiki..


Re: Speedometer problem. - Carlton - 31.03.2010

Quote:
Originally Posted by » RyDeR «
lol, if your not good with floats how did you made Mapicon and Pickup streamer? :P
_________________________________________________
It's not difficult, you'll understand soon; For more info just surf to the wiki..
I mean't the functions, like floatsqroot, etc. The streamers just use IsPlayerInRangeOfPoint. Wiki doesn't have information on it.


Re: Speedometer problem. - rabit7 - 31.03.2010

Speedmeter is to free download, look for some


Re: Speedometer problem. - Carlton - 31.03.2010

Quote:
Originally Posted by rabit7
Speedmeter is to free download, look for some
I didn't ask to download some. It was a problem that was fixed already.


Re: Speedometer problem. - rabit7 - 31.03.2010

do you have any errors?


Re: Speedometer problem. - Carlton - 31.03.2010

Quote:
Originally Posted by rabit7
do you have errors?
Quote:
Originally Posted by Carlton
Quote:
Originally Posted by rabit7
Speedmeter is to free download, look for some
I didn't ask to download some. It was a problem that was fixed already.



Re: Speedometer problem. - rabit7 - 31.03.2010

speedmeter is not too accurate