Advertisement
Guest User

Velocímetro TextDrawn

a guest
Mar 14th, 2010
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.63 KB | None | 0 0
  1. //Timer
  2. new CheckStatusTimer;
  3.  
  4. //4all
  5. new Text:Black0;
  6. new Text:Black1;
  7. new Text:Black2;
  8. new Text:Black3;
  9. new Text:LightBlack;
  10.  
  11. forward CheckStatus();
  12.  
  13. //4player
  14. new Text:VHS[MAX_PLAYERS];
  15.  
  16. //Speed
  17. new Float:OldX[MAX_PLAYERS];
  18. new Float:OldY[MAX_PLAYERS];
  19. new Float:OldZ[MAX_PLAYERS];
  20.  
  21.  
  22. public OnGameModeInit()
  23. {
  24.     CheckStatusTimer = SetTimer("CheckStatus", 1000, 1);
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30.     TextDrawsShown[playerid] = false;
  31.     return false;
  32.  
  33. }
  34.  
  35. public CheckStatus()
  36. {
  37.     for(new i=0; i<MAX_PLAYERS; i++)
  38.     {
  39.         if(IsPlayerConnected(i))
  40.         {
  41.             if(IsPlayerInAnyVehicle(i))
  42.             {
  43.                 if(TextDrawsShown[i] == false)
  44.                 {
  45.                     TextDrawShowForPlayer(i, Text:Black0);
  46.                     TextDrawShowForPlayer(i, Text:Black1);
  47.                     TextDrawShowForPlayer(i, Text:Black2);
  48.                     TextDrawShowForPlayer(i, Text:Black3);
  49.                     TextDrawShowForPlayer(i, Text:LightBlack);
  50.                     TextDrawsShown[i] = true;
  51.                 }
  52.                 new String[256];
  53.                 new Float:X, Float:Y, Float:Z, Float:Distance;
  54.                 GetPlayerPos(i, X, Y, Z);
  55.                 Distance = floatsqroot(floatadd(floatadd(floatpower(floatsub(X, OldX[i]), 2), floatpower(floatsub(Y, OldY[i]), 2)), floatpower(floatsub(Z, OldZ[i]), 2)));
  56.                 format(String,sizeof(String),"~b~Velocidade:~n~ ~r~%i km/h~n~~b~Combustivel:~n~ ~r~%i", floatround(((Distance/1000.0)*60.0)*60.0), Petrol[i]);
  57.                 if(VHSCreated[i] == true)
  58.                 {
  59.                     TextDrawDestroy(VHS[i]);
  60.                 }
  61.                 VHS[i] = TextDrawCreate(515.000000,100.000000,String);
  62.                 TextDrawAlignment(VHS[i],0);
  63.                 TextDrawBackgroundColor(VHS[i],0x000000ff);
  64.                 TextDrawFont(VHS[i],1);
  65.                 TextDrawLetterSize(VHS[i],0.444444,2.000000);
  66.                 TextDrawColor(VHS[i],0xffffffff);
  67.                 TextDrawSetOutline(VHS[i],1);
  68.                 TextDrawSetProportional(VHS[i],1);
  69.                 TextDrawSetShadow(VHS[i],1);
  70.                 TextDrawShowForPlayer(i, VHS[i]);
  71.                 VHSCreated[i] = true;
  72.                 OldX[i] = X; OldY[i] = Y; OldZ[i] = Z;
  73.                 Velocidade[i] = floatround(((Distance/1000.0)*60.0)*60.0);
  74.                 if(Velocidade[i] > 210 && GetPlayerState(i) == PLAYER_STATE_DRIVER && VeloMulta == 1){
  75.                     SendClientMessage(i,COLOR_RED,"[MULTA] Você foi pego dirigindo acima da velocidade, e levou multa.");
  76.                     GivePlayerMoney(i,-50);
  77.                 }
  78.             }
  79.             else
  80.             {
  81.                 if(TextDrawsShown[i] == true)
  82.                 {
  83.                     TextDrawHideForPlayer(i, Text:Black0);
  84.                     TextDrawHideForPlayer(i, Text:Black1);
  85.                     TextDrawHideForPlayer(i, Text:Black2);
  86.                     TextDrawHideForPlayer(i, Text:Black3);
  87.                     TextDrawHideForPlayer(i, Text:LightBlack);
  88.                     TextDrawsShown[i] = false;
  89.                 }
  90.                 TextDrawHideForPlayer(i, Text:VHS[i]);
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement