Advertisement
Guest User

audio.inc

a guest
Aug 18th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.41 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2012 Incognito
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *     http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16.  
  17. #include <a_samp>
  18.  
  19. // Natives (Main)
  20.  
  21. native Audio_CreateTCPServer(port);
  22. native Audio_DestroyTCPServer();
  23. native Audio_SetPack(const name[], bool:transferable = true, bool:automated = true);
  24. native Audio_IsClientConnected(playerid);
  25. native Audio_SendMessage(playerid, const message[]);
  26. native Audio_TransferPack(playerid);
  27.  
  28. // Natives (Sequences)
  29.  
  30. native Audio_CreateSequence();
  31. native Audio_DestroySequence(sequenceid);
  32. native Audio_AddToSequence(sequenceid, audioid);
  33. native Audio_RemoveFromSequence(sequenceid, audioid);
  34.  
  35. // Natives (Audio)
  36.  
  37. native Audio_Play(playerid, audioid, bool:pause = false, bool:loop = false, bool:downmix = false);
  38. native Audio_PlayStreamed(playerid, const url[], bool:pause = false, bool:loop = false, bool:downmix = false);
  39. native Audio_PlaySequence(playerid, sequenceid, bool:pause = false, bool:loop = false, bool:downmix = false);
  40. native Audio_Pause(playerid, handleid);
  41. native Audio_Resume(playerid, handleid);
  42. native Audio_Stop(playerid, handleid);
  43. native Audio_Restart(playerid, handleid);
  44. native Audio_GetPosition(playerid, handleid, const callback[] = "Audio_OnGetPosition");
  45. native Audio_SetPosition(playerid, handleid, seconds);
  46. native Audio_SetVolume(playerid, handleid, volume);
  47. native Audio_SetFX(playerid, handleid, type);
  48. native Audio_RemoveFX(playerid, handleid, type);
  49. native Audio_Set3DPosition(playerid, handleid, Float:x, Float:y, Float:z, Float:distance);
  50. native Audio_Remove3DPosition(playerid, handleid);
  51.  
  52. // Natives (Radio Stations)
  53.  
  54. native Audio_SetRadioStation(playerid, station);
  55. native Audio_StopRadio(playerid);
  56.  
  57. // Natives (Internal)
  58.  
  59. native Audio_AddPlayer(playerid, const ip[], const name[]);
  60. native Audio_RenamePlayer(playerid, const name[]);
  61. native Audio_RemovePlayer(playerid);
  62.  
  63. // Callbacks (Main)
  64.  
  65. forward Audio_OnClientConnect(playerid);
  66. forward Audio_OnClientDisconnect(playerid);
  67. forward Audio_OnTransferFile(playerid, file[], current, total, result);
  68. forward Audio_OnPlay(playerid, handleid);
  69. forward Audio_OnStop(playerid, handleid);
  70. forward Audio_OnTrackChange(playerid, handleid, track[]);
  71. forward Audio_OnRadioStationChange(playerid, station);
  72.  
  73. // Callbacks (Custom)
  74.  
  75. forward Audio_OnGetPosition(playerid, handleid, seconds);
  76.  
  77. // Callback Hook Section
  78.  
  79. static bool:Audio_g_CTS = false;
  80. static bool:Audio_g_OPC = false;
  81. static bool:Audio_g_OPDC = false;
  82.  
  83. public OnFilterScriptInit()
  84. {
  85.     if (!Audio_g_CTS)
  86.     {
  87.         Audio_g_CTS = true;
  88.         Audio_g_OPC = (funcidx("Audio_OnPlayerConnect") != -1);
  89.         Audio_g_OPDC = (funcidx("Audio_OnPlayerDisconnect") != -1);
  90.         Audio_CreateTCPServer(GetServerVarAsInt("port"));
  91.     }
  92.     if (funcidx("Audio_OnFilterScriptInit") != -1)
  93.     {
  94.         return CallLocalFunction("Audio_OnFilterScriptInit", "");
  95.     }
  96.     return 1;
  97. }
  98.  
  99. #if defined _ALS_OnFilterScriptInit
  100.     #undef OnFilterScriptInit
  101. #else
  102.     #define _ALS_OnFilterScriptInit
  103. #endif
  104. #define OnFilterScriptInit Audio_OnFilterScriptInit
  105.  
  106. forward Audio_OnFilterScriptInit();
  107.  
  108. public OnGameModeInit()
  109. {
  110.     if (!Audio_g_CTS)
  111.     {
  112.         Audio_g_CTS = true;
  113.         Audio_g_OPC = (funcidx("Audio_OnPlayerConnect") != -1);
  114.         Audio_g_OPDC = (funcidx("Audio_OnPlayerDisconnect") != -1);
  115.         Audio_CreateTCPServer(GetServerVarAsInt("port"));
  116.     }
  117.     if (funcidx("Audio_OnGameModeInit") != -1)
  118.     {
  119.         return CallLocalFunction("Audio_OnGameModeInit", "");
  120.     }
  121.     return 1;
  122. }
  123.  
  124. #if defined _ALS_OnGameModeInit
  125.     #undef OnGameModeInit
  126. #else
  127.     #define _ALS_OnGameModeInit
  128. #endif
  129. #define OnGameModeInit Audio_OnGameModeInit
  130.  
  131. forward Audio_OnGameModeInit();
  132.  
  133. public OnPlayerConnect(playerid)
  134. {
  135.     if (!IsPlayerNPC(playerid))
  136.     {
  137.         new ip[16], name[MAX_PLAYER_NAME];
  138.         GetPlayerIp(playerid, ip, sizeof(ip));
  139.         GetPlayerName(playerid, name, sizeof(name));
  140.         Audio_AddPlayer(playerid, ip, name);
  141.     }
  142.     if (Audio_g_OPC)
  143.     {
  144.         return CallLocalFunction("Audio_OnPlayerConnect", "d", playerid);
  145.     }
  146.     return 1;
  147. }
  148.  
  149. #if defined _ALS_OnPlayerConnect
  150.     #undef OnPlayerConnect
  151. #else
  152.     #define _ALS_OnPlayerConnect
  153. #endif
  154. #define OnPlayerConnect Audio_OnPlayerConnect
  155.  
  156. forward Audio_OnPlayerConnect(playerid);
  157.  
  158. public OnPlayerDisconnect(playerid, reason)
  159. {
  160.     if (!IsPlayerNPC(playerid))
  161.     {
  162.         Audio_RemovePlayer(playerid);
  163.     }
  164.     if (Audio_g_OPDC)
  165.     {
  166.         return CallLocalFunction("Audio_OnPlayerDisconnect", "dd", playerid, reason);
  167.     }
  168.     return 1;
  169. }
  170.  
  171. #if defined _ALS_OnPlayerDisconnect
  172.     #undef OnPlayerDisconnect
  173. #else
  174.     #define _ALS_OnPlayerDisconnect
  175. #endif
  176. #define OnPlayerDisconnect Audio_OnPlayerDisconnect
  177.  
  178. forward Audio_OnPlayerDisconnect(playerid, reason);
  179.  
  180. // Native Hook Section
  181.  
  182. stock Audio_SetPlayerName(playerid, name[])
  183. {
  184.     new value = SetPlayerName(playerid, name);
  185.     if (value > 0)
  186.     {
  187.         Audio_RenamePlayer(playerid, name);
  188.     }
  189.     return value;
  190. }
  191. #if defined _ALS_SetPlayerName
  192.     #undef SetPlayerName
  193. #else
  194.     #define _ALS_SetPlayerName
  195. #endif
  196. #define SetPlayerName Audio_SetPlayerName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement