phone.pwn 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Phone 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. forward RingToner();
  34. public RingToner()
  35. {
  36. foreach(new i: Player)
  37. {
  38. if(RingTone[i] != 6 && RingTone[i] != 0 && RingTone[i] < 11)
  39. {
  40. RingTone[i] = RingTone[i] -1;
  41. PlayerPlaySound(i, 1138, 0.0, 0.0, 0.0);
  42. }
  43. if(RingTone[i] == 6)
  44. {
  45. RingTone[i] = RingTone[i] -1;
  46. }
  47. if(RingTone[i] == 20)
  48. {
  49. RingTone[i] = RingTone[i] -1;
  50. PlayerPlaySound(i, 1139, 0.0, 0.0, 0.0);
  51. }
  52. }
  53. SetTimer("RingTonerRev", 1000, 0);
  54. return 1;
  55. }
  56. forward RingTonerRev();
  57. public RingTonerRev()
  58. {
  59. foreach(new i: Player)
  60. {
  61. if(RingTone[i] != 5 && RingTone[i] != 0 && RingTone[i] < 10)
  62. {
  63. RingTone[i] = RingTone[i] -1;
  64. PlayerPlaySound(i, 1137, 0.0, 0.0, 0.0);
  65. }
  66. if(RingTone[i] == 5)
  67. {
  68. RingTone[i] = RingTone[i] -1;
  69. }
  70. if(RingTone[i] == 19)
  71. {
  72. PlayerPlaySound(i, 1139, 0.0, 0.0, 0.0);
  73. RingTone[i] = 0;
  74. }
  75. }
  76. SetTimer("RingToner", 1000, 0);
  77. return 1;
  78. }
  79. CMD:cellphonehelp(playerid, params[])
  80. {
  81. SetPVarInt(playerid, "HelpResultCat0", 4);
  82. Help_ListCat(playerid, DIALOG_HELPCATOTHER1);
  83. return 1;
  84. }
  85. CMD:ocellphonehelp(playerid, params[])
  86. {
  87. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  88. if (PlayerInfo[playerid][pPnumber] != 0) {
  89. SendClientMessageEx(playerid, COLOR_WHITE,"*** HELP *** - type a command for more infomation.");
  90. SendClientMessageEx(playerid, COLOR_GRAD3,"*** CELLPHONE *** /call 'eg: /call 911' /sms (/p)ickup (/h)angup /speakerphone /number");
  91. }
  92. else {
  93. SendClientMessageEx(playerid, COLOR_WHITE,"You can buy a cell phone in any 24-7");
  94. }
  95. return 1;
  96. }
  97. CMD:phoneprivacy(playerid, params[])
  98. {
  99. if(PlayerInfo[playerid][pPnumber] != 0 && PlayerInfo[playerid][pDonateRank] >= 2)
  100. {
  101. if(PlayerInfo[playerid][pPhonePrivacy] == 1)
  102. {
  103. PlayerInfo[playerid][pPhonePrivacy] = 0;
  104. SendClientMessageEx(playerid, COLOR_WHITE, "You have disabled the phone privacy feature.");
  105. }
  106. else
  107. {
  108. PlayerInfo[playerid][pPhonePrivacy] = 1;
  109. SendClientMessageEx(playerid, COLOR_WHITE, "You have enabled the phone privacy feature.");
  110. }
  111. }
  112. else
  113. {
  114. SendClientMessageEx(playerid, COLOR_WHITE, "You don't have a phone or you aren't a Silver VIP.");
  115. }
  116. return 1;
  117. }
  118. CMD:speakerphone(playerid, params[])
  119. {
  120. if(PlayerInfo[playerid][pPnumber] != 0)
  121. {
  122. if(PlayerInfo[playerid][pSpeakerPhone] == 1)
  123. {
  124. PlayerInfo[playerid][pSpeakerPhone] = 0;
  125. SendClientMessageEx(playerid, COLOR_WHITE, "You have disabled the speakerphone feature on your phone.");
  126. }
  127. else
  128. {
  129. PlayerInfo[playerid][pSpeakerPhone] = 1;
  130. SendClientMessageEx(playerid, COLOR_WHITE, "You have enabled the speakerphone feature on your phone.");
  131. }
  132. }
  133. else
  134. {
  135. SendClientMessageEx(playerid, COLOR_WHITE, "You don't have a phone.");
  136. }
  137. return 1;
  138. }
  139. CMD:colorcar(playerid, params[]) {
  140. new iColors[2];
  141. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not in a vehicle.");
  142. else if(PlayerInfo[playerid][pSpraycan] == 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "Your spraycan is empty.");
  143. if(sscanf(params, "ii", iColors[0], iColors[1])) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /colorcar [ID 1] [ID 2]. Colors must be an ID.");
  144. else if((PlayerInfo[playerid][pDonateRank] == 0) && (iColors[0] > 127 || iColors[1] > 127)) return SendClientMessageEx(playerid, COLOR_GREY, "Only VIPs can use special color IDs above 127.");
  145. else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
  146. new szMessage[60];
  147. for(new i = 0; i < MAX_PLAYERVEHICLES; i++)
  148. {
  149. if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][i][pvId]))
  150. {
  151. PlayerVehicleInfo[playerid][i][pvColor1] = iColors[0], PlayerVehicleInfo[playerid][i][pvColor2] = iColors[1];
  152. ChangeVehicleColor(PlayerVehicleInfo[playerid][i][pvId], PlayerVehicleInfo[playerid][i][pvColor1], PlayerVehicleInfo[playerid][i][pvColor2]);
  153. PlayerInfo[playerid][pSpraycan]--;
  154. g_mysql_SaveVehicle(playerid, i);
  155. format(szMessage, sizeof(szMessage), "You have changed the colors of your vehicle to ID %d, %d.", iColors[0], iColors[1]);
  156. return SendClientMessageEx(playerid, COLOR_GRAD2, szMessage);
  157. }
  158. }
  159. for(new i = 0; i < sizeof(VIPVehicles); i++)
  160. {
  161. if(IsPlayerInVehicle(playerid, VIPVehicles[i]))
  162. {
  163. ChangeVehicleColor(VIPVehicles[i], iColors[0], iColors[1]);
  164. PlayerInfo[playerid][pSpraycan]--;
  165. format(szMessage, sizeof(szMessage), "You have changed the colors of this vehicle to ID %d, %d.", iColors[0], iColors[1]);
  166. return SendClientMessageEx(playerid, COLOR_GRAD2, szMessage);
  167. }
  168. }
  169. for(new i = 0; i < sizeof(FamedVehicles); i++)
  170. {
  171. if(IsPlayerInVehicle(playerid, FamedVehicles[i]))
  172. {
  173. ChangeVehicleColor(FamedVehicles[i], iColors[0], iColors[1]);
  174. PlayerInfo[playerid][pSpraycan]--;
  175. format(szMessage, sizeof(szMessage), "You have changed the colors of this vehicle to ID %d, %d.", iColors[0], iColors[1]);
  176. return SendClientMessageEx(playerid, COLOR_GRAD2, szMessage);
  177. }
  178. }
  179. SendClientMessageEx(playerid, COLOR_GREY, "You can't spray other people's vehicles.");
  180. return 1;
  181. }
  182. CMD:number(playerid, params[]) {
  183. if(PlayerInfo[playerid][pPhoneBook] == 1) {
  184. new
  185. iTarget;
  186. if(sscanf(params, "u", iTarget)) {
  187. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /number [player]");
  188. }
  189. else if(IsPlayerConnected(iTarget)) {
  190. new
  191. szNumber[16 + MAX_PLAYER_NAME];
  192. format(szNumber, sizeof(szNumber), "* %s (%i)", GetPlayerNameEx(iTarget), PlayerInfo[iTarget][pPnumber]);
  193. SendClientMessageEx(playerid, COLOR_GRAD1, szNumber);
  194. }
  195. else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
  196. }
  197. else SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have a phone book.");
  198. return 1;
  199. }
  200. CMD:tempnum(playerid, params[]) {
  201. return cmd_tempnumber(playerid, params);
  202. }
  203. CMD:tempnumber(playerid, params[]){
  204. if (PlayerInfo[playerid][pMember] != INVALID_GROUP_ID && PlayerInfo[playerid][pRank] >= arrGroupData[PlayerInfo[playerid][pMember]][gTempNum] || IsAHitman(playerid)) {
  205. new num;
  206. if(TempNumber[playerid] == 1) {
  207. SendClientMessageEx(playerid, COLOR_GREY, "Your temporary number has been disabled and your original number has been restored.");
  208. TempNumber[playerid] = 0;
  209. PlayerInfo[playerid][pPnumber] = GetPVarInt(playerid, "oldnum");
  210. return 1;
  211. }
  212. if(sscanf(params, "i", num) && TempNumber[playerid] == 0)
  213. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /tempnumber [number]");
  214. if(strlen(params) > 10 || strlen(params) < 2)
  215. return SendClientMessage(playerid, COLOR_GREY, "The temporary phone number can only be between 2 and 10 digits long.");
  216. if(PlayerInfo[playerid][pPnumber] == num)
  217. return SendClientMessageEx(playerid,COLOR_GREY,"You cannot set your temporary number to your existing number");
  218. else {
  219. SetPVarInt(playerid, "oldnum", PlayerInfo[playerid][pPnumber]);
  220. SetPVarInt(playerid, "tempnum", num);
  221. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT `Username` FROM `accounts` WHERE `PhoneNr` = '%d'",num);
  222. mysql_tquery(MainPipeline, szMiscArray, "OnPhoneNumberCheck", "ii", playerid, 5);
  223. }
  224. } else SendClientMessageEx(playerid, COLOR_GREY, "You do not have access to this command.");
  225. return 1;
  226. }
  227. /*
  228. CMD:ringtone(playerid, params[])
  229. {
  230. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen")) {
  231. return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  232. }
  233. if(!IsPlayerInAnyVehicle(playerid))
  234. {
  235. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  236. SetPlayerAttachedObject(playerid, 9, 330, 6);
  237. }
  238. return ShowPlayerDialogEx(playerid,RTONEMENU,DIALOG_STYLE_LIST,"Ringtone - Change Your Ringtone:","Ringtone 1\nRingtone 2\nRingtone 3\nRingtone 4\nRingtone 5\nRingtone 6\nRingtone 7\nRingtone 8\nRingtone 9\nTurn Off","Select","Close");
  239. }
  240. */
  241. CMD:setautoreply(playerid, params[])
  242. {
  243. if(strlen(PlayerInfo[playerid][pAutoTextReply]) > 0)
  244. {
  245. strdel(PlayerInfo[playerid][pAutoTextReply], 0, 64);
  246. SendClientMessageEx(playerid, COLOR_WHITE, "You have disabled auto reply.");
  247. return 1;
  248. }
  249. if(PlayerInfo[playerid][pDonateRank] < 2)
  250. {
  251. SendClientMessageEx(playerid, COLOR_GREY, "You aren't a VIP.");
  252. return 1;
  253. }
  254. if(isnull(params))
  255. {
  256. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setautoreply [text]");
  257. return 1;
  258. }
  259. new string[128];
  260. if(strlen(params) >= 1 && strlen(params) < 63)
  261. {
  262. format(PlayerInfo[playerid][pAutoTextReply], 64, "%s", params);
  263. format(string, sizeof(string), "You have changed your autotext response to: %s", params);
  264. SendClientMessageEx(playerid, COLOR_WHITE, string);
  265. }
  266. else
  267. {
  268. SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Your autotext response must consist of at least 1 character and can't exceed 64 characters.");
  269. }
  270. return 1;
  271. }
  272. CMD:call(playerid, params[])
  273. {
  274. new string[128], phonenumb;
  275. if(sscanf(params, "d", phonenumb)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /call [phonenumber]");
  276. if(PlayerInfo[playerid][pJailTime] > 0 && !GetPVarType(playerid, "PayPhone"))
  277. {
  278. SendClientMessageEx(playerid,COLOR_GREY,"You can't use your phone while in jail.");
  279. return 1;
  280. }
  281. if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || GetPVarInt(playerid, "pBagged") >= 1)
  282. {
  283. SendClientMessageEx(playerid,COLOR_GREY,"You can't use your phone whilist restrained.");
  284. return 1;
  285. }
  286. if(!GetPVarType(playerid, "PayPhone")) {
  287. if(PlayerInfo[playerid][pPnumber] == 0)
  288. {
  289. SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone.");
  290. return 1;
  291. }
  292. if(PhoneOnline[playerid] > 0)
  293. {
  294. SendClientMessageEx(playerid, COLOR_GREY, "Your phone is off.");
  295. return 1;
  296. }
  297. }
  298. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen") || PlayerInfo[playerid][pHospital] > 0) {
  299. return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  300. }
  301. format(string, sizeof(string), "* %s takes out a cellphone.", GetPlayerNameEx(playerid));
  302. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  303. switch(phonenumb) {
  304. case 911: {
  305. if(PlayerInfo[playerid][pJailTime] > 0 && !GetPVarType(playerid, "PayPhone")) return SendClientMessageEx(playerid, COLOR_WHITE, "Cannot use this whilst in prison!");
  306. if(GetPVarType(playerid, "Has911Call")) SendClientMessageEx(playerid, COLOR_GREY, "You can only have one active call at a time. (/cancelcall)");
  307. else if(PlayerInfo[playerid][p911Muted] != 0) ShowPlayerDialogEx(playerid, 7955, DIALOG_STYLE_MSGBOX, "Call Blocked", "You are currently blocked from using 911 emergency services. This is generally caused by abuse of services.\n\n((Use /report to report for an unmute))", "Close", "");
  308. else ShowPlayerDialogEx(playerid, DIALOG_911MENU, DIALOG_STYLE_LIST, "911 Emergency Services", "Emergency\nMedical\nPolice Assistance (Non-Emergency)\nTowing\nVehicle Burglary (In Progress)\nFire", "Select", "End Call");
  309. return 1;
  310. }
  311. case 18004444, 18001800, 18008080, 18001111, 18001020: {
  312. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_WHITE, "Cannot use this whilst in prison!");
  313. if(GetPVarType(playerid, "Has911Call")) SendClientMessageEx(playerid, COLOR_GREY, "You can only have one active call at a time. (/cancelcall)");
  314. else {
  315. new iGroupID;
  316. if(phonenumb == 18004444) iGroupID = 5;
  317. if(phonenumb == 18001800) iGroupID = 12;
  318. if(phonenumb == 18008080) iGroupID = 4;
  319. if(phonenumb == 18001111) iGroupID = 6; // SATR
  320. if(phonenumb == 18001020) iGroupID = 2; // SAPS
  321. if(GetPVarType(playerid, "PayPhone")) TogglePlayerControllable(playerid, false);
  322. format(szMiscArray, sizeof(szMiscArray), "GROUP ID: %d", iGroupID);
  323. SendClientMessage(playerid, COLOR_YELLOW, szMiscArray);
  324. SetPVarInt(playerid, "GRPCALL", iGroupID);
  325. format(szMiscArray, sizeof(szMiscArray), "{%s}%s's Hotline", Group_NumToDialogHex(arrGroupData[iGroupID][g_hDutyColour]), arrGroupData[iGroupID][g_szGroupName]);
  326. ShowPlayerDialogEx(playerid, DIALOG_HOTLINE, DIALOG_STYLE_INPUT, szMiscArray, "Please let us know briefly about your needs.", "Enter", "End Call");
  327. }
  328. return 1;
  329. }
  330. /*case 1738: {
  331. if(!GetPVarType(playerid, "ShipmentCallActive"))
  332. {
  333. SetPVarInt(playerid, "ShipmentCallActive", 1);
  334. SendClientMessageEx(playerid, COLOR_PINK, "** An unknown person picks up the phone.");
  335. SetTimerEx("ShipmentConvo", 2000, false, "ii", playerid, 1);
  336. }
  337. return 1;
  338. }*/
  339. }
  340. if(GetPVarType(playerid, "BUSICALL")) {
  341. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_WHITE, "Cannot use this whilist in prison!");
  342. if(GetPVarType(playerid, "Has911Call")) SendClientMessageEx(playerid, COLOR_GREY, "You can only have one active call at a time. (/cancelcall)");
  343. else {
  344. new i = GetPVarInt(playerid, "BUSICALL");
  345. format(szMiscArray, sizeof(szMiscArray), "%s's Landline | %d", Businesses[i][bName], Businesses[i][bPhoneNr]);
  346. ShowPlayerDialogEx(playerid, DIALOG_HOTLINE, DIALOG_STYLE_INPUT, szMiscArray, "Please let us know briefly about your needs.", "Enter", "End Call");
  347. }
  348. return 1;
  349. }
  350. if(GetPVarType(playerid, "PayPhone")) {
  351. new i = GetPVarInt(playerid, "PayPhone");
  352. if(arrPayPhoneData[i][pp_iNumber] == phonenumb) {
  353. DeletePVar(playerid, "PayPhone");
  354. return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot call the pay phone you're calling from.");
  355. }
  356. }
  357. for(new i; i < MAX_PAYPHONES; ++i) {
  358. if(IsValidDynamicArea(arrPayPhoneData[i][pp_iAreaID] && phonenumb == arrPayPhoneData[i][pp_iNumber])) {
  359. if(arrPayPhoneData[i][pp_iCallerID] != INVALID_PLAYER_ID) return SendClientMessageEx(playerid, COLOR_GRAD1, "This pay phone is already in use.");
  360. SetPVarInt(playerid, "PayPhone", i);
  361. arrPayPhoneData[i][pp_iCallerID] = playerid;
  362. PayPhone_UpdateTextLabel(i, 1);
  363. Mobile[playerid] = 2000; // trial
  364. SendClientMessageEx(playerid, COLOR_GRAD1, "Dialing pay phone...");
  365. SendClientMessageEx(playerid, COLOR_WHITE, "HINT: You now use T to talk on your cellphone, type /hangup to hang up.");
  366. CellTime[playerid] = 1;
  367. SetPlayerAttachedObject(playerid, 8, 330, 6);
  368. return SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  369. }
  370. }
  371. for(new i; i < MAX_BUSINESSES; ++i) {
  372. if(IsValidBusinessID(i)) {
  373. if(phonenumb == Businesses[i][bPhoneNr]) {
  374. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_WHITE, "Cannot use this whilist in prison!");
  375. if(GetPVarType(playerid, "Has911Call")) SendClientMessageEx(playerid, COLOR_GREY, "You can only have one active call at a time. (/cancelcall)");
  376. else {
  377. SetPVarInt(playerid, "BUSICALL", i);
  378. format(szMiscArray, sizeof(szMiscArray), "%s's Company Line | %d", Businesses[i][bName], Businesses[i][bPhoneNr]);
  379. ShowPlayerDialogEx(playerid, DIALOG_HOTLINE, DIALOG_STYLE_INPUT, szMiscArray, "Please let us know briefly about your needs.", "Enter", "End Call");
  380. }
  381. return 1;
  382. }
  383. }
  384. }
  385. if(phonenumb == PlayerInfo[playerid][pPnumber])
  386. {
  387. SendClientMessageEx(playerid, COLOR_GRAD2, " You cannot call yourself...");
  388. return 1;
  389. }
  390. if(Mobile[playerid] != INVALID_PLAYER_ID)
  391. {
  392. SendClientMessageEx(playerid, COLOR_GRAD2, " You are already on a call...");
  393. return 1;
  394. }
  395. foreach(new i: Player)
  396. {
  397. if(PlayerInfo[i][pPnumber] == phonenumb && phonenumb != 0)
  398. {
  399. Mobile[playerid] = i; //caller connecting
  400. if(IsPlayerConnected(i))
  401. {
  402. if(i != INVALID_PLAYER_ID)
  403. {
  404. if(PhoneOnline[i] > 0)
  405. {
  406. SendClientMessageEx(playerid, COLOR_GREY, "That player's phone is switched off.");
  407. Mobile[playerid] = INVALID_PLAYER_ID;
  408. DeletePVar(playerid, "PayPhone");
  409. return 1;
  410. }
  411. if(Mobile[i] != INVALID_PLAYER_ID)
  412. {
  413. SendClientMessageEx(playerid, COLOR_GRAD2, "You just get a busy tone...");
  414. Mobile[playerid] = INVALID_PLAYER_ID;
  415. DeletePVar(playerid, "PayPhone");
  416. return 1;
  417. }
  418. if(Spectating[i]!=0)
  419. {
  420. SendClientMessageEx(playerid, COLOR_GRAD2, "You just get a busy tone...");
  421. Mobile[playerid] = INVALID_PLAYER_ID;
  422. DeletePVar(playerid, "PayPhone");
  423. return 1;
  424. }
  425. if(Mobile[i] == INVALID_PLAYER_ID)
  426. {
  427. if(GetPVarType(playerid, "PayPhone")) {
  428. format(string, sizeof(string), "Your mobile is ringing - type /p to answer it. [Caller: Pay Phone (%d)]", arrPayPhoneData[GetPVarInt(playerid, "PayPhone")][pp_iNumber]);
  429. TogglePlayerControllable(playerid, false);
  430. SendClientMessageEx(i, COLOR_YELLOW, string);
  431. }
  432. else {
  433. format(string, sizeof(string), "Your mobile is ringing - type /p to answer it. [Caller ID: %d]", PlayerInfo[playerid][pPnumber]);
  434. SendClientMessageEx(i, COLOR_YELLOW, string);
  435. FetchContact(i, PlayerInfo[playerid][pPnumber]);
  436. }
  437. RingTone[i] = 10;
  438. format(string, sizeof(string), "* %s's phone begins to ring.", GetPlayerNameEx(i));
  439. SendClientMessageEx(playerid, COLOR_WHITE, "HINT: You now use T to talk on your cellphone, type /hangup to hang up.");
  440. ProxDetector(30.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  441. CellTime[playerid] = 1;
  442. SetPlayerAttachedObject(playerid, 8, 330, 6);
  443. Phone_Calling(playerid, i);
  444. return SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  445. }
  446. }
  447. }
  448. }
  449. }
  450. SendClientMessageEx(playerid, COLOR_GRAD2, "Your call can not be completed as dialed, please check the number and try again.");
  451. DeletePVar(playerid, "PayPhone");
  452. return 1;
  453. }
  454. CMD:t(playerid, params[])
  455. {
  456. return cmd_sms(playerid, params);
  457. }
  458. CMD:txt(playerid, params[])
  459. {
  460. return cmd_sms(playerid, params);
  461. }
  462. CMD:sms(playerid, params[])
  463. {
  464. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, " You haven't logged in yet!");
  465. if(PlayerInfo[playerid][pJailTime] && strfind(PlayerInfo[playerid][pPrisonReason], "[OOC]", true) != -1) return SendClientMessageEx(playerid, COLOR_GREY, "OOC prisoners are restricted to only speak in /b");
  466. if(PlayerInfo[playerid][pPnumber] == 0) return SendClientMessageEx(playerid, COLOR_GRAD2, " You don't have a cell phone.");
  467. if(PhoneOnline[playerid] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "Your phone is off.");
  468. if(GetPVarInt(playerid, "Injured") != 0 || PlayerInfo[playerid][pHospital] != 0) return SendClientMessageEx (playerid, COLOR_GRAD2, "You cannot do this at this time.");
  469. if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || GetPVarInt(playerid, "pBagged") >= 1) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use your phone whilist restrained.");
  470. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, " You can not use your phone while in jail or prison!");
  471. szMiscArray[0] = 0;
  472. new phonenumb, text[100];
  473. if(sscanf(params, "ds[100]", phonenumb, text)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: (/t)ext [phonenumber] [text chat]");
  474. if(Spectating[playerid] == 0 || !GetPVarType(playerid, "FlyMode"))
  475. {
  476. format(szMiscArray, sizeof(szMiscArray), "* %s takes out a cellphone.", GetPlayerNameEx(playerid));
  477. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  478. }
  479. if(phonenumb == 555)
  480. {
  481. if ((strcmp("yes", text, true, strlen(text)) == 0) && (strlen(text) == strlen("yes")))
  482. {
  483. ChatTrafficProcess(playerid, COLOR_YELLOW, "Text message delivered.", 7);
  484. ChatTrafficProcess(playerid, COLOR_YELLOW, "SMS: I'm watching you, Sender: MOLE (555)", 7);
  485. //SendAudioToPlayer(playerid, 47, 100);
  486. RingTone[playerid] = 20;
  487. return 1;
  488. }
  489. else
  490. {
  491. ChatTrafficProcess(playerid, COLOR_YELLOW, "SMS: I'm watching you, Sender: MOLE (555)", 7);
  492. //SendAudioToPlayer(playerid, 47, 100);
  493. RingTone[playerid] = 20;
  494. return 1;
  495. }
  496. }
  497. szMiscArray[0] = 0;
  498. foreach(new i: Player)
  499. {
  500. if(PlayerInfo[i][pPnumber] == phonenumb && phonenumb != 0)
  501. {
  502. new giveplayerid = i;
  503. if(Mobile[giveplayerid] != INVALID_PLAYER_ID)
  504. {
  505. ChatTrafficProcess(playerid, COLOR_GREY, "That player's phone is busy (on a call).", 7);
  506. DeletePVar(playerid, "PayPhone");
  507. return 1;
  508. }
  509. Mobile[playerid] = giveplayerid; //caller connecting
  510. if(IsPlayerConnected(giveplayerid))
  511. {
  512. if(giveplayerid != INVALID_PLAYER_ID)
  513. {
  514. if(PhoneOnline[giveplayerid] > 0)
  515. {
  516. ChatTrafficProcess(playerid, COLOR_GREY, "That player's phone is switched off.", 7);
  517. Mobile[playerid] = INVALID_PLAYER_ID;
  518. return 1;
  519. }
  520. foreach(new u: Player)
  521. {
  522. if(GetPVarInt(u, "BigEar") == 6 && (GetPVarInt(u, "BigEarPlayer") == playerid || GetPVarInt(u, "BigEarPlayer") == giveplayerid))
  523. {
  524. format(szMiscArray, sizeof(szMiscArray), "(BE) %s SMS to %s: %s", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), text);
  525. ChatTrafficProcess(u, COLOR_YELLOW, szMiscArray, 7);
  526. }
  527. }
  528. if(PlayerInfo[playerid][pPhonePrivacy] == 1)
  529. {
  530. format(szMiscArray, sizeof(szMiscArray), "SMS: %s, Sender: Unknown.", text);
  531. }
  532. else
  533. {
  534. format(szMiscArray, sizeof(szMiscArray), "SMS: %s, Sender: %d (( %s ))", text, PlayerInfo[playerid][pPnumber], GetPlayerNameEx(playerid));
  535. }
  536. if(i != playerid)
  537. {
  538. if(PlayerInfo[i][pSmslog] > 0)
  539. {
  540. new query[384], ftext[128];
  541. mysql_escape_string(text, ftext);
  542. if(PlayerInfo[playerid][pPhonePrivacy] == 1) mysql_format(MainPipeline, query, sizeof(query), "INSERT INTO `sms` (`id`, `sender`, `senderid`, `sendernumber`, `receiver`, `receiverid`, `receivernumber`, `message`, `date`) VALUES (NULL, '%s', %d, 0, '%s', %d, %d, '%s', NOW())", GetPlayerNameExt(playerid), GetPlayerSQLId(playerid), GetPlayerNameExt(i), GetPlayerSQLId(i), phonenumb, ftext);
  543. else mysql_format(MainPipeline, query, sizeof(query), "INSERT INTO `sms` (`id`, `sender`, `senderid`, `sendernumber`, `receiver`, `receiverid`, `receivernumber`, `message`, `date`) VALUES (NULL, '%s', %d, %d, '%s', %d, %d, '%s', NOW())", GetPlayerNameExt(playerid), GetPlayerSQLId(playerid), PlayerInfo[playerid][pPnumber], GetPlayerNameExt(i), GetPlayerSQLId(i), phonenumb, ftext);
  544. mysql_tquery(MainPipeline, query, "OnQueryFinish", "i", SENDDATA_THREAD);
  545. }
  546. }
  547. //format(szMiscArray, sizeof(szMiscArray), "* %s's phone beeps.", sendername);
  548. RingTone[giveplayerid] =20;
  549. ChatTrafficProcess(giveplayerid, COLOR_YELLOW, szMiscArray, 7);
  550. ChatTrafficProcess(playerid, COLOR_YELLOW, szMiscArray, 7);
  551. ChatTrafficProcess(playerid, COLOR_YELLOW, "Text Message Delivered", 7);
  552. FetchContact(giveplayerid, PlayerInfo[playerid][pPnumber]);
  553. format(szMiscArray, sizeof(szMiscArray), "~r~$-%d", 25);
  554. GameTextForPlayer(playerid, szMiscArray, 5000, 1);
  555. GivePlayerCash(playerid,-25);
  556. //PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  557. //SendAudioToPlayer(playerid, 47, 100);
  558. //SendAudioToPlayer(giveplayerid, 47, 100);
  559. Mobile[playerid] = INVALID_PLAYER_ID;
  560. if(strcmp(PlayerInfo[giveplayerid][pAutoTextReply], "Nothing", true) != 0)
  561. {
  562. format(szMiscArray, sizeof(szMiscArray), "SMS: %s, Sender: %d [automated response]", PlayerInfo[giveplayerid][pAutoTextReply], PlayerInfo[giveplayerid][pPnumber]);
  563. ChatTrafficProcess(playerid, COLOR_YELLOW, szMiscArray, 7);
  564. }
  565. return 1;
  566. }
  567. }
  568. }
  569. }
  570. SendClientMessageEx(playerid, COLOR_GRAD2, " Message delivery failed...");
  571. return 1;
  572. }
  573. CMD:p(playerid, params[]) {
  574. return cmd_pickup(playerid, params);
  575. }
  576. CMD:pickup(playerid, params[])
  577. {
  578. new string[128];
  579. if(Mobile[playerid] != INVALID_PLAYER_ID)
  580. {
  581. SendClientMessageEx(playerid, COLOR_GRAD2, " You are already on a call...");
  582. return 1;
  583. }
  584. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen") || PlayerInfo[playerid][pHospital] > 0) {
  585. return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  586. }
  587. if(GetPVarType(playerid, "PayPhone")) {
  588. new x = GetPVarInt(playerid, "PayPhone");
  589. if(arrPayPhoneData[x][pp_iCallerID] != INVALID_PLAYER_ID) {
  590. if(arrPayPhoneData[x][pp_iCallerID] == playerid) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot answer the pay phone you're dialing.");
  591. foreach(new i: Player) {
  592. if(GetPVarInt(i, "PayPhone") == x) {
  593. if(i != playerid) return SendClientMessage(playerid, COLOR_GRAD1, "Someone else is already using this pay phone.");
  594. }
  595. }
  596. foreach(new i: Player) {
  597. if(i == arrPayPhoneData[x][pp_iCallerID])
  598. {
  599. Mobile[playerid] = i;
  600. Mobile[i] = playerid;
  601. SendClientMessageEx(i, COLOR_GRAD2, " Someone picked up the call.");
  602. format(string, sizeof(string), "* %s answers the pay phone.", GetPlayerNameEx(playerid));
  603. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  604. TogglePlayerControllable(playerid, false);
  605. SetPlayerAttachedObject(playerid, 8, 330, 6);
  606. return SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  607. }
  608. }
  609. }
  610. }
  611. foreach(new i: Player)
  612. {
  613. if(Mobile[i] == playerid)
  614. {
  615. Mobile[playerid] = i; //caller connecting
  616. SendClientMessageEx(i, COLOR_GRAD2, " They picked up the call.");
  617. format(string, sizeof(string), "* %s answers their cellphone.", GetPlayerNameEx(playerid));
  618. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  619. RingTone[playerid] = 0;
  620. SetPlayerAttachedObject(playerid, 8, 330, 6);
  621. Phone_PickupCall(playerid, i);
  622. return SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  623. }
  624. }
  625. return 1;
  626. }
  627. CMD:h(playerid, params[]) {
  628. return cmd_hangup(playerid, params);
  629. }
  630. CMD:hangup(playerid,params[])
  631. {
  632. new string[128];
  633. if(GetPVarInt(playerid, "Injured") != 0||PlayerCuffed[playerid]!=0||PlayerInfo[playerid][pHospital]!=0)
  634. {
  635. SendClientMessageEx (playerid, COLOR_GRAD2, "You cannot do this at this time.");
  636. return 1;
  637. }
  638. if(GetPVarType(playerid, "Has911Call")) {
  639. if(GetPVarType(playerid, "PayPhone")) TogglePlayerControllable(playerid, true);
  640. cmd_cancelcall(playerid, "");
  641. }
  642. new caller = Mobile[playerid];
  643. if((IsPlayerConnected(caller)/* && caller != INVALID_PLAYER_ID*/))
  644. {
  645. if(caller < MAX_PLAYERS)
  646. {
  647. if(GetPVarInt(caller, "_UsingJailPhone") == 1)
  648. {
  649. TogglePlayerControllable(caller, 1);
  650. DeletePVar(caller, "_UsingJailPhone");
  651. bJailPhoneUse[GetClosestPrisonPhone(caller)] = false;
  652. }
  653. SendClientMessageEx(caller, COLOR_GRAD2, " They hung up.");
  654. format(string, sizeof(string), "* %s puts away their cellphone.", GetPlayerNameEx(caller));
  655. ProxDetector(30.0, caller, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  656. CellTime[caller] = 0;
  657. Mobile[caller] = INVALID_PLAYER_ID;
  658. }
  659. if(GetPVarType(playerid, "PayPhone")) {
  660. new x = GetPVarInt(playerid, "PayPhone");
  661. DeletePVar(playerid, "PayPhone");
  662. arrPayPhoneData[x][pp_iCallerID] = INVALID_PLAYER_ID;
  663. TogglePlayerControllable(playerid, true);
  664. PayPhone_UpdateTextLabel(x, 0);
  665. }
  666. if(GetPVarType(caller, "PayPhone")) {
  667. new x = GetPVarInt(caller, "PayPhone");
  668. DeletePVar(caller, "PayPhone");
  669. arrPayPhoneData[x][pp_iCallerID] = INVALID_PLAYER_ID;
  670. TogglePlayerControllable(caller, true);
  671. PayPhone_UpdateTextLabel(x, 0);
  672. }
  673. DeletePVar(playerid, "GRPCALL");
  674. DeletePVar(caller, "GRPCALL");
  675. DeletePVar(playerid, "BUSICALL");
  676. DeletePVar(caller, "BUSICALL");
  677. CellTime[playerid] = 0;
  678. Phone_HangupCall(playerid, Mobile[playerid]);
  679. SendClientMessageEx(playerid, COLOR_GRAD2, " You hung up.");
  680. format(string, sizeof(string), "* %s puts away their cellphone.", GetPlayerNameEx(playerid));
  681. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  682. Mobile[playerid] = INVALID_PLAYER_ID;
  683. CellTime[playerid] = 0;
  684. RingTone[playerid] = 0;
  685. RemovePlayerAttachedObject(playerid, 8);
  686. RemovePlayerAttachedObject(caller, 8);
  687. SetPlayerSpecialAction(caller, SPECIAL_ACTION_STOPUSECELLPHONE);
  688. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
  689. return 1;
  690. }
  691. else {
  692. if(GetPVarType(playerid, "PayPhone")) {
  693. CellTime[playerid] = 0;
  694. SendClientMessageEx(playerid, COLOR_GRAD2, " You hung up.");
  695. format(string, sizeof(string), "* %s puts away their cellphone.", GetPlayerNameEx(playerid));
  696. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  697. Mobile[playerid] = INVALID_PLAYER_ID;
  698. CellTime[playerid] = 0;
  699. RingTone[playerid] = 0;
  700. RemovePlayerAttachedObject(playerid, 8);
  701. RemovePlayerAttachedObject(caller, 8);
  702. SetPlayerSpecialAction(caller, SPECIAL_ACTION_STOPUSECELLPHONE);
  703. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
  704. new x = GetPVarInt(playerid, "PayPhone");
  705. DeletePVar(playerid, "PayPhone");
  706. arrPayPhoneData[x][pp_iCallerID] = INVALID_PLAYER_ID;
  707. PayPhone_UpdateTextLabel(x, 0);
  708. return 1;
  709. }
  710. }
  711. SendClientMessageEx(playerid, COLOR_GRAD2, " Your phone is in your pocket.");
  712. return 1;
  713. }
  714. FetchContact(iReceiverID, iCallerNumber) {
  715. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT `contactname` FROM `phone_contacts` WHERE `id` = '%d' AND `contactnr` = '%d' LIMIT 1", GetPlayerSQLId(iReceiverID), iCallerNumber);
  716. mysql_tquery(MainPipeline, szMiscArray, "OnFetchContact", "i", iReceiverID);
  717. }
  718. forward OnFetchContact(iReceiverID);
  719. public OnFetchContact(iReceiverID) {
  720. new
  721. iRows,
  722. szName[MAX_PLAYER_NAME];
  723. szMiscArray[0] = 0;
  724. cache_get_row_count(iRows);
  725. if(!iRows) return 1;
  726. cache_get_value_name(0, "contactname", szName, MAX_PLAYER_NAME);
  727. format(szMiscArray, sizeof(szMiscArray), "[CONTACT]: %s", szName);
  728. ChatTrafficProcess(iReceiverID, COLOR_GRAD1, szMiscArray, 7);
  729. return 1;
  730. }