Advertisement
Jimmmy_BNM

Veiculo Som Automático v1.5

Oct 20th, 2014
2,453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.43 KB | None | 0 0
  1. Creditos: Feito por Jimmy Servidor BRASIL NOVO MUNDO 0.3z IP: 192.95.6.22:7710
  2.  
  3. #define FILTERSCRIPT
  4. #include <a_samp>    
  5.  
  6. #if defined FILTERSCRIPT
  7.  
  8. new SomCarid[MAX_PLAYERS];
  9. new Musica[MAX_PLAYERS];
  10. new vMusica[MAX_PLAYERS];
  11. new VSomVeiculo[MAX_PLAYERS];
  12.  
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     for(new i = 0; i < MAX_PLAYERS; i++)
  17.     {
  18.     VSomVeiculo[i] = SetTimerEx("ReceberSomVeiculo", 5000, true, "i", i);
  19.     }
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30.     return 1;
  31. }
  32.  
  33. public OnPlayerDisconnect(playerid, reason)
  34. {
  35.     vMusica[playerid] = 0;
  36.     Musica[playerid] = 0;
  37.     KillTimer(VSomVeiculo[playerid]);
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerCommandText(playerid, cmdtext[])
  42. {
  43.     if(strcmp(cmdtext,"/radio1", true)==0)
  44.     {
  45.     if(IsPlayerInAnyVehicle(playerid))
  46.     {
  47.     Musica[playerid] = 1;
  48.     vMusica[playerid] = 0;
  49.     }else{
  50.     SendClientMessage(playerid, 0xFFFF59AA, "| INFO | Você não esta em um veiculo !");
  51.     }
  52.     return 1;
  53.     }
  54.  
  55.     if(strcmp(cmdtext,"/radio2", true)==0)
  56.     {
  57.     if(IsPlayerInAnyVehicle(playerid))
  58.     {
  59.     Musica[playerid] = 2;
  60.     vMusica[playerid] = 0;
  61.     }else{
  62.     SendClientMessage(playerid, 0xFFFF59AA, "| INFO | Você não esta em um veiculo !");
  63.     }
  64.     return 1;
  65.     }
  66.     return 0;
  67. }
  68.  
  69. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  70. {
  71.     return 1;
  72. }
  73.  
  74. forward ReceberSomVeiculo(playerid);
  75. public ReceberSomVeiculo(playerid)
  76. {
  77.         EnviarSomVeiculo(playerid);
  78.         new Float:X, Float:Y, Float:Z;
  79.         GetVehiclePos(SomCarid[playerid], X, Y, Z);
  80.         if(IsPlayerInRangeOfPoint(playerid, 15.0, X, Y, Z))
  81.         {
  82.         if(Musica[playerid] == 1)
  83.         {
  84.                 if(vMusica[playerid] == 0)
  85.                 {
  86.                 PlayAudioStreamForPlayer(playerid,"http://live.hunterfm.com/live"); // URL 1 /Radio1
  87.                 vMusica[playerid] = 1;
  88.                 }
  89.         }
  90.         if(Musica[playerid] == 2)
  91.         {
  92.                 if(vMusica[playerid] == 0)
  93.                 {
  94.                 PlayAudioStreamForPlayer(playerid, "URL");// URL 2 /Radio2
  95.                 vMusica[playerid] = 1;
  96.                 }
  97.         }
  98.         }else{
  99.         if(vMusica[playerid] == 1)
  100.         {
  101.                 StopAudioStreamForPlayer(playerid);
  102.                 Musica[playerid] = 0;
  103.                 vMusica[playerid] = 0;
  104.             }
  105.         }
  106. }
  107.  
  108. forward EnviarSomVeiculo(playerid);
  109. public EnviarSomVeiculo(playerid)
  110. {
  111.         if(IsPlayerInAnyVehicle(playerid))
  112.         {
  113.         new IdCar , id = -1;
  114.         IdCar = GetPlayerVehicleID(playerid);
  115.         for(new i = 0; i < MAX_PLAYERS; i++)
  116.         {
  117.         if(GetDistanceBetweenPlayers(playerid, i) < 15)
  118.         {
  119.         id = i;
  120.         if(Musica[playerid] == 2)
  121.         {
  122.                 Musica[id] = 2;
  123.         }
  124.         if(Musica[playerid] == 1)
  125.         {
  126.                 Musica[id] = 1;
  127.         }
  128.         SomCarid[id] = IdCar;
  129.         if(vMusica[playerid] == 0)
  130.         {
  131.                 vMusica[id] = 0;
  132.         }
  133.         }
  134.         }
  135.     }
  136. }
  137. stock GetDistanceBetweenPlayers(playerid,playerid2){
  138.         new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  139.         new Float:dis;
  140.         GetPlayerPos(playerid,x1,y1,z1);
  141.         GetPlayerPos(playerid2,x2,y2,z2);
  142.         dis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  143.         return floatround(dis);
  144. }
  145. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement