Advertisement
Guest User

Untitled

a guest
May 20th, 2012
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.96 KB | None | 0 0
  1. new Float:distance[MAX_PLAYERS];
  2. new m[MAX_PLAYERS];
  3. new km[MAX_PLAYERS];
  4. new Float:xx[MAX_PLAYERS],Float:yy[MAX_PLAYERS],Float:zz[MAX_PLAYERS];
  5. new Text:tacho[MAX_PLAYERS];
  6. new tachovar[MAX_PLAYERS];
  7.  
  8. public OnGameModeInit()
  9. {
  10.     for(new i=0;i<MAX_PLAYERS;i++)
  11.     {
  12.         tacho[i]= TextDrawCreate(508.000000, 383.000000, " ");
  13.         TextDrawBackgroundColor(tacho[i],255);
  14.         TextDrawFont(tacho[i],2);
  15.         TextDrawLetterSize(tacho[i],0.639999,2.399999);
  16.         TextDrawColor(tacho[i],16711935);
  17.         TextDrawSetOutline(tacho[i],1);
  18.         TextDrawSetProportional(tacho[i],1);
  19.     }
  20. }
  21.  
  22. public OnPlayerStateChange(playerid, newstate, oldstate)
  23. {
  24.     if(newstate==PLAYER_STATE_DRIVER)
  25.     {
  26.             tachovar[playerid]=SetTimerEx("tachotimer",200,true,"i",playerid);
  27.         TextDrawShowForPlayer(playerid,tacho[playerid]);
  28.         GetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
  29.     }
  30.     if(newstate==PLAYER_STATE_ONFOOT)
  31.     {
  32.         KillTimer(tachovar[playerid]);
  33.         TextDrawHideForPlayer(playerid,tacho[playerid]);
  34.     }
  35. }
  36.  
  37. forward tachotimer(playerid);
  38. public tachotimer(playerid)
  39. {
  40.     new string[50];
  41.     new Float:distanz;
  42.     new Float:x,Float:y,Float:z;
  43.     GetPlayerPos(playerid,x,y,z);
  44.     distanz=GetDistanceFromPointToPoint(xx[playerid],yy[playerid],zz[playerid],x,y,z);
  45.     if(distanz>100) return 1;
  46.     distance[playerid]=distance[playerid]+distanz;
  47.     GetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
  48.     if(distance[playerid]>100)
  49.     {
  50.         m[playerid]++;
  51.         distance[playerid]=distance[playerid]-100;
  52.         if(m[playerid]==10)
  53.         {
  54.             km[playerid]++;
  55.             m[playerid]=0;
  56.         }
  57.     }
  58.     format(string,sizeof(string),"%i,%i KM",km[playerid],m[playerid]);
  59.     TextDrawSetString(tacho[playerid],string);
  60.     return 1;
  61. }
  62.  
  63. forward Float:GetDistanceFromPointToPoint(Float:X,Float:Y,Float:Z,Float:tX,Float:tY,Float:tZ);
  64. public Float:GetDistanceFromPointToPoint(Float:X,Float:Y,Float:Z,Float:tX,Float:tY,Float:tZ)
  65. {
  66.     return Float:floatsqroot((tX-X)*(tX-X)+(tY-Y)*(tY-Y)+(tZ-Z)*(tZ-Z));
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement