Advertisement
Guest User

Atrox Audio Multi Stream

a guest
Dec 19th, 2011
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.37 KB | None | 0 0
  1. /*
  2.     SA:MP Audio Multi Stream v.1.2
  3.     Copyright © 2011 Atrox
  4.  
  5.     This program is free software: you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation, either version 3 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. public OnPlayerConnect(playerid)
  20. {
  21.     SetPVarInt(playerid, "duration", 0);
  22.     SetPVarString(playerid, "url", "");
  23.     SetPVarFloat(playerid, "posX", 0.0);
  24.     SetPVarFloat(playerid, "posY", 0.0);
  25.     SetPVarFloat(playerid, "posZ", 0.0);
  26.     SetPVarFloat(playerid, "distance", 50.0);
  27.     SetPVarInt(playerid, "usepos", 0);
  28.     return 1;
  29. }
  30. #if defined _ALS_OnPlayerConnect
  31.     #undef OnPlayerConnect
  32. #else
  33.     #define _ALS_OnPlayerConnect
  34. #endif
  35.  
  36. #define OnPlayerConnect AudioMS_OnPlayerConnect
  37.  
  38. forward AudioMS_OnPlayerConnect(playerid);
  39.  
  40. stock StopAudioStreamForPlayerEx(playerid)
  41. {
  42.     SetPVarInt(playerid, "duration", 0);
  43.     SetPVarString(playerid, "url", "");
  44.     SetPVarFloat(playerid, "posX", 0.0);
  45.     SetPVarFloat(playerid, "posY", 0.0);
  46.     SetPVarFloat(playerid, "posZ", 0.0);
  47.     SetPVarFloat(playerid, "distance", 50.0);
  48.     SetPVarInt(playerid, "usepos", 0);
  49.    
  50.     StopAudioStreamForPlayer(playerid);
  51. }
  52. stock PlayAudioStreamForPlayerEx(playerid, url[], duration, Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0)
  53. {
  54.     if(GetPVarInt(playerid, "duration") == 0)
  55.     {
  56.         PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  57.         SetPVarInt(playerid, "duration", duration);
  58.         SetPVarString(playerid, "url", url);
  59.         SetPVarFloat(playerid, "posX", posX);
  60.         SetPVarFloat(playerid, "posY", posY);
  61.         SetPVarFloat(playerid, "posZ", posZ);
  62.         SetPVarFloat(playerid, "distance", distance);
  63.         SetPVarInt(playerid, "usepos", usepos);
  64.         if(duration != -1)
  65.         {
  66.             SetTimerEx("StopAudio", duration, 0, "d", playerid);
  67.         }
  68.     }
  69.     else if(GetPVarInt(playerid, "duration") == -1)
  70.     {
  71.         StopAudioStreamForPlayer(playerid);
  72.         PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  73.         if(duration != -1)
  74.         {
  75.             new tmp[256];
  76.             GetPVarString(playerid, "url", tmp, 256);
  77.             SetTimerEx("SetNextStream", duration, 0, "dsdffffd", playerid, tmp, GetPVarInt(playerid, "duration"), GetPVarFloat(playerid, "posX"), GetPVarFloat(playerid, "posY"), GetPVarFloat(playerid, "posZ"), GetPVarFloat(playerid, "distance"), GetPVarInt(playerid, "usepos"));
  78.         }
  79.     }
  80.     else
  81.     {
  82.         StopAudioStreamForPlayer(playerid);
  83.         PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  84.  
  85.         if(duration != -1)
  86.         {
  87.             new tmp[256];
  88.             GetPVarString(playerid, "url", tmp, 256);
  89.             SetTimerEx("SetNextStream", duration, 0, "dsdffffd", playerid, tmp, GetPVarInt(playerid, "duration"), GetPVarFloat(playerid, "posX"), GetPVarFloat(playerid, "posY"), GetPVarFloat(playerid, "posZ"), GetPVarFloat(playerid, "distance"), GetPVarInt(playerid, "usepos"));
  90.         }
  91.     }
  92. }
  93. forward StopAudio(playerid);
  94. public StopAudio(playerid)
  95. {
  96.     StopAudioStreamForPlayerEx(playerid);
  97. }
  98. forward SetNextStream(playerid,url[], duration, Float:posX, Float:posY, Float:posZ, Float:distance, usepos);
  99. public SetNextStream(playerid,url[], duration, Float:posX, Float:posY, Float:posZ, Float:distance, usepos)
  100. {
  101.     StopAudioStreamForPlayer(playerid);
  102.     new tmp[256];
  103.     format(tmp, 256, url);
  104.     PlayAudioStreamForPlayer(playerid, tmp, Float:posX, Float:posY, Float:posZ, Float:distance, usepos);
  105.    
  106.     SetPVarInt(playerid, "duration", duration);
  107.     SetPVarString(playerid, "url", tmp);
  108.     SetPVarFloat(playerid, "posX", posX);
  109.     SetPVarFloat(playerid, "posY", posY);
  110.     SetPVarFloat(playerid, "posZ", posZ);
  111.     SetPVarFloat(playerid, "distance", distance);
  112.     SetPVarInt(playerid, "usepos", usepos);
  113.     if(duration != -1)
  114.     {
  115.        SetTimerEx("StopAudio", duration, 0, "d", playerid);
  116.     }
  117.     return 1;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement