Advertisement
Nyft_

Marcar veículos perto do jogador ~NYFT

May 9th, 2022 (edited)
917
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include a_samp
  2. #include sscanf2
  3. #include streamer
  4. #include pawn.cmd
  5. #include <YSI_Coding\y_va>
  6.  
  7. static const Float:STREAM_DISTANCE = 100.0;
  8.  
  9. static bool:playerActiveStreamIn[MAX_PLAYERS];
  10. static Text3D:playerActiveStreamLabel[MAX_PLAYERS][MAX_VEHICLES];
  11.  
  12. main(){}
  13.  
  14. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  15. {
  16.     if((newkeys & KEY_YES) && !playerActiveStreamIn[playerid])
  17.     {
  18.         new label[32], Float:x, Float:y, Float:z, Float:distance;
  19.         playerActiveStreamIn[playerid] = true;
  20.  
  21.         for(new i = (GetVehiclePoolSize() + 1); i != 0; --i)
  22.         {
  23.             GetVehiclePos(i, x, y, z);
  24.  
  25.             if((distance = GetPlayerDistanceFromPoint(playerid, x, y, z)) <= STREAM_DISTANCE)
  26.             {
  27.                 format(label, sizeof(label), "(%i) - Distância: %.1f", i, distance);
  28.                 playerActiveStreamLabel[playerid][i] = CreateDynamic3DTextLabel(label, -1, 0.0, 0.0, 0.5, STREAM_DISTANCE, .attachedvehicle = i, .playerid = playerid);
  29.             }
  30.         }
  31.     }
  32.     if((newkeys & KEY_NO) && playerActiveStreamIn[playerid])
  33.     {
  34.         playerActiveStreamIn[playerid] = false;
  35.  
  36.         for(new i = (GetVehiclePoolSize() + 1); i != 0; --i)
  37.             if(IsValidDynamic3DTextLabel(playerActiveStreamLabel[playerid][i]))
  38.                   DestroyDynamic3DTextLabel(playerActiveStreamLabel[playerid][i]);
  39.     }
  40.     return 1;
  41. }
  42.  
  43. CMD:v(playerid, params[])
  44. {
  45.     new modelid, color[2];
  46.  
  47.     if(sscanf(params, "iii", modelid, color[0], color[1]))
  48.         return SendClientMessage(playerid, -1, "* /v (modelo) (cor-1) (cor-2)");
  49.  
  50.     if(!(400 <= modelid <= 611))
  51.         return SendClientMessage(playerid, -1, "* Modelo inexistente.");
  52.  
  53.     new vehicleid, Float:x, Float:y, Float:z, Float:a;
  54.     GetPlayerPos(playerid, x, y, z);
  55.     GetPlayerFacingAngle(playerid, a);
  56.  
  57.     vehicleid = CreateVehicle(modelid, x, y, z, a, color[0], color[1], -1);
  58.     PutPlayerInVehicle(playerid, vehicleid, 0);
  59.     va_SendClientMessage(playerid, -1, "* Você criou o veículo %i com as cores %i e %i.", modelid, color[0], color[1]);
  60.     return 1;
  61. }
Advertisement
RAW Paste Data Copied
Advertisement