[Tutorial] Speedometer
#1

Before a year I`ve looking whole day to find some speedometer for my server... So i decided to give you one cool

URL: https://sampforum.blast.hk/showthread.php?tid=161275

Thanks to mckennie but there are guys that dont know how to use it so I make it easyer...

Lets start...



On top of the screen add this:

Code:
forward GetVehicleSpeed(vehicleid);
Put this in end of a script:

Code:
 public GetVehicleSpeed(vehicleid) {
      new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,final_speed_int;
      if(vehicleid != 0) {
            GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
            final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136;
            final_speed_int = floatround(final_speed,floatround_round);
            return 1; }
      return final_speed_int; }



So this is some kind of speedometer...you can use it simply like:

Code:
new Text:speedtext[MAX_PLAYERS];

public OnPlayerConnect(playerid) {
      speedtext[playerid] = TextDrawCreate(510, 105, "~g~Speed~w~: 0 Km/h"); 
      TextDrawFont(speedtext[playerid], 3); 
      TextDrawLetterSize(speedtext[playerid], 0.4, 1.4); 
      TextDrawSetOutline(speedtext[playerid], 1);
      return 1; }

public OnPlayerStateChange(playerid, oldstate, newstate) {
      new vid = GetPlayerVehicleID(playerid);
      if(newstate == PLAYER_STATE_DRIVER) {
            new string[256];         
            format(string,sizeof(string),"~g~Speed~w~: %d Km/h", GetVehicleSpeed(vid)); 
            TextDrawSetString(speedtext[playerid], string);
            TextDrawShowForPlayer(playerid, speedtext[playerid]);      
      }else if(newstate == PLAYER_STATE_ONFOOT) {
            TextDrawHideForPlayer(playerid, speedtext[playerid]); 	
            return 1; }
      return 1; }

public OnPlayerDisconnect(playerid) {
      TextDrawDestroy(speedtext[playerid]);
      return 1; }
So this is it ...I hope this will help you ...

Sorry for bad english :S...
Reply
#2

1. It should be in here http://forum.sa-mp.com/forumdisplay.php?f=70
2. It looks the same as the other guys topic
3. You need to explain it to be a tut.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)