Advertisement
Guest User

audio.inc

a guest
Apr 21st, 2011
1,529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.87 KB | None | 0 0
  1. /*
  2.     SA-MP Audio Plugin v0.4
  3.     Copyright © 2010 Incognito
  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. #if defined _audio_included
  20.     #endinput
  21. #endif
  22. #define _audio_included
  23. #pragma library audio
  24.  
  25. // Natives
  26.  
  27. native Audio_CreateTCPServer(port);
  28. native Audio_DestroyTCPServer();
  29. native Audio_SetPack(const audiopack[], bool:transferable = true);
  30. native Audio_CreateSequence();
  31. native Audio_DestroySequence(sequenceid);
  32. native Audio_AddToSequence(sequenceid, audioid);
  33. native Audio_RemoveFromSequence(sequenceid, audioid);
  34. native Audio_Play(playerid, audioid, bool:pause = false, bool:loop = false, bool:downmix = false);
  35. native Audio_PlaySequence(playerid, sequenceid, bool:pause = false, bool:loop = false, bool:downmix = false);
  36. native Audio_PlayStreamed(playerid, const url[], bool:pause = false, bool:loop = false, bool:downmix = false);
  37. native Audio_Pause(playerid, handleid);
  38. native Audio_Resume(playerid, handleid);
  39. native Audio_Stop(playerid, handleid);
  40. native Audio_Restart(playerid, handleid);
  41. native Audio_Seek(playerid, handleid, seconds);
  42. native Audio_SetVolume(playerid, handleid, volume);
  43. native Audio_Set3DPosition(playerid, handleid, Float:x, Float:y, Float:z, Float:distance);
  44. native Audio_Set3DOffsets(playerid, handleid, Float:x, Float:y, Float:z);
  45. native Audio_SetFX(playerid, handleid, type);
  46. native Audio_RemoveFX(playerid, handleid, type);
  47. native Audio_SetEAX(playerid, environment);
  48. native Audio_RemoveEAX(playerid);
  49. native Audio_IsClientConnected(playerid);
  50. native Audio_TransferPack(playerid);
  51. native Audio_AddPlayer(playerid, const ip[], const name[]);
  52. native Audio_RemovePlayer(playerid);
  53.  
  54. // Callbacks
  55.  
  56. forward Audio_OnClientConnect(playerid);
  57. forward Audio_OnClientDisconnect(playerid);
  58. forward Audio_OnSetPack(audiopack[]);
  59. forward Audio_OnTransferFile(playerid, file[], current, total, result);
  60. forward Audio_OnPlay(playerid, handleid);
  61. forward Audio_OnStop(playerid, handleid);
  62. forward Audio_OnTrackChange(playerid, handleid, track[]);
  63.  
  64. // Automatic Setup System
  65.  
  66. static
  67.     bool:Audio_g_CTS = false,
  68.     bool:Audio_g_OPC = false,
  69.     bool:Audio_g_OPDC = false;
  70.  
  71. public
  72.     OnFilterScriptInit()
  73. {
  74.     if (!Audio_g_CTS)
  75.     {
  76.         Audio_g_CTS = true;
  77.         Audio_g_OPC = (funcidx("Audio_OnPlayerConnect") != -1);
  78.         Audio_g_OPDC = (funcidx("Audio_OnPlayerDisconnect") != -1);
  79.         Audio_CreateTCPServer(GetServerVarAsInt("port"));
  80.     }
  81.     if (funcidx("Audio_OnFilterScriptInit") != -1)
  82.     {
  83.         return CallLocalFunction("Audio_OnFilterScriptInit", "");
  84.     }
  85.     return 1;
  86. }
  87.  
  88. #if defined _ALS_OnFilterScriptInit
  89.     #undef OnFilterScriptInit
  90. #else
  91.     #define _ALS_OnFilterScriptInit
  92. #endif
  93. #define OnFilterScriptInit Audio_OnFilterScriptInit
  94.  
  95. forward
  96.     Audio_OnFilterScriptInit();
  97.  
  98. public
  99.     OnGameModeInit()
  100. {
  101.     if (!Audio_g_CTS)
  102.     {
  103.         Audio_g_CTS = true;
  104.         Audio_g_OPC = (funcidx("Audio_OnPlayerConnect") != -1);
  105.         Audio_g_OPDC = (funcidx("Audio_OnPlayerDisconnect") != -1);
  106.         Audio_CreateTCPServer(GetServerVarAsInt("port"));
  107.     }
  108.     if (funcidx("Audio_OnGameModeInit") != -1)
  109.     {
  110.         return CallLocalFunction("Audio_OnGameModeInit", "");
  111.     }
  112.     return 1;
  113. }
  114.  
  115. #if defined _ALS_OnGameModeInit
  116.     #undef OnGameModeInit
  117. #else
  118.     #define _ALS_OnGameModeInit
  119. #endif
  120. #define OnGameModeInit Audio_OnGameModeInit
  121.  
  122. forward
  123.     Audio_OnGameModeInit();
  124.  
  125. public
  126.     OnPlayerConnect(playerid)
  127. {
  128.     if (!IsPlayerNPC(playerid))
  129.     {
  130.         new
  131.             ip[16],
  132.             name[MAX_PLAYER_NAME];
  133.         GetPlayerIp(playerid, ip, sizeof(ip));
  134.         GetPlayerName(playerid, name, sizeof(name));
  135.         Audio_AddPlayer(playerid, ip, name);
  136.     }
  137.     if (Audio_g_OPC)
  138.     {
  139.         return CallLocalFunction("Audio_OnPlayerConnect", "d", playerid);
  140.     }
  141.     return 1;
  142. }
  143.  
  144. #if defined _ALS_OnPlayerConnect
  145.     #undef OnPlayerConnect
  146. #else
  147.     #define _ALS_OnPlayerConnect
  148. #endif
  149. #define OnPlayerConnect Audio_OnPlayerConnect
  150.  
  151. forward
  152.     Audio_OnPlayerConnect(playerid);
  153.  
  154. public
  155.     OnPlayerDisconnect(playerid, reason)
  156. {
  157.     if (!IsPlayerNPC(playerid))
  158.     {
  159.         Audio_RemovePlayer(playerid);
  160.     }
  161.     if (Audio_g_OPDC)
  162.     {
  163.         return CallLocalFunction("Audio_OnPlayerDisconnect", "dd", playerid, reason);
  164.     }
  165.     return 1;
  166. }
  167.  
  168. #if defined _ALS_OnPlayerDisconnect
  169.     #undef OnPlayerDisconnect
  170. #else
  171.     #define _ALS_OnPlayerDisconnect
  172. #endif
  173. #define OnPlayerDisconnect Audio_OnPlayerDisconnect
  174.  
  175. forward
  176.     Audio_OnPlayerDisconnect(playerid, reason);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement