1
0

boombox.pwn 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Boombox System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. CMD:setboombox(playerid, params[])
  34. {
  35. if(GetPVarType(playerid, "pBoomBox"))
  36. {
  37. ShowSetStation(playerid);
  38. }
  39. else
  40. {
  41. SendClientMessage(playerid, COLOR_GRAD2, "You don't have a boombox out!");
  42. }
  43. return 1;
  44. }
  45. CMD:shopboombox(playerid, params[])
  46. {
  47. if (PlayerInfo[playerid][pShopTech] < 1)
  48. {
  49. SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
  50. return 1;
  51. }
  52. new giveplayerid, invoice;
  53. if(sscanf(params, "ui", giveplayerid, invoice)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /shopboombox [player] [invoice #]");
  54. new string[128];
  55. if(PlayerInfo[giveplayerid][pBoombox] == 1)
  56. {
  57. PlayerInfo[giveplayerid][pBoombox] = 0;
  58. format(string, sizeof(string), "Your boombox has been taken by Shop Tech %s. ", GetPlayerNameEx(playerid));
  59. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  60. format(string, sizeof(string), "[SHOPBOOMBOX] %s has taken %s(%d) boombox - Invoice %d", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), invoice);
  61. SendClientMessageEx(playerid, COLOR_GRAD1, string);
  62. Log("logs/shoplog.log", string);
  63. }
  64. else
  65. {
  66. PlayerInfo[giveplayerid][pBoombox] = 1;
  67. format(string, sizeof(string), "You have been given a boombox from Shop Tech %s. ", GetPlayerNameEx(playerid));
  68. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  69. format(string, sizeof(string), "[SHOPBOOMBOX] %s has given %s(%d) a boombox - Invoice %d", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), invoice);
  70. SendClientMessageEx(playerid, COLOR_GRAD1, string);
  71. Log("logs/shoplog.log", string);
  72. }
  73. return 1;
  74. }
  75. CMD:placeboombox(playerid, params[])
  76. {
  77. if(PlayerInfo[playerid][pBoombox] == 1 || PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  78. {
  79. if(GetPVarType(playerid, "IsInArena")) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this while being in an arena!");
  80. if(GetPVarInt(playerid, "WatchingTV")) return SendClientMessageEx(playerid, COLOR_GREY, "You can not do this while watching TV!");
  81. if(GetPVarInt(playerid, "Injured") == 1 || PlayerInfo[playerid][pJailTime] > 0 || PlayerInfo[playerid][pHospital] > 0 || IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this right now.");
  82. //if(PlayerInfo[playerid][pVW] == 0 || PlayerInfo[playerid][pInt] == 0) return SendClientMessageEx(playerid, COLOR_WHITE, "You can only place boomboxes inside interiors.");
  83. if(GetPVarType(playerid, "pBoomBox")) return SendClientMessageEx(playerid, COLOR_WHITE, "You already have a boombox out, use /destroyboombox.");
  84. foreach(new i: Player)
  85. {
  86. if(GetPVarType(i, "pBoomBox"))
  87. {
  88. if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "pBoomBoxX"), GetPVarFloat(i, "pBoomBoxY"), GetPVarFloat(i, "pBoomBoxZ")) && GetPVarInt(i, "pBoomBoxVW") == GetPlayerVirtualWorld(playerid))
  89. {
  90. SendClientMessage(playerid, COLOR_WHITE, "You are in range of another boombox, you can't place one here!");
  91. return 1;
  92. }
  93. }
  94. }
  95. new string[128];
  96. format(string, sizeof(string), "%s has placed a boombox!", GetPlayerNameEx(playerid));
  97. ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
  98. new Float:x, Float:y, Float:z, Float:a;
  99. GetPlayerPos(playerid, x, y, z);
  100. GetPlayerFacingAngle(playerid, a);
  101. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
  102. x += (2 * floatsin(-a, degrees));
  103. y += (2 * floatcos(-a, degrees));
  104. z -= 1.0;
  105. SetPVarInt(playerid, "pBoomBox", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, a, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
  106. SetPVarFloat(playerid, "pBoomBoxX", x); SetPVarFloat(playerid, "pBoomBoxY", y); SetPVarFloat(playerid, "pBoomBoxZ", z);
  107. format(string, sizeof(string), "%s's boombox\n{FF0000}/setboombox {FFFF00}or\n{FF0000}/destroyboombox", GetPlayerNameEx(playerid));
  108. SetPVarInt(playerid, "pBoomBoxLabel", _:CreateDynamic3DTextLabel(string, COLOR_YELLOW, x, y, z+0.6, 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
  109. SetPVarInt(playerid, "pBoomBoxArea", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
  110. SetPVarInt(playerid, "pBoomBoxInt", GetPlayerInterior(playerid));
  111. SetPVarInt(playerid, "pBoomBoxVW", GetPlayerVirtualWorld(playerid));
  112. }
  113. else
  114. {
  115. SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have a boom box! Buy from one shop.ng-gaming.net");
  116. }
  117. return 1;
  118. }
  119. CMD:destroyboombox(playerid, params[])
  120. {
  121. if(GetPVarType(playerid, "pBoomBox"))
  122. {
  123. DestroyDynamicObject(GetPVarInt(playerid, "pBoomBox"));
  124. DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "pBoomBoxLabel"));
  125. DeletePVar(playerid, "pBoomBox"); DeletePVar(playerid, "pBoomBoxStation"); DeletePVar(playerid, "pBoomBoxLabel");
  126. DeletePVar(playerid, "pBoomBoxX"); DeletePVar(playerid, "pBoomBoxY"); DeletePVar(playerid, "pBoomBoxZ");
  127. if(GetPVarType(playerid, "pBoomBoxArea"))
  128. {
  129. new string[128];
  130. format(string, sizeof(string), "* %s has destroyed the boombox.", GetPlayerNameEx(playerid));
  131. foreach(new i: Player)
  132. {
  133. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
  134. {
  135. StopAudioStreamForPlayerEx(i);
  136. SendClientMessage(i, COLOR_PURPLE, string);
  137. }
  138. }
  139. DeletePVar(playerid, "pBoomBoxArea");
  140. }
  141. SendClientMessage(playerid, COLOR_WHITE, "You've destroyed your boombox!");
  142. }
  143. else
  144. {
  145. foreach(new i: Player)
  146. {
  147. if(GetPVarType(i, "pBoomBox"))
  148. {
  149. if(GetPVarInt(i, "pBoomBoxVW") == GetPlayerVirtualWorld(playerid) && GetPVarInt(i, "pBoomBoxInt") == GetPlayerInterior(playerid) && IsPlayerInRangeOfPoint(playerid, 5.0, GetPVarFloat(i, "pBoomBoxX"), GetPVarFloat(i, "pBoomBoxY"), GetPVarFloat(i, "pBoomBoxZ")))
  150. {
  151. DestroyDynamicObject(GetPVarInt(i, "pBoomBox"));
  152. DestroyDynamic3DTextLabel(Text3D:GetPVarInt(i, "pBoomBoxLabel"));
  153. DeletePVar(i, "pBoomBox");
  154. DeletePVar(i, "pBoomBoxStation");
  155. DeletePVar(i, "pBoomBoxLabel");
  156. DeletePVar(i, "pBoomBoxX");
  157. DeletePVar(i, "pBoomBoxY");
  158. DeletePVar(i, "pBoomBoxZ");
  159. DeletePVar(i, "pBoomBoxInt");
  160. DeletePVar(i, "pBoomBoxVW");
  161. new string[128];
  162. if(GetPVarType(i, "pBoomBoxArea"))
  163. {
  164. format(string, sizeof(string), "* %s has destroyed the boombox.", GetPlayerNameEx(playerid));
  165. foreach(new pi:Player)
  166. {
  167. if(IsPlayerInDynamicArea(pi, GetPVarInt(i, "pBoomBoxArea")))
  168. {
  169. StopAudioStreamForPlayerEx(pi);
  170. SendClientMessage(pi, COLOR_PURPLE, string);
  171. }
  172. }
  173. DeletePVar(i, "pBoomBoxArea");
  174. }
  175. format(string, sizeof(string), "%s has destroyed your boombox!", GetPlayerNameEx(playerid));
  176. SendClientMessage(i, COLOR_WHITE, string);
  177. return 1;
  178. }
  179. }
  180. }
  181. SendClientMessage(playerid, COLOR_WHITE, "You don't have a boombox or you are not near one to destroy.");
  182. }
  183. return 1;
  184. }