Advertisement
Guest User

Kilometerzähler

a guest
Jun 13th, 2012
1,343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.01 KB | None | 0 0
  1. /*==================================================================================================
  2. ====================================================================================================
  3. ============= VIELEN DANK, DASS SIE SICH DAS FILTERSCRIPT VON PILLE ENTSCHIEDEN HABEN. =============
  4. ====================================================================================================
  5. ====================== ICH WÜNSCHE VIEL SPAß MIT IHREM NEUEN KILOMETERZÄHLER. ======================
  6. ====================================================================================================
  7. =========== DAS LÖSCHEN DIESES TEXTES IST VERBOTEN UND FÜHRT ZU SCHLECHTEM GEWISSEN. ===============
  8. ====================================================================================================*/
  9.  
  10.  
  11. #include <a_samp>
  12.  
  13. #define FILTERSCRIPT
  14. #if defined FILTERSCRIPT
  15.  
  16. new Float:distance[MAX_PLAYERS];
  17. new m[MAX_PLAYERS];
  18. new km[MAX_PLAYERS];
  19. new Float:xx[MAX_PLAYERS],Float:yy[MAX_PLAYERS],Float:zz[MAX_PLAYERS];
  20. new Text:tacho[MAX_PLAYERS];
  21. new tachovar[MAX_PLAYERS];
  22.  
  23. public OnFilterScriptInit()
  24. {
  25.     for(new i=0;i<MAX_PLAYERS;i++)
  26.     {
  27.         tacho[i]= TextDrawCreate(508.000000, 383.000000, " ");
  28.         TextDrawBackgroundColor(tacho[i],255);
  29.         TextDrawFont(tacho[i],2);
  30.         TextDrawLetterSize(tacho[i],0.639999,2.399999);
  31.         TextDrawColor(tacho[i],16711935);
  32.         TextDrawSetOutline(tacho[i],1);
  33.         TextDrawSetProportional(tacho[i],1);
  34.     }
  35.     print("\n----------------------------------");
  36.     print(" Kilometerzähler Copyright by Pille.");
  37.     print("----------------------------------\n");
  38.    
  39. }
  40.  
  41. #else
  42. #endif
  43.  
  44. public OnPlayerStateChange(playerid, newstate, oldstate)
  45. {
  46.     if(newstate==PLAYER_STATE_DRIVER)
  47.     {
  48.         tachovar[playerid]=SetTimerEx("tachotimer",200,true,"i",playerid);
  49.         TextDrawShowForPlayer(playerid,tacho[playerid]);
  50.         GetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
  51.     }
  52.     if(newstate==PLAYER_STATE_ONFOOT)
  53.     {
  54.         KillTimer(tachovar[playerid]);
  55.         TextDrawHideForPlayer(playerid,tacho[playerid]);
  56.     }
  57. }
  58.  
  59. forward tachotimer(playerid);
  60. public tachotimer(playerid)
  61. {
  62.     new string[50];
  63.     new Float:distanz;
  64.     new Float:x,Float:y,Float:z;
  65.     GetPlayerPos(playerid,x,y,z);
  66.     distanz=GetDistanceFromPointToPoint(xx[playerid],yy[playerid],zz[playerid],x,y,z);
  67.     if(distanz>100) return 1;
  68.     distance[playerid]=distance[playerid]+distanz;
  69.     GetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
  70.     if(distance[playerid]>100)
  71.     {
  72.         m[playerid]++;
  73.         distance[playerid]=distance[playerid]-100;
  74.         if(m[playerid]==10)
  75.         {
  76.             km[playerid]++;
  77.             m[playerid]=0;
  78.         }
  79.         format(string,sizeof(string),"%i,%i KM",km[playerid],m[playerid]);
  80.         TextDrawSetString(tacho[playerid],string);
  81.     }
  82.     return 1;
  83. }
  84.  
  85. forward Float:GetDistanceFromPointToPoint(Float:X,Float:Y,Float:Z,Float:tX,Float:tY,Float:tZ);
  86. public Float:GetDistanceFromPointToPoint(Float:X,Float:Y,Float:Z,Float:tX,Float:tY,Float:tZ)
  87. {
  88.     return Float:floatsqroot((tX-X)*(tX-X)+(tY-Y)*(tY-Y)+(tZ-Z)*(tZ-Z));
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement