1
0

callsystem.pwn 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Call 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. #include <YSI\y_hooks>
  34. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  35. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  36. switch(dialogid) {
  37. case DIALOG_CALLS_MENU: {
  38. if(!response) return DeletePVar(playerid, "AC"), DeletePVar(playerid, "IC"), DeletePVar(playerid, "Calls"), 1;
  39. if(GetPVarType(playerid, "Calls")) {
  40. switch(listitem) {
  41. case 0: Calls_Group(playerid);
  42. case 1: Calls_Business(playerid);
  43. }
  44. DeletePVar(playerid, "Calls");
  45. return 1;
  46. }
  47. SetPVarInt(playerid, "CALL_CHOICE", listitem);
  48. ShowPlayerDialogEx(playerid, DIALOG_CALLS_MENU2, DIALOG_STYLE_INPUT, "Calls | Specify ID", "Please specify the caller ID (seen in /ac)", "Select", "Cancel");
  49. }
  50. case DIALOG_CALLS_MENU2: {
  51. if(response) {
  52. switch(GetPVarInt(playerid, "CALL_CHOICE")) {
  53. case 0: {
  54. if(GetPVarType(playerid, "AC")) AcceptCall_Group(playerid, strval(inputtext));
  55. if(GetPVarType(playerid, "IC")) IgnoreCall_Group(playerid, strval(inputtext));
  56. }
  57. case 1: {
  58. if(GetPVarType(playerid, "AC")) AcceptCall_Business(playerid, strval(inputtext));
  59. if(GetPVarType(playerid, "IC")) IgnoreCall_Business(playerid, strval(inputtext));
  60. }
  61. }
  62. }
  63. DeletePVar(playerid, "AC");
  64. DeletePVar(playerid, "IC");
  65. DeletePVar(playerid, "CALL_CHOICE");
  66. }
  67. }
  68. return 0;
  69. }
  70. stock SendCallToQueue(callfrom, description[], area[], mainzone[], type, vehicleid = INVALID_VEHICLE_ID)
  71. {
  72. new newid = INVALID_CALL_ID;
  73. for(new i; i < MAX_CALLS; i++)
  74. {
  75. if(Calls[i][HasBeenUsed] == 0)
  76. {
  77. newid = i;
  78. break;
  79. }
  80. }
  81. if(newid != INVALID_CALL_ID)
  82. {
  83. foreach(new i: Player)
  84. {
  85. if(0 <= PlayerInfo[i][pMember] < MAX_GROUPS)
  86. {
  87. for(new j; j < arrGroupData[PlayerInfo[i][pMember]][g_iJCount]; j++)
  88. {
  89. if(strcmp(arrGroupJurisdictions[PlayerInfo[i][pMember]][j][g_iAreaName], area, true) == 0 || strcmp(arrGroupJurisdictions[PlayerInfo[i][pMember]][j][g_iAreaName], mainzone, true) == 0)
  90. {
  91. if((type == 0 || type == 4) && IsACop(i))
  92. {
  93. PlayCrimeReportForPlayer(i, callfrom, 7);
  94. format(szMiscArray, sizeof(szMiscArray), "HQ: All Units APB: Reporter: %s", GetPlayerNameEx(callfrom));
  95. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  96. format(szMiscArray, sizeof(szMiscArray), "HQ: Location: %s, Description: %s", area, description);
  97. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  98. }
  99. if(type == 1 && IsAMedic(i))
  100. {
  101. PlayCrimeReportForPlayer(i, callfrom, 7);
  102. format(szMiscArray, sizeof(szMiscArray), "HQ: All Units APB: Reporter: %s", GetPlayerNameEx(callfrom));
  103. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  104. format(szMiscArray, sizeof(szMiscArray), "HQ: Location: %s, Description: %s", area, description);
  105. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  106. }
  107. if(type == 2 && IsACop(i))
  108. {
  109. PlayCrimeReportForPlayer(i, callfrom, 7);
  110. format(szMiscArray, sizeof(szMiscArray), "HQ: All Units APB: Reporter: %s", GetPlayerNameEx(callfrom));
  111. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  112. format(szMiscArray, sizeof(szMiscArray), "HQ: Location: %s, Description: %s", area, description);
  113. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  114. }
  115. if(type == 3 && (IsACop(i) || IsATowman(i)))
  116. {
  117. PlayCrimeReportForPlayer(i, callfrom, 7);
  118. format(szMiscArray, sizeof(szMiscArray), "HQ: All Units APB: Reporter: %s", GetPlayerNameEx(callfrom));
  119. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  120. format(szMiscArray, sizeof(szMiscArray), "HQ: Location: %s, Description: %s", area, description);
  121. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  122. }
  123. if(type == 5 && (IsACop(i) || IsAMedic(i)))
  124. {
  125. PlayCrimeReportForPlayer(i, callfrom, 7);
  126. format(szMiscArray, sizeof(szMiscArray), "HQ: All Units APB: Reporter: %s", GetPlayerNameEx(callfrom));
  127. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  128. format(szMiscArray, sizeof(szMiscArray), "HQ: Location: %s, Description: %s", area, description);
  129. SendClientMessageEx(i, TEAM_BLUE_COLOR, szMiscArray);
  130. }
  131. }
  132. }
  133. if(type == 6)
  134. {
  135. new x = GetPVarInt(callfrom, "GRPCALL");
  136. Calls[newid][c_iGroupID] = x;
  137. if(PlayerInfo[i][pMember] == x) {
  138. format(szMiscArray, sizeof(szMiscArray), "Landline: Caller: %s | %d", GetPlayerNameEx(callfrom), PlayerInfo[callfrom][pPnumber]);
  139. SendClientMessageEx(i, COLOR_PINK, szMiscArray);
  140. format(szMiscArray, sizeof(szMiscArray), "Landline: Location: %s, Description: %s", area, description);
  141. SendClientMessageEx(i, COLOR_PINK, szMiscArray);
  142. }
  143. }
  144. if(type == 7)
  145. {
  146. new x = GetPVarInt(callfrom, "BUSICALL");
  147. Calls[newid][c_iBusinessID] = x;
  148. if(PlayerInfo[i][pBusiness] == x) {
  149. format(szMiscArray, sizeof(szMiscArray), "Landline: Caller: %s | %d", GetPlayerNameEx(callfrom), PlayerInfo[callfrom][pPnumber]);
  150. SendClientMessageEx(i, COLOR_PINK, szMiscArray);
  151. format(szMiscArray, sizeof(szMiscArray), "Landline: Location: %s, Description: %s", area, description);
  152. SendClientMessageEx(i, COLOR_PINK, szMiscArray);
  153. }
  154. }
  155. }
  156. }
  157. SetPVarInt(callfrom, "Has911Call", 1);
  158. strmid(Calls[newid][Area], area, 0, strlen(area), 28);
  159. strmid(Calls[newid][MainZone], mainzone, 0, strlen(mainzone), 28);
  160. strmid(Calls[newid][Description], description, 0, strlen(description), 128);
  161. Calls[newid][CallFrom] = callfrom;
  162. Calls[newid][Type] = type;
  163. Calls[newid][TimeToExpire] = 0;
  164. Calls[newid][HasBeenUsed] = 1;
  165. Calls[newid][BeingUsed] = 1;
  166. Calls[newid][CallVehicleId] = vehicleid;
  167. Calls[newid][CallExpireTimer] = SetTimerEx("CallTimer", 60000, 0, "d", newid);
  168. new query[512];
  169. mysql_format(MainPipeline, query, sizeof(query), "INSERT INTO `911Calls` (Caller, Phone, Area, MainZone, Description, Type, Time) VALUES ('%s', %d, '%e', '%s', '%e', %d, UNIX_TIMESTAMP())", GetPlayerNameEx(callfrom), PlayerInfo[callfrom][pPnumber], area, mainzone, description, type);
  170. mysql_tquery(MainPipeline, query, "OnQueryFinish", "i", SENDDATA_THREAD);
  171. }
  172. else
  173. {
  174. ClearCalls();
  175. SendCallToQueue(callfrom, description, area, mainzone, type, vehicleid);
  176. }
  177. }
  178. stock ClearCalls()
  179. {
  180. for(new i; i < MAX_CALLS; i++)
  181. {
  182. if(Calls[i][BeingUsed] == 1) DeletePVar(Calls[i][CallFrom], "Has911Call");
  183. strmid(Calls[i][Area], "None", 0, 4, 4);
  184. strmid(Calls[i][MainZone], "None", 0, 4, 4);
  185. strmid(Calls[i][Description], "None", 0, 4, 4);
  186. Calls[i][RespondingID] = INVALID_PLAYER_ID;
  187. Calls[i][CallFrom] = INVALID_PLAYER_ID;
  188. Calls[i][Type] = -1;
  189. Calls[i][TimeToExpire] = 0;
  190. Calls[i][HasBeenUsed] = 0;
  191. Calls[i][BeingUsed] = 0;
  192. Calls[i][CallVehicleId] = INVALID_VEHICLE_ID;
  193. Calls[i][c_iGroupID] = INVALID_GROUP_ID;
  194. Calls[i][c_iBusinessID] = INVALID_BUSINESS_ID;
  195. }
  196. return 1;
  197. }
  198. forward CallTimer(callid);
  199. public CallTimer(callid)
  200. {
  201. if(Calls[callid][BeingUsed] == 1)
  202. {
  203. if(Calls[callid][TimeToExpire] >= 0)
  204. {
  205. Calls[callid][TimeToExpire]++;
  206. Calls[callid][CallExpireTimer] = SetTimerEx("CallTimer", 60000, 0, "d", callid);
  207. }
  208. }
  209. return 1;
  210. }
  211. Calls_Group(playerid) {
  212. if(0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS)
  213. {
  214. new iGroupID = PlayerInfo[playerid][pMember];
  215. switch(arrGroupData[iGroupID][g_iGroupType]) {
  216. case GROUP_TYPE_NEWS: SendClientMessageEx(playerid, arrGroupData[iGroupID][g_hDutyColour] * 256 + 170, "____________________ HOTLINE ____________________");
  217. default: SendClientMessageEx(playerid, arrGroupData[iGroupID][g_hDutyColour] * 256 + 170, "____________________ LANDLINE ____________________");
  218. }
  219. for(new i = 999; i >= 0; i--)
  220. {
  221. if(Calls[i][BeingUsed] == 1)
  222. {
  223. if(Calls[i][Type] == 6 && Calls[i][c_iGroupID] == iGroupID) {
  224. format(szMiscArray, sizeof(szMiscArray), "%s | Call #%i | Description: %s | Location: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  225. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  226. }
  227. else {
  228. for(new j; j < arrGroupData[PlayerInfo[playerid][pMember]][g_iJCount]; j++)
  229. {
  230. if(strcmp(arrGroupJurisdictions[PlayerInfo[playerid][pMember]][j][g_iAreaName], Calls[i][Area], true) == 0 || strcmp(arrGroupJurisdictions[PlayerInfo[playerid][pMember]][j][g_iAreaName], Calls[i][MainZone], true) == 0 || (!strcmp(arrGroupJurisdictions[PlayerInfo[playerid][pMember]][j][g_iAreaName], gMainZones[9][SAZONE_NAME], true) && strcmp(Calls[i][MainZone], gMainZones[3][SAZONE_NAME], true) == -1))
  231. {
  232. if(Calls[i][Type] == 0 && IsACop(playerid))
  233. {
  234. format(szMiscArray, sizeof(szMiscArray), "[EMERGENCY] %s | Call #%i | Description: %s | 10-20: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  235. SendClientMessageEx(playerid, COLOR_YELLOW, szMiscArray);
  236. }
  237. else if(Calls[i][Type] == 1 && IsAMedic(playerid))
  238. {
  239. format(szMiscArray, sizeof(szMiscArray), "%s | Call #%i | Description: %s | 10-20: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  240. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  241. }
  242. else if(Calls[i][Type] == 2 && IsACop(playerid))
  243. {
  244. format(szMiscArray, sizeof(szMiscArray), "%s | Call #%i | Description: %s | 10-20: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  245. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  246. }
  247. else if(Calls[i][Type] == 3 && (IsATowman(playerid)))
  248. {
  249. format(szMiscArray, sizeof(szMiscArray), "[TOWING] %s | Call #%i | Description: %s | 10-20: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  250. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  251. }
  252. else if(Calls[i][Type] == 4 && IsACop(playerid))
  253. {
  254. format(szMiscArray, sizeof(szMiscArray), "%s | Call #%i | Description: %s | 10-20: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  255. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  256. }
  257. else if(Calls[i][Type] == 5 && (IsACop(playerid) || IsAMedic(playerid)))
  258. {
  259. format(szMiscArray, sizeof(szMiscArray), "%s | Call #%i | Description: %s | 10-20: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  260. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. SendClientMessageEx(playerid, arrGroupData[iGroupID][g_hDutyColour] * 256 + 170, "___________________________________________________");
  268. }
  269. }
  270. Calls_Business(playerid) {
  271. if(PlayerInfo[playerid][pBusiness] != INVALID_BUSINESS_ID)
  272. {
  273. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "____________________ COMPANY LINE ____________________");
  274. for(new i = 999; i >= 0; i--)
  275. {
  276. if(Calls[i][BeingUsed] == 1)
  277. {
  278. if(Calls[i][Type] == 7 && Calls[i][c_iBusinessID] == PlayerInfo[playerid][pBusiness])
  279. {
  280. format(szMiscArray, sizeof(szMiscArray), "%s | Call #%i | Description: %s | Location: %s | Pending: %d minutes", GetPlayerNameEx(Calls[i][CallFrom]), i, Calls[i][Description], Calls[i][Area], Calls[i][TimeToExpire]);
  281. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  282. }
  283. }
  284. }
  285. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "___________________________________________________");
  286. }
  287. }
  288. CMD:calls(playerid, params[])
  289. {
  290. if(PlayerInfo[playerid][pBusiness] == INVALID_BUSINESS_ID && PlayerInfo[playerid][pMember] == INVALID_GROUP_ID) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot use this feature.");
  291. SetPVarInt(playerid, "Calls", 1);
  292. ShowPlayerDialogEx(playerid, DIALOG_CALLS_MENU, DIALOG_STYLE_LIST, "Landline Calls", "Group\nBusiness", "Select", "Cancel");
  293. return 1;
  294. }
  295. CMD:ac(playerid, params[])
  296. {
  297. return cmd_acceptcall(playerid, params);
  298. }
  299. AcceptCall_Group(playerid, callid) {
  300. if(0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS)
  301. {
  302. new string[128];
  303. if(callid < 0 || callid > 999) return SendClientMessageEx(playerid, COLOR_GREY, " Call number cannot be below 0 or above 999!");
  304. if(Calls[callid][BeingUsed] == 0) return SendClientMessageEx(playerid, COLOR_GREY, " There is no pending call with that number!");
  305. if(playerid == Calls[callid][CallFrom]) return SendClientMessageEx(playerid, COLOR_GREY, " You can't accept your own call!");
  306. if(((Calls[callid][Type] == 0 || Calls[callid][Type] == 4) && !IsACop(playerid)) || (Calls[callid][Type] == 1 && !IsAMedic(playerid)) || (Calls[callid][Type] == 2 && !IsACop(playerid)) || (Calls[callid][Type] == 3 && !IsACop(playerid) && !IsATowman(playerid))) return SendClientMessageEx(playerid, COLOR_GREY, " You cannot answer this call!");
  307. if(!IsPlayerConnected(Calls[callid][CallFrom]))
  308. {
  309. SendClientMessageEx(playerid, COLOR_GREY, " The caller has disconnected!");
  310. Calls[callid][CallFrom] = INVALID_PLAYER_ID;
  311. Calls[callid][BeingUsed] = 0;
  312. return 1;
  313. }
  314. for(new j; j < arrGroupData[PlayerInfo[playerid][pMember]][g_iJCount]; j++)
  315. {
  316. if(strcmp(arrGroupJurisdictions[PlayerInfo[playerid][pMember]][j][g_iAreaName], Calls[callid][Area], true) == 0 || strcmp(arrGroupJurisdictions[PlayerInfo[playerid][pMember]][j][g_iAreaName], Calls[callid][MainZone], true) == 0)
  317. {
  318. new Float: Pos[3], Float: carPos[3], targetid = Calls[callid][CallFrom], targetslot = GetPlayerVehicle(Calls[callid][CallFrom], Calls[callid][CallVehicleId]);
  319. if(Calls[callid][CallVehicleId] != INVALID_VEHICLE_ID && Calls[callid][Type] == 4) {
  320. switch(PlayerVehicleInfo[targetid][targetslot][pvAlarm]) {
  321. case 1: {
  322. new zone[MAX_ZONE_NAME], mainzone[MAX_ZONE_NAME];
  323. Get3DZone(carPos[0], carPos[1], carPos[2], zone, sizeof(zone));
  324. Get2DMainZone(carPos[0], carPos[1], mainzone, sizeof(mainzone));
  325. format(string, sizeof(string), "This %s(%d) is located in %s(%s).", GetVehicleName(Calls[callid][CallVehicleId]), zone, mainzone);
  326. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  327. }
  328. case 2: {
  329. if(PlayerVehicleInfo[targetid][targetslot][pvAlarmTriggered]) {
  330. if(PlayerVehicleInfo[targetid][targetslot][pvId] != INVALID_PLAYER_VEHICLE_ID)
  331. {
  332. GetVehiclePos(PlayerVehicleInfo[targetid][targetslot][pvId], carPos[0], carPos[1], carPos[2]);
  333. if(CheckPointCheck(playerid))
  334. {
  335. return SendClientMessageEx(playerid, COLOR_WHITE, "Please ensure that your current checkpoint is destroyed first (you either have material packages, or another existing checkpoint).");
  336. }
  337. else
  338. {
  339. new zone[MAX_ZONE_NAME], mainzone[MAX_ZONE_NAME];
  340. Get3DZone(carPos[0], carPos[1], carPos[2], zone, sizeof(zone));
  341. Get2DMainZone(carPos[0], carPos[1], mainzone, sizeof(mainzone));
  342. format(string, sizeof(string), "This %s(%d) is located in %s(%s).", GetVehicleName(Calls[callid][CallVehicleId]), zone, mainzone);
  343. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  344. SetPVarFloat(playerid, "CarLastX", carPos[0]);
  345. SetPVarFloat(playerid, "CarLastY", carPos[1]);
  346. SetPVarFloat(playerid, "CarLastZ", carPos[2]);
  347. SetPVarInt(playerid, "TrackVehicleBurglary", 120);
  348. SetPVarInt(playerid, "CallId", callid);
  349. SetPlayerCheckpoint(playerid, carPos[0], carPos[1], carPos[2], 15.0);
  350. SendClientMessageEx(playerid, COLOR_WHITE, "Hint: Make your way to the checkpoint to find the vehicle(Will only last 2 minutes)!");
  351. }
  352. }
  353. else if(PlayerVehicleInfo[targetid][targetslot][pvImpounded]) SendClientMessageEx(playerid, COLOR_WHITE, "You can not track an impounded vehicle.");
  354. else if(PlayerVehicleInfo[targetid][targetslot][pvDisabled] == 1) SendClientMessageEx(playerid, COLOR_WHITE, "You can not track a disabled vehicle.");
  355. else if(PlayerVehicleInfo[targetid][targetslot][pvSpawned] == 0) SendClientMessageEx(playerid, COLOR_WHITE, "You can not track a stored vehicle.");
  356. else SendClientMessageEx(playerid, COLOR_WHITE, "You can not track a non-existent vehicle.");
  357. }
  358. }
  359. }
  360. }
  361. foreach(new i: Player)
  362. {
  363. if(PlayerInfo[i][pMember] == PlayerInfo[playerid][pMember] && PlayerInfo[playerid][pRank] >= arrGroupData[PlayerInfo[playerid][pMember]][g_iRadioAccess]) {
  364. format(string, sizeof(string), "%s has accepted %s's call from %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]), Calls[callid][Area]);
  365. SendClientMessageEx(i, COLOR_DBLUE, string);
  366. }
  367. if(GetPVarInt(i, "BigEar") == 4 && GetPVarInt(i, "BigEarGroup") == PlayerInfo[playerid][pMember]) {
  368. format(string, sizeof(string), "(BE) %s has accepted %s's call from %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]), Calls[callid][Area]);
  369. SendClientMessageEx(i, COLOR_DBLUE, string);
  370. }
  371. }
  372. PlayCrimeReportForPlayer(playerid, Calls[callid][CallFrom], 8);
  373. AddCallToken(playerid);
  374. format(string, sizeof(string), "%s has accepted your call. You are now in a direct call with them. (/h to hang up)", GetPlayerNameEx(playerid));
  375. SendClientMessageEx(Calls[callid][CallFrom], COLOR_WHITE, string);
  376. format(string, sizeof(string), "You have accepted %s's call. You are now in a direct call with them. (/h to hang up)", GetPlayerNameEx(Calls[callid][CallFrom]));
  377. SendClientMessageEx(playerid, COLOR_WHITE, string);
  378. Mobile[playerid] = Calls[callid][CallFrom];
  379. SetPlayerAttachedObject(playerid, 8, 330, 6);
  380. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  381. Mobile[Calls[callid][CallFrom]] = playerid;
  382. SetPlayerAttachedObject(Calls[callid][CallFrom], 8, 330, 6);
  383. SetPlayerSpecialAction(Calls[callid][CallFrom], SPECIAL_ACTION_USECELLPHONE);
  384. PlayerInfo[playerid][pCallsAccepted]++;
  385. GetPlayerPos(Calls[callid][CallFrom], Pos[0], Pos[1], Pos[2]);
  386. SetPlayerCheckpoint(playerid, Pos[0], Pos[1], Pos[2], 15.0);
  387. Calls[callid][RespondingID] = playerid;
  388. Calls[callid][BeingUsed] = 0;
  389. Calls[callid][TimeToExpire] = 0;
  390. strmid(Calls[callid][Area], "None", 0, 4, 4);
  391. strmid(Calls[callid][MainZone], "None", 0, 4, 4);
  392. strmid(Calls[callid][Description], "None", 0, 4, 4);
  393. DeletePVar(Calls[callid][CallFrom], "Has911Call");
  394. return 1;
  395. }
  396. }
  397. return SendClientMessageEx(playerid, COLOR_GREY, " This call is not within your jurisdiction!");
  398. }
  399. return 1;
  400. }
  401. AcceptCall_Business(playerid, callid) {
  402. if(0 <= PlayerInfo[playerid][pBusiness] < MAX_BUSINESSES) {
  403. if(callid < 0 || callid > 999) return SendClientMessageEx(playerid, COLOR_GREY, " Call number cannot be below 0 or above 999!");
  404. if(Calls[callid][BeingUsed] == 0) return SendClientMessageEx(playerid, COLOR_GREY, " There is no pending call with that number!");
  405. if(playerid == Calls[callid][CallFrom]) return SendClientMessageEx(playerid, COLOR_GREY, " You can't accept your own call!");
  406. if(Calls[callid][Type] != 7) return SendClientMessageEx(playerid, COLOR_GREY, " You cannot answer this call!");
  407. if(!IsPlayerConnected(Calls[callid][CallFrom]))
  408. {
  409. SendClientMessageEx(playerid, COLOR_GREY, " The caller has disconnected!");
  410. Calls[callid][CallFrom] = INVALID_PLAYER_ID;
  411. Calls[callid][BeingUsed] = 0;
  412. return 1;
  413. }
  414. foreach(new i: Player)
  415. {
  416. if(PlayerInfo[i][pMember] == PlayerInfo[playerid][pMember] && PlayerInfo[playerid][pRank] >= arrGroupData[PlayerInfo[playerid][pMember]][g_iRadioAccess]) {
  417. format(szMiscArray, sizeof(szMiscArray), "%s has accepted %s's call from %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]), Calls[callid][Area]);
  418. SendClientMessageEx(i, COLOR_DBLUE, szMiscArray);
  419. }
  420. if(GetPVarInt(i, "BigEar") == 4 && GetPVarInt(i, "BigEarGroup") == PlayerInfo[playerid][pMember]) {
  421. format(szMiscArray, sizeof(szMiscArray), "(BE) %s has accepted %s's call from %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]), Calls[callid][Area]);
  422. SendClientMessageEx(i, COLOR_DBLUE, szMiscArray);
  423. }
  424. }
  425. new Float: fPos[3];
  426. PlayCrimeReportForPlayer(playerid, Calls[callid][CallFrom], 8);
  427. AddCallToken(playerid);
  428. format(szMiscArray, sizeof(szMiscArray), "%s has accepted your call. You are now in a direct call with them. (/h to hang up)", GetPlayerNameEx(playerid));
  429. SendClientMessageEx(Calls[callid][CallFrom], COLOR_WHITE, szMiscArray);
  430. format(szMiscArray, sizeof(szMiscArray), "You have accepted %s's call. You are now in a direct call with them. (/h to hang up)", GetPlayerNameEx(Calls[callid][CallFrom]));
  431. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  432. Mobile[playerid] = Calls[callid][CallFrom];
  433. SetPlayerAttachedObject(playerid, 8, 330, 6);
  434. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  435. Mobile[Calls[callid][CallFrom]] = playerid;
  436. SetPlayerAttachedObject(Calls[callid][CallFrom], 8, 330, 6);
  437. SetPlayerSpecialAction(Calls[callid][CallFrom], SPECIAL_ACTION_USECELLPHONE);
  438. PlayerInfo[playerid][pCallsAccepted]++;
  439. GetPlayerPos(Calls[callid][CallFrom], fPos[0], fPos[1], fPos[2]);
  440. SetPlayerCheckpoint(playerid, fPos[0], fPos[1], fPos[2], 15.0);
  441. Calls[callid][RespondingID] = playerid;
  442. Calls[callid][BeingUsed] = 0;
  443. Calls[callid][TimeToExpire] = 0;
  444. strmid(Calls[callid][Area], "None", 0, 4, 4);
  445. strmid(Calls[callid][MainZone], "None", 0, 4, 4);
  446. strmid(Calls[callid][Description], "None", 0, 4, 4);
  447. DeletePVar(Calls[callid][CallFrom], "Has911Call");
  448. }
  449. return 1;
  450. }
  451. IgnoreCall_Group(playerid, callid) {
  452. if(0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS)
  453. {
  454. new string[128];
  455. if(callid < 0 || callid > 999) return SendClientMessageEx(playerid, COLOR_GREY, " Call number cannot be below 0 or above 999!");
  456. if(Calls[callid][BeingUsed] == 0) return SendClientMessageEx(playerid, COLOR_GREY, " There is no pending call with that number!");
  457. if(playerid == Calls[callid][CallFrom]) return SendClientMessageEx(playerid, COLOR_GREY, " You can't drop your own call!");
  458. if((Calls[callid][Type] == 0 && !IsACop(playerid)) || (Calls[callid][Type] == 1 && !IsAMedic(playerid)) || (Calls[callid][Type] == 2 && !IsACop(playerid)) || (Calls[callid][Type] == 3 && !IsACop(playerid) && !IsATowman(playerid))) return SendClientMessageEx(playerid, COLOR_GREY, " You cannot answer this call!");
  459. if(!IsPlayerConnected(Calls[callid][CallFrom]))
  460. {
  461. SendClientMessageEx(playerid, COLOR_GREY, " The caller has disconnected!");
  462. Calls[callid][CallFrom] = INVALID_PLAYER_ID;
  463. Calls[callid][BeingUsed] = 0;
  464. return 1;
  465. }
  466. for(new j; j < arrGroupData[PlayerInfo[playerid][pMember]][g_iJCount]; j++)
  467. {
  468. foreach(new i: Player)
  469. {
  470. if(PlayerInfo[i][pMember] == PlayerInfo[playerid][pMember] && PlayerInfo[playerid][pRank] >= arrGroupData[PlayerInfo[playerid][pMember]][g_iRadioAccess]) {
  471. format(string, sizeof(string), "%s has dropped %s's call.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]));
  472. SendClientMessageEx(i, COLOR_DBLUE, string);
  473. }
  474. if(GetPVarInt(i, "BigEar") == 4 && GetPVarInt(i, "BigEarGroup") == PlayerInfo[playerid][pMember]) {
  475. format(string, sizeof(string), "(BE) %s has dropped %s's call.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]));
  476. SendClientMessageEx(i, COLOR_DBLUE, string);
  477. }
  478. }
  479. DeletePVar(Calls[callid][CallFrom], "Has911Call");
  480. Calls[callid][CallFrom] = INVALID_PLAYER_ID;
  481. Calls[callid][BeingUsed] = 0;
  482. Calls[callid][TimeToExpire] = 0;
  483. strmid(Calls[callid][Area], "None", 0, 4, 4);
  484. strmid(Calls[callid][MainZone], "None", 0, 4, 4);
  485. strmid(Calls[callid][Description], "None", 0, 4, 4);
  486. return 1;
  487. }
  488. return SendClientMessageEx(playerid, COLOR_GREY, " This call is not within your jurisdiction!");
  489. }
  490. return 1;
  491. }
  492. IgnoreCall_Business(playerid, callid) {
  493. if(0 <= PlayerInfo[playerid][pBusiness] < MAX_BUSINESSES)
  494. {
  495. new string[128];
  496. if(callid < 0 || callid > 999) return SendClientMessageEx(playerid, COLOR_GREY, " Call number cannot be below 0 or above 999!");
  497. if(Calls[callid][BeingUsed] == 0) return SendClientMessageEx(playerid, COLOR_GREY, " There is no pending call with that number!");
  498. if(playerid == Calls[callid][CallFrom]) return SendClientMessageEx(playerid, COLOR_GREY, " You can't drop your own call!");
  499. if(Calls[callid][Type] != 7) return SendClientMessageEx(playerid, COLOR_GREY, " You cannot ignore this call!");
  500. if(!IsPlayerConnected(Calls[callid][CallFrom]))
  501. {
  502. SendClientMessageEx(playerid, COLOR_GREY, " The caller has disconnected!");
  503. Calls[callid][CallFrom] = INVALID_PLAYER_ID;
  504. Calls[callid][BeingUsed] = 0;
  505. return 1;
  506. }
  507. for(new j; j < arrGroupData[PlayerInfo[playerid][pMember]][g_iJCount]; j++)
  508. {
  509. foreach(new i: Player)
  510. {
  511. if(PlayerInfo[i][pMember] == PlayerInfo[playerid][pMember] && PlayerInfo[playerid][pRank] >= arrGroupData[PlayerInfo[playerid][pMember]][g_iRadioAccess]) {
  512. format(string, sizeof(string), "%s has dropped %s's call.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]));
  513. SendClientMessageEx(i, COLOR_DBLUE, string);
  514. }
  515. if(GetPVarInt(i, "BigEar") == 4 && GetPVarInt(i, "BigEarGroup") == PlayerInfo[playerid][pMember]) {
  516. format(string, sizeof(string), "(BE) %s has dropped %s's call.", GetPlayerNameEx(playerid), GetPlayerNameEx(Calls[callid][CallFrom]));
  517. SendClientMessageEx(i, COLOR_DBLUE, string);
  518. }
  519. }
  520. DeletePVar(Calls[callid][CallFrom], "Has911Call");
  521. Calls[callid][CallFrom] = INVALID_PLAYER_ID;
  522. Calls[callid][BeingUsed] = 0;
  523. Calls[callid][TimeToExpire] = 0;
  524. strmid(Calls[callid][Area], "None", 0, 4, 4);
  525. strmid(Calls[callid][MainZone], "None", 0, 4, 4);
  526. strmid(Calls[callid][Description], "None", 0, 4, 4);
  527. return 1;
  528. }
  529. return SendClientMessageEx(playerid, COLOR_GREY, " This call is not within your jurisdiction!");
  530. }
  531. return 1;
  532. }
  533. CMD:acceptcall(playerid, params[])
  534. {
  535. if(PlayerInfo[playerid][pBusiness] == INVALID_BUSINESS_ID && PlayerInfo[playerid][pMember] == INVALID_GROUP_ID) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot use this feature.");
  536. SetPVarInt(playerid, "AC", 1);
  537. ShowPlayerDialogEx(playerid, DIALOG_CALLS_MENU, DIALOG_STYLE_LIST, "Landline Calls", "Group\nBusiness", "Select", "Cancel");
  538. return 1;
  539. }
  540. CMD:ic(playerid, params[])
  541. {
  542. return cmd_ignorecall(playerid, params);
  543. }
  544. CMD:ignorecall(playerid, params[])
  545. {
  546. if(PlayerInfo[playerid][pBusiness] == INVALID_BUSINESS_ID && PlayerInfo[playerid][pMember] == INVALID_GROUP_ID) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot use this feature.");
  547. SetPVarInt(playerid, "IC", 1);
  548. ShowPlayerDialogEx(playerid, DIALOG_CALLS_MENU, DIALOG_STYLE_LIST, "Landline Calls", "Group\nBusiness", "Select", "Cancel");
  549. return 1;
  550. }
  551. CMD:cancelcall(playerid, params[])
  552. {
  553. for(new i = 0; i < MAX_CALLS; i++)
  554. {
  555. if(Calls[i][CallFrom] == playerid)
  556. {
  557. Calls[i][CallFrom] = INVALID_PLAYER_ID;
  558. Calls[i][BeingUsed] = 0;
  559. Calls[i][TimeToExpire] = 0;
  560. strmid(Calls[i][Area], "None", 0, 4, 4);
  561. strmid(Calls[i][MainZone], "None", 0, 4, 4);
  562. strmid(Calls[i][Description], "None", 0, 4, 4);
  563. DeletePVar(playerid, "Has911Call");
  564. return SendClientMessageEx(playerid, COLOR_WHITE, "You have dropped your call." );
  565. }
  566. }
  567. SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have any pending calls.");
  568. return 1;
  569. }
  570. CMD:clearallcalls(playerid, params[])
  571. {
  572. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pFactionModerator] >= 1) {
  573. new string[128];
  574. ClearCalls();
  575. SendClientMessageEx(playerid,COLOR_GRAD1, "You have cleared all pending calls.");
  576. format(string, sizeof(string), "AdmCmd: %s has cleared all pending calls.", GetPlayerNameEx(playerid));
  577. ABroadCast(COLOR_LIGHTRED, string, 3);
  578. }
  579. else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  580. return 1;
  581. }