1
0

interact.pwn 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Interaction System Revision
  11. Remastered by Winterfield
  12. Next Generation Gaming, LLC
  13. (created by Next Generation Gaming Development Team)
  14. * Copyright (c) 2016, Next Generation Gaming, LLC
  15. *
  16. * All rights reserved.
  17. *
  18. * Redistribution and use in source and binary forms, with or without modification,
  19. * are not permitted in any case.
  20. *
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  26. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <YSI\y_hooks>
  35. CMD:interact(playerid, params[])
  36. {
  37. new id;
  38. if(sscanf(params, "u", id)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /interact [playerid]");
  39. if(IsPlayerConnected(id))
  40. {
  41. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "That player is not near you!.");
  42. if(id == playerid) return SendClientMessageEx(playerid, COLOR_GREY, "You can't interact with yourself.");
  43. SetPVarInt(playerid, "pInteract", id);
  44. ShowInteractionMenu(playerid, 0);
  45. }
  46. else SendClientMessageEx(playerid, COLOR_GRAD1, "That player is not connected!");
  47. return 1;
  48. }
  49. ShowInteractionMenu(playerid, menu)
  50. {
  51. szMiscArray[0] = 0;
  52. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you."); // An extra check never hurts! - Winterfield
  53. switch(menu)
  54. {
  55. case 0: // Main Menu
  56. {
  57. DeletePVar(playerid, "pGiving");
  58. DeletePVar(playerid, "pSelling");
  59. format(szMiscArray, sizeof(szMiscArray), "Pay\nGive Item\nSell Item\nFrisk\nShow License");
  60. if(IsACop(playerid)) format(szMiscArray, sizeof(szMiscArray), "%s\nCop", szMiscArray);
  61. if(IsAMedic(playerid)) format(szMiscArray, sizeof(szMiscArray), "%s\nMedic", szMiscArray);
  62. if(IsADocGuard(playerid)) format(szMiscArray, sizeof(szMiscArray), "%s\nGuard", szMiscArray);
  63. ShowPlayerDialogEx(playerid, DIALOG_INTERACT, DIALOG_STYLE_LIST, "Interaction Menu", szMiscArray, "Select", "Cancel");
  64. }
  65. case 1: // Give / Sell
  66. {
  67. format(szMiscArray, sizeof(szMiscArray), "Item\tCurrent Amount\n\
  68. Drugs\n\
  69. Weapons\n\
  70. Materials\t%d\n\
  71. Syringes\t%d\n\
  72. Sprunk\t%d\n\
  73. Fireworks\t%d",
  74. PlayerInfo[playerid][pMats],
  75. PlayerInfo[playerid][pSyringes],
  76. PlayerInfo[playerid][pSprunk],
  77. PlayerInfo[playerid][pFirework]);
  78. if(GetPVarInt(playerid, "pGiving")) ShowPlayerDialogEx(playerid, DIALOG_INTERACT_GIVEITEM, DIALOG_STYLE_TABLIST_HEADERS, "Interaction Menu - Give", szMiscArray, "Select", "Cancel");
  79. else if(GetPVarInt(playerid, "pSelling")) ShowPlayerDialogEx(playerid, DIALOG_INTERACT_SELLITEM, DIALOG_STYLE_TABLIST_HEADERS, "Interaction Menu - Sell", szMiscArray, "Select", "Cancel");
  80. }
  81. }
  82. return 1;
  83. }
  84. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  85. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  86. switch(dialogid)
  87. {
  88. case DIALOG_INTERACT:
  89. {
  90. if(!response) return 1;
  91. if(!IsPlayerConnected(GetPVarInt(playerid, "pInteract"))) return SendClientMessage(playerid, COLOR_GRAD1, "The player you were interacting with has disconnected!");
  92. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you.");
  93. szMiscArray[0] = 0;
  94. switch(listitem)
  95. {
  96. case 0: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_PAY, DIALOG_STYLE_INPUT, "Interaction Menu - Pay", "How much would you like to transfer?", "Select", "Cancel"); // Pay
  97. case 1: // Give
  98. {
  99. SetPVarInt(playerid, "pGiving", 1);
  100. ShowInteractionMenu(playerid, 1);
  101. }
  102. case 2: // Sell
  103. {
  104. SetPVarInt(playerid, "pSelling", 1);
  105. ShowInteractionMenu(playerid, 1);
  106. }
  107. case 3: // Frisk
  108. {
  109. new id[3];
  110. valstr(id, GetPVarInt(playerid, "pInteract"));
  111. cmd_frisk(playerid, id);
  112. }
  113. case 4: // Show License
  114. {
  115. new id[3];
  116. valstr(id, GetPVarInt(playerid, "pInteract"));
  117. cmd_showlicenses(playerid, id);
  118. }
  119. }
  120. if(listitem == 5 && IsACop(playerid))
  121. {
  122. format(szMiscArray, sizeof(szMiscArray), "(Un)cuff\nJailcuff\nDrag\nDetain\nTicket\nConfiscate", szMiscArray);
  123. ShowPlayerDialogEx(playerid, DIALOG_INTERACT_COP, DIALOG_STYLE_LIST, "Interaction Menu - Cop", szMiscArray, "Select", "Cancel");
  124. }
  125. if(listitem == 5 && IsAMedic(playerid))
  126. {
  127. format(szMiscArray, sizeof(szMiscArray), "Move Patient\nLoad Patient\nTriage\nHeal", szMiscArray);
  128. ShowPlayerDialogEx(playerid, DIALOG_INTERACT_MEDIC, DIALOG_STYLE_LIST, "Interaction Menu - Medic", szMiscArray, "Select", "Cancel");
  129. }
  130. if(listitem == 5 && IsADocGuard(playerid))
  131. {
  132. format(szMiscArray, sizeof(szMiscArray), "(Un)cuff\nJailcuff\nDrag\nDetain\nConfiscate\nExtend Sentence\nReduce Sentence\nIsolate", szMiscArray);
  133. ShowPlayerDialogEx(playerid, DIALOG_INTERACT_GUARD, DIALOG_STYLE_LIST, "Interaction Menu - DoC", szMiscArray, "Select", "Cancel");
  134. }
  135. }
  136. case DIALOG_INTERACT_PAY:
  137. {
  138. if(!response) return 1;
  139. if(!IsPlayerConnected(GetPVarInt(playerid, "pInteract"))) return SendClientMessage(playerid, COLOR_GRAD1, "The player you were interacting with has disconnected!");
  140. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you.");
  141. new id[3], realstring[50];
  142. valstr(id, GetPVarInt(playerid, "pInteract"));
  143. format(realstring, 50, "%s %s", id, inputtext);
  144. cmd_pay(playerid, realstring);
  145. }
  146. case DIALOG_INTERACT_GIVEITEM:
  147. {
  148. if(!response) return 1;
  149. if(!IsPlayerConnected(GetPVarInt(playerid, "pInteract"))) return SendClientMessage(playerid, COLOR_GRAD1, "The player you were interacting with has disconnected!");
  150. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you.");
  151. switch(listitem)
  152. {
  153. case 0:
  154. {
  155. szMiscArray[0] = 0;
  156. for(new i; i < sizeof(Drugs); i++) format(szMiscArray, sizeof(szMiscArray), "%s\n{A9C4E4}%s {FFFFFF}(%dg){A9C4E4}", szMiscArray, GetDrugName(i), PlayerInfo[playerid][pDrugs][i]);
  157. ShowPlayerDialogEx(playerid, DIALOG_INTERACT_GI_DRUGS, DIALOG_STYLE_LIST, "Interaction Menu - Give Item (Drugs)", szMiscArray, "Select", "Cancel");
  158. }
  159. case 1:
  160. {
  161. szMiscArray[0] = 0;
  162. new weapon[16], weapons[13][2];
  163. for (new i = 0; i <= 12; i++)
  164. {
  165. GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
  166. GetWeaponName(weapons[i][0], weapon, sizeof(weapon));
  167. if(PlayerInfo[playerid][pGuns][i] == weapons[i][0]) format(szMiscArray, sizeof(szMiscArray), "%s\n{A9C4E4}%s {FFFFFF}(%d){A9C4E4}", szMiscArray, weapon, weapons[i][0]);
  168. }
  169. ShowPlayerDialogEx(playerid, DIALOG_INTERACT_GI_WEAPON, DIALOG_STYLE_LIST, "Interaction Menu - Give Item (Weapons)", szMiscArray, "Select", "Cancel");
  170. }
  171. }
  172. }
  173. case DIALOG_INTERACT_COP:
  174. {
  175. if(!response) return 1;
  176. if(!IsPlayerConnected(GetPVarInt(playerid, "pInteract"))) return SendClientMessage(playerid, COLOR_GRAD1, "The player you were interacting with has disconnected!");
  177. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you.");
  178. switch(listitem)
  179. {
  180. case 0: // (Un)cuff
  181. {
  182. new id[3];
  183. valstr(id, GetPVarInt(playerid, "pInteract"));
  184. if(PlayerCuffed[GetPVarInt(playerid, "pInteract")] > 1) cmd_uncuff(playerid, id);
  185. else cmd_cuff(playerid, id);
  186. }
  187. case 1: // Jailcuff
  188. {
  189. new id[3];
  190. valstr(id, GetPVarInt(playerid, "pInteract"));
  191. cmd_jailcuff(playerid, id);
  192. }
  193. case 2: // Drag
  194. {
  195. new id[3];
  196. valstr(id, GetPVarInt(playerid, "pInteract"));
  197. cmd_drag(playerid, id);
  198. }
  199. case 3: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_DETAIN, DIALOG_STYLE_INPUT, "Interaction Menu - Detain", "Please choose the number of seat you'd like to detain the suspect in. (1-3)", "Select", "Cancel");
  200. case 4: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_TICKET, DIALOG_STYLE_INPUT, "Interaction Menu - Ticket", "Please choose how much you would like to ticket the suspect.", "Select", "Cancel");
  201. case 5: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_CONFISCATE, DIALOG_STYLE_LIST, "Interaction Menu - Confiscate", "Weapons\nPot\nCrack\nMeth\nEcstasy\nMaterials\nRadio\nHeroin\nRawopium\nSyringes\nPotSeeds\nOpiumSeeds\nDrugCrates", "Select", "Cancel");
  202. }
  203. }
  204. case DIALOG_INTERACT_MEDIC:
  205. {
  206. if(!response) return 1;
  207. if(!IsPlayerConnected(GetPVarInt(playerid, "pInteract"))) return SendClientMessage(playerid, COLOR_GRAD1, "The player you were interacting with has disconnected!");
  208. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you.");
  209. switch(listitem)
  210. {
  211. case 0: // Move Patient
  212. {
  213. new id[3];
  214. valstr(id, GetPVarInt(playerid, "pInteract"));
  215. cmd_movept(playerid, id);
  216. }
  217. case 1: // Load Patient
  218. {
  219. new id[3], seat = -1, realstring[50];
  220. valstr(id, GetPVarInt(playerid, "pInteract"));
  221. new carid = gLastCar[playerid];
  222. if(IsAnAmbulance(carid))
  223. {
  224. for(new i = 2; i < 3; i++)
  225. if(!IsVehicleOccupied(carid, i)) { seat = i; break; }
  226. }
  227. else return 1;
  228. format(realstring, 50, "%s %d", id, seat);
  229. if(seat != -1) cmd_loadpt(playerid, realstring);
  230. }
  231. case 2: // Jailcuff
  232. {
  233. new id[3];
  234. valstr(id, GetPVarInt(playerid, "pInteract"));
  235. cmd_jailcuff(playerid, id);
  236. }
  237. case 3: // Triage
  238. {
  239. new id[3];
  240. valstr(id, GetPVarInt(playerid, "pInteract"));
  241. cmd_triage(playerid, id);
  242. }
  243. case 4: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_HEAL, DIALOG_STYLE_INPUT, "Interaction Menu - Heal", "How much would you like to heal the patient for? ($200 - $1,000)", "Select", "Cancel");
  244. }
  245. }
  246. case DIALOG_INTERACT_GUARD:
  247. {
  248. if(!response) return 1;
  249. if(!IsPlayerConnected(GetPVarInt(playerid, "pInteract"))) return SendClientMessage(playerid, COLOR_GRAD1, "The player you were interacting with has disconnected!");
  250. if(!ProxDetectorS(8.0, playerid, GetPVarInt(playerid, "pInteract"))) return SendClientMessageEx(playerid, COLOR_GREY, "The player you have tried to interact with is not near you.");
  251. switch(listitem)
  252. {
  253. case 0: // (Un)cuff
  254. {
  255. new id[3];
  256. valstr(id, GetPVarInt(playerid, "pInteract"));
  257. if(PlayerCuffed[GetPVarInt(playerid, "pInteract")] > 1) cmd_uncuff(playerid, id);
  258. else cmd_cuff(playerid, id);
  259. }
  260. case 1: // Jailcuff
  261. {
  262. new id[3];
  263. valstr(id, GetPVarInt(playerid, "pInteract"));
  264. cmd_jailcuff(playerid, id);
  265. }
  266. case 2: // Drag
  267. {
  268. new id[3];
  269. valstr(id, GetPVarInt(playerid, "pInteract"));
  270. cmd_drag(playerid, id);
  271. }
  272. case 3: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_DETAIN, DIALOG_STYLE_INPUT, "Interaction Menu - Detain", "Please choose the number of seat you'd like to detain the suspect in. (1-3)", "Select", "Cancel");
  273. case 4: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_CONFISCATE, DIALOG_STYLE_LIST, "Interaction Menu - Confiscate", "Weapons\nPot\nCrack\nMeth\nEcstasy\nMaterials\nRadio\nHeroin\nRawopium\nSyringes\nPotSeeds\nOpiumSeeds\nDrugCrates", "Select", "Cancel");
  274. case 5: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_EXTEND, DIALOG_STYLE_INPUT, "Interaction Menu - Extend Sentence", "How much would you like to extend the prisoners sentence? (1 - 30)", "Select", "Cancel");
  275. case 6: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_REDUCE, DIALOG_STYLE_INPUT, "Interaction Menu - Reduce Sentence", "How much would you like to reduce the prisoners sentence? (1 - 30)", "Select", "Cancel");
  276. case 7: ShowPlayerDialogEx(playerid, DIALOG_INTERACT_ISOLATION, DIALOG_STYLE_LIST, "Interaction Menu - Isolation", "IC Isolation\nOOC Isolation", "Select", "Cancel");
  277. }
  278. }
  279. }
  280. return 0;
  281. }