ddsale.pwn 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. #include <YSI\y_hooks>
  2. ClearDoorSaleVariables(playerid)
  3. {
  4. stop DDSaleTimer[playerid];
  5. DDSalePendingAdmin[playerid] = false;
  6. DDSalePendingPlayer[playerid] = false;
  7. DDSaleTarget[playerid] = INVALID_PLAYER_ID;
  8. DDSalePrice[playerid] = 0;
  9. DDSaleTracking[playerid] = 0;
  10. for(new i = 0; i < sizeof(DDSaleDoors[]); i ++) DDSaleDoors[playerid][i] = 0;
  11. return 1;
  12. }
  13. CalculatePercentage(source, percentage, minimum)
  14. {
  15. new amount;
  16. amount = percentage * source / 100;
  17. if(amount < minimum) amount = minimum;
  18. return amount;
  19. }
  20. ReturnDoorLineDetails(playerid, doorid)
  21. {
  22. new string[32];
  23. string = "N/A";
  24. if(doorid != 0 && GetPlayerSQLId(playerid) == DDoorsInfo[doorid][ddOwner]) format(string, sizeof(string), "%d (%s)", doorid, DDoorsInfo[doorid][ddDescription]);
  25. return string;
  26. }
  27. ShowDynamicDoorDialog(playerid)
  28. {
  29. if(!IsPlayerConnected(DDSaleTarget[playerid]) || DDSaleTarget[playerid] == INVALID_PLAYER_ID)
  30. {
  31. SendClientMessageEx(playerid, COLOR_GREY, "The specified buyer is no longer connected.");
  32. ClearDoorSaleVariables(playerid);
  33. return 1;
  34. }
  35. if(DDSalePendingPlayer[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from the specified buyer.");
  36. if(DDSalePendingAdmin[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from server administration.");
  37. szMiscArray[0] = 0;
  38. format(szMiscArray, sizeof(szMiscArray), "Setting\tValue\nBuyer\t%s\nPrice\t$%s\nSeller Fine\t$%s\nDynamic Door 1\t%s\nDynamic Door 2\t%s\nDynamic Door 3\t%s\nDynamic Door 4\t%s\nDynamic Door 5\t%s\nGarage 1\t%s\nGarage 2\t%s\nFinalize And Submit",
  39. GetPlayerNameEx(DDSaleTarget[playerid]), number_format(DDSalePrice[playerid]), number_format(CalculatePercentage(DDSalePrice[playerid], 10, 1000000)),
  40. ReturnDoorLineDetails(playerid, DDSaleDoors[playerid][0]), ReturnDoorLineDetails(playerid, DDSaleDoors[playerid][1]), ReturnDoorLineDetails(playerid, DDSaleDoors[playerid][2]),
  41. ReturnDoorLineDetails(playerid, DDSaleDoors[playerid][3]), ReturnDoorLineDetails(playerid, DDSaleDoors[playerid][4]), ReturnGarageLineDetails(playerid, DDSaleDoors[playerid][5]), ReturnGarageLineDetails(playerid, DDSaleDoors[playerid][6]));
  42. ShowPlayerDialogEx(playerid, DIALOG_DDSALEMAIN, DIALOG_STYLE_TABLIST_HEADERS, "Dynamic Door Selling", szMiscArray, "Okay", "Cancel");
  43. return 1;
  44. }
  45. task DynamicDoorSellRequests[60000]()
  46. {
  47. new bool:notification;
  48. foreach(new i : Player)
  49. {
  50. if(gPlayerLogged{i} == 1 && DDSalePendingAdmin[i] == true)
  51. {
  52. notification = true;
  53. break;
  54. }
  55. }
  56. if(notification == true)
  57. {
  58. ABroadCast(COLOR_LIGHTRED, "One or more dynamic door sale requests are pending review.", 4, true);
  59. return 1;
  60. }
  61. return 1;
  62. }
  63. timer DDSaleTimerEx[30000](playerid)
  64. {
  65. if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid) && playerid != INVALID_PLAYER_ID)
  66. {
  67. new string[128];
  68. format(string, sizeof(string), "Your dynamic door offer (buyer: %s) has expired.", GetPlayerNameEx(DDSaleTarget[playerid]));
  69. SendClientMessageEx(playerid, COLOR_GREY, string);
  70. format(string, sizeof(string), "Your dynamic door sale offer from %s has expired.", GetPlayerNameEx(playerid));
  71. SendClientMessageEx(DDSaleTarget[playerid], COLOR_GREY, string);
  72. ClearDoorSaleVariables(playerid);
  73. return 1;
  74. }
  75. return 1;
  76. }
  77. CMD:ad(playerid, params[]) return cmd_approvedoorsale(playerid, params);
  78. CMD:ds(playerid, params[]) return cmd_denydoorsale(playerid, params);
  79. CMD:doorsalehelp(playerid, params[])
  80. {
  81. SendClientMessageEx(playerid, COLOR_WHITE, "** DYNAMIC DOOR SALE COMMANDS **");
  82. SendClientMessageEx(playerid, COLOR_GREY, "» /selldoors [Part Of Name/ ID] - Allows you to sell your dynamic doors to a specified player with a set price.");
  83. SendClientMessageEx(playerid, COLOR_GREY, "» /cancel door - Cancels your dynamic door sale request (must be pending review from server administrator).");
  84. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  85. {
  86. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /doorrequests - View the list of current dynamic door requests pending review from administration.");
  87. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /doorsaleinfo - View detailed information on a door sale request.");
  88. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /(a)pprove(d)oorsale [Part Of Name/ ID] - Approve a specified player's dynamic door sale.");
  89. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /(d)enydoor(s)ale [Part Of Name/ ID] - Deny a specified player's dynamic door sale.");
  90. return 1;
  91. }
  92. return 1;
  93. }
  94. CMD:selldoors(playerid, params[])
  95. {
  96. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You are not logged into your account.");
  97. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot sell dynamic doors while injured.");
  98. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot sell dynamic doors while handcuffed.");
  99. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot sell dynamic doors while in prison.");
  100. new target;
  101. if(sscanf(params, "u", target)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /selldoors [Part Of Name/ ID]");
  102. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't connected.");
  103. if(target == playerid) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot sell dynamic doors to yourself.");
  104. if(GetPlayerCash(playerid) < 1000000) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot afford the minimum $1,000,000 transfer fine.");
  105. if(gPlayerLogged{target} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't logged into their account.");
  106. if(DDSalePendingPlayer[playerid] == true || DDSalePendingAdmin[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "You have an existing dynamic door sale offer, use (/cancel door) to cancel it.");
  107. foreach(new i : Player) if(DDSaleTarget[i] == target) return SendClientMessageEx(playerid, COLOR_GREY, "Another player has already offered the specified player a dynamic door sale offer.");
  108. ClearDoorSaleVariables(playerid);
  109. DDSaleTarget[playerid] = target;
  110. ShowDynamicDoorDialog(playerid);
  111. return 1;
  112. }
  113. CMD:doorrequests(playerid, params[])
  114. {
  115. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  116. new count, string[64];
  117. SendClientMessageEx(playerid, COLOR_WHITE, "** DYNAMIC DOOR SALE REQUESTS PENDING APPROVAL: **");
  118. foreach(new i : Player)
  119. {
  120. if(gPlayerLogged{i} == 1 && DDSalePendingAdmin[i] == true)
  121. {
  122. format(string, sizeof(string), "(ID: %d) %s", i, GetPlayerNameEx(i));
  123. SendClientMessageEx(playerid, COLOR_GREY, string);
  124. count ++;
  125. }
  126. }
  127. if(count == 0) return SendClientMessageEx(playerid, COLOR_GREY, "There are not currently any dynamic door sale requests approval.");
  128. return 1;
  129. }
  130. CMD:doorsaleinfo(playerid, params[])
  131. {
  132. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  133. new target;
  134. if(sscanf(params, "u", target)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /doorsaleinfo [Part Of Name/ ID]");
  135. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't connected.");
  136. if(gPlayerLogged{target} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't logged into their account.");
  137. if(DDSalePendingAdmin[target] == false) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player does not have a pending dynamic door sale request.");
  138. szMiscArray[0] = 0;
  139. format(szMiscArray, sizeof(szMiscArray), "General Information:\n\n » Seller: %s\n » Buyer: %s\n » Price: $%s\n » Fine: $%s\n\nDynamic Door(s):\n\n", GetPlayerNameEx(target), GetPlayerNameEx(DDSaleTarget[target]), number_format(DDSalePrice[target]), CalculatePercentage(DDSalePrice[target], 10, 1000000));
  140. for(new i = 0; i < sizeof(DDSaleDoors[]); i ++) if(DDSaleDoors[target][i] != 0 && GetPlayerSQLId(target) == DDoorsInfo[DDSaleDoors[target][i]][ddOwner]) format(szMiscArray, sizeof(szMiscArray), "%s\n » Door ID: %d (%s)", szMiscArray, DDSaleDoors[target][i], DDoorsInfo[DDSaleDoors[target][i]][ddDescription]);
  141. ShowPlayerDialogEx(playerid, DIALOG_DDSALEINFO, DIALOG_STYLE_MSGBOX, "Dynamic Door Sale Details", szMiscArray, "Okay", "Cancel");
  142. return 1;
  143. }
  144. CMD:approvedoorsale(playerid, params[])
  145. {
  146. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  147. new target, fine, count[2], timex[3], string[128];
  148. if(sscanf(params, "u", target)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /approvedoorsale [Part Of Name/ ID]");
  149. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't connected.");
  150. if(gPlayerLogged{target} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't logged into their account.");
  151. if(DDSalePendingAdmin[target] == false) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player does not have a pending dynamic door sale request.");
  152. fine = CalculatePercentage(DDSalePrice[target], 10, 1000000);
  153. if(GetPlayerCash(DDSaleTarget[target]) < DDSalePrice[target])
  154. {
  155. format(string, sizeof(string), "You have approved %s's dynamic door sale request.", GetPlayerNameEx(target));
  156. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  157. format(string, sizeof(string), "No transactions have been made however, as %s does not have the sufficient funds ($%s).", GetPlayerNameEx(DDSaleTarget[target]), number_format(DDSalePrice[target]));
  158. SendClientMessageEx(playerid, COLOR_GREY, string);
  159. format(string, sizeof(string), "%s has approved your dynamic door sale request.", GetPlayerNameEx(playerid));
  160. SendClientMessageEx(target, COLOR_GREEN, string);
  161. format(string, sizeof(string), "No transactions have been made however, as %s does not have the sufficient funds ($%s).", GetPlayerNameEx(DDSaleTarget[target]), number_format(DDSalePrice[target]));
  162. SendClientMessageEx(target, COLOR_GREY, string);
  163. format(string, sizeof(string), "%s has approved %s's dynamic door sale request.", GetPlayerNameEx(playerid), GetPlayerNameEx(target));
  164. SendClientMessageEx(DDSaleTarget[target], COLOR_GREEN, string);
  165. format(string, sizeof(string), "No transactions have been made however, as you do not have the sufficient funds ($%s).", number_format(DDSalePrice[target]));
  166. SendClientMessageEx(DDSaleTarget[target], COLOR_GREY, string);
  167. ClearDoorSaleVariables(target);
  168. PlayerInfo[playerid][pAcceptReport] ++;
  169. ReportCount[playerid] ++;
  170. ReportHourCount[playerid] ++;
  171. format(string, sizeof(string), "AdmCmd: %s approved %s's dynamic door sale request (sale failed).", GetPlayerNameEx(playerid), GetPlayerNameEx(target));
  172. ABroadCast(COLOR_LIGHTRED, string, 4);
  173. Log("logs/admin.log", string);
  174. return 1;
  175. }
  176. else if(GetPlayerCash(target) < fine)
  177. {
  178. format(string, sizeof(string), "You have approved %s's dynamic door sale request.", GetPlayerNameEx(target));
  179. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  180. format(string, sizeof(string), "No transactions have been made however, as %s does not have the sufficient funds for the fine ($%s).", GetPlayerNameEx(target), number_format(fine));
  181. SendClientMessageEx(playerid, COLOR_GREY, string);
  182. format(string, sizeof(string), "%s has approved your dynamic door sale request.", GetPlayerNameEx(playerid));
  183. SendClientMessageEx(target, COLOR_GREEN, string);
  184. format(string, sizeof(string), "No transactions have been made however, as you does not have the sufficient funds for the fine ($%s).", number_format(fine));
  185. SendClientMessageEx(target, COLOR_GREY, string);
  186. format(string, sizeof(string), "%s has approved %s's dynamic door sale request.", GetPlayerNameEx(playerid), GetPlayerNameEx(target));
  187. SendClientMessageEx(DDSaleTarget[target], COLOR_GREEN, string);
  188. format(string, sizeof(string), "No transactions have been made however, as %s does not have the sufficient funds for the fine ($%s).", GetPlayerNameEx(target), number_format(fine));
  189. SendClientMessageEx(DDSaleTarget[target], COLOR_GREY, string);
  190. PlayerInfo[playerid][pAcceptReport] ++;
  191. ReportCount[playerid] ++;
  192. ReportHourCount[playerid] ++;
  193. format(string, sizeof(string), "AdmCmd: %s approved %s's dynamic door sale request (sale failed).", GetPlayerNameEx(playerid), GetPlayerNameEx(target));
  194. ABroadCast(COLOR_LIGHTRED, string, 4);
  195. Log("logs/admin.log", string);
  196. ClearDoorSaleVariables(target);
  197. return 1;
  198. }
  199. else if(GetPlayerCash(DDSaleTarget[target]) >= DDSalePrice[target])
  200. {
  201. szMiscArray[0] = 0;
  202. gettime(timex[0], timex[1], timex[2]);
  203. format(string, sizeof(string), "You have approved %s's dynamic door sale request.", GetPlayerNameEx(target));
  204. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  205. format(string, sizeof(string), "%s has approved your dynamic door sale request ($%s).", GetPlayerNameEx(playerid), number_format(DDSalePrice[target]));
  206. SendClientMessageEx(target, COLOR_GREEN, string);
  207. format(string, sizeof(string), "%s has approved %s's dynamic door sale request ($%s).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), number_format(DDSalePrice[target]));
  208. SendClientMessageEx(DDSaleTarget[target], COLOR_GREEN, string);
  209. GivePlayerCashEx(target, TYPE_ONHAND, DDSalePrice[target]);
  210. GivePlayerCashEx(target, TYPE_ONHAND, -fine);
  211. GivePlayerCashEx(DDSaleTarget[target], TYPE_ONHAND, -DDSalePrice[target]);
  212. format(szMiscArray, sizeof(szMiscArray), "General Transaction Information:\n\n » Seller: %s\n » Buyer: %s\n » Price: $%s\n » Seller Fine: $%s\n » Date: %s (%02d:%02d:%02d)\n\nDynamic Doors:\n",
  213. GetPlayerNameEx(target), GetPlayerNameEx(DDSaleTarget[target]), number_format(DDSalePrice[target]), number_format(fine), date(gettime(), 4), timex[0], timex[1], timex[2]);
  214. for(new i = 0; i < sizeof(DDSaleDoors[]) - 2; i ++)
  215. {
  216. if(DDSaleDoors[target][i] != 0 && GetPlayerSQLId(target) == DDoorsInfo[DDSaleDoors[target][i]][ddOwner])
  217. {
  218. format(szMiscArray, sizeof(szMiscArray), "%s\n » Door ID: %d (%s)", szMiscArray, DDSaleDoors[target][i], DDoorsInfo[DDSaleDoors[target][i]][ddDescription]);
  219. strcpy(DDoorsInfo[DDSaleDoors[target][i]][ddOwnerName], GetPlayerNameEx(DDSaleTarget[target]), MAX_PLAYER_NAME);
  220. DDoorsInfo[DDSaleDoors[target][i]][ddOwner] = GetPlayerSQLId(DDSaleTarget[target]);
  221. DestroyDynamicPickup(DDoorsInfo[DDSaleDoors[target][i]][ddPickupID]);
  222. if(IsValidDynamic3DTextLabel(DDoorsInfo[DDSaleDoors[target][i]][ddTextID])) DestroyDynamic3DTextLabel(DDoorsInfo[DDSaleDoors[target][i]][ddTextID]);
  223. CreateDynamicDoor(DDSaleDoors[target][i]);
  224. SaveDynamicDoor(DDSaleDoors[target][i]);
  225. count[0] ++;
  226. }
  227. }
  228. if(count[0] == 0) strcat(szMiscArray, "\n » None");
  229. strcat(szMiscArray, "\n\nGarages:\n");
  230. for(new i = sizeof(DDSaleDoors[]) - 2; i < sizeof(DDSaleDoors[]); i ++)
  231. {
  232. if(DDSaleDoors[target][i] != 0 && GetPlayerSQLId(target) == GarageInfo[DDSaleDoors[target][i]][gar_Owner])
  233. {
  234. format(szMiscArray, sizeof(szMiscArray), "%s\n » Garage ID: %d", szMiscArray, DDSaleDoors[target][i]);
  235. strcpy(GarageInfo[DDSaleDoors[target][i]][gar_OwnerName], GetPlayerNameEx(DDSaleTarget[target]), MAX_PLAYER_NAME);
  236. GarageInfo[DDSaleDoors[target][i]][gar_Owner] = GetPlayerSQLId(DDSaleTarget[target]);
  237. CreateGarage(DDSaleDoors[target][i]);
  238. SaveGarage(DDSaleDoors[target][i]);
  239. count[1] ++;
  240. }
  241. }
  242. if(count[1] == 0) strcat(szMiscArray, "\n » None");
  243. strcat(szMiscArray, "\n\nPress (F8) to take a screen-shot of this receipt for future reference.");
  244. ShowPlayerDialogEx(target, DIALOG_DDSALERECIEPT, DIALOG_STYLE_MSGBOX, "Dynamic Door Sale Receipt", szMiscArray, "Okay", "Cancel");
  245. ShowPlayerDialogEx(DDSaleTarget[target], DIALOG_DDSALERECIEPT, DIALOG_STYLE_MSGBOX, "Dynamic Door Sale Receipt", szMiscArray, "Okay", "Cancel");
  246. PlayerInfo[playerid][pAcceptReport] ++;
  247. ReportCount[playerid] ++;
  248. ReportHourCount[playerid] ++;
  249. format(string, sizeof(string), "AdmCmd: DDSale: Auth: %s DD sale (Seller:%s) (DD:%d) (F:$%s) (P:$%s) (TO: (%s)).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), DDSaleTracking[target], number_format(fine), number_format(DDSalePrice[target]), GetPlayerNameEx(DDSaleTarget[target]));
  250. ABroadCast(COLOR_LIGHTRED, string, 4);
  251. Log("logs/admin.log", string);
  252. ClearDoorSaleVariables(target);
  253. return 1;
  254. }
  255. return 1;
  256. }
  257. CMD:denydoorsale(playerid, params[])
  258. {
  259. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  260. new target, reason[64], string[128];
  261. if(sscanf(params, "us[64]", target, reason)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /denydoorsale [Part Of Name/ ID] [Reason]");
  262. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't connected.");
  263. if(gPlayerLogged{target} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player isn't logged into their account.");
  264. if(DDSalePendingAdmin[target] == false) return SendClientMessageEx(playerid, COLOR_GREY, "The specified player does not have a pending dynamic door sale request.");
  265. if(strlen(reason) < 3 || strlen(reason) > 60) return SendClientMessageEx(playerid, COLOR_GREY, "The specified reason cannot be under 3 characters or over 60 characters.");
  266. ClearDoorSaleVariables(target);
  267. format(string, sizeof(string), "You have denied %s's dynamic door sale request, reason: %s.", GetPlayerNameEx(target), reason);
  268. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  269. format(string, sizeof(string), "%s has denied your dynamic door sale request, reason: %s.", GetPlayerNameEx(playerid), reason);
  270. SendClientMessageEx(target, COLOR_LIGHTRED, string);
  271. PlayerInfo[playerid][pTrashReport] ++;
  272. format(string, sizeof(string), "AdmCmd: %s denied %s's dynamic door sale request, reason: %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(target), reason);
  273. ABroadCast(COLOR_LIGHTRED, string, 4);
  274. Log("logs/admin.log", string);
  275. return 1;
  276. }
  277. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  278. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  279. new string[128];
  280. switch(dialogid)
  281. {
  282. case DIALOG_DDSALEMAIN:
  283. {
  284. switch(response)
  285. {
  286. case false: return ClearDoorSaleVariables(playerid);
  287. case true:
  288. {
  289. if(!IsPlayerConnected(DDSaleTarget[playerid]) || DDSaleTarget[playerid] == INVALID_PLAYER_ID)
  290. {
  291. SendClientMessageEx(playerid, COLOR_GREY, "The specified buyer is no longer connected.");
  292. ClearDoorSaleVariables(playerid);
  293. return 1;
  294. }
  295. if(DDSalePendingPlayer[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from the specified buyer.");
  296. if(DDSalePendingAdmin[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from server administration.");
  297. switch(listitem)
  298. {
  299. case 0:
  300. {
  301. ShowDynamicDoorDialog(playerid);
  302. SendClientMessageEx(playerid, COLOR_GREY, "To modify the buyer of your dynamic door(s), exit this dialog and use the command again.");
  303. return 1;
  304. }
  305. case 1: return ShowPlayerDialogEx(playerid, DIALOG_DDSALEPRICE, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input the total price of the sale below.", "Okay", "Cancel");
  306. case 2:
  307. {
  308. SendClientMessageEx(playerid, COLOR_GREY, "The seller's fine is automatically determined by the total sale price. It cannot be modified.");
  309. ShowDynamicDoorDialog(playerid);
  310. return 1;
  311. }
  312. case 3..7:
  313. {
  314. DDSaleTracking[playerid] = (listitem - 3);
  315. ShowPlayerDialogEx(playerid, DIALOG_DDSALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the dynamic door you would like to link to the sale. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  316. return 1;
  317. }
  318. case 8, 9:
  319. {
  320. DDSaleTracking[playerid] = (listitem - 8);
  321. ShowPlayerDialogEx(playerid, DIALOG_GARAGESALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the garage you would like to link to the sale. Input \"0\" to remove a garage.", "Okay", "Cancel");
  322. return 1;
  323. }
  324. case 10:
  325. {
  326. if(DDSalePrice[playerid] < 1 || DDSalePrice[playerid] > 1000000000)
  327. {
  328. SendClientMessageEx(playerid, COLOR_GREY, "You must specify a price between $1 and $1,000,000,000.");
  329. ShowDynamicDoorDialog(playerid);
  330. return 1;
  331. }
  332. new fine, bool:linked;
  333. for(new i = 0; i < sizeof(DDSaleDoors[]); i ++)
  334. {
  335. if(DDSaleDoors[playerid][i] != 0)
  336. {
  337. if(GetPlayerSQLId(playerid) == DDoorsInfo[DDSaleDoors[playerid][i]][ddOwner] && linked == false) linked = true;
  338. else if(GetPlayerSQLId(playerid) != DDoorsInfo[DDSaleDoors[playerid][i]][ddOwner]) DDSaleDoors[playerid][i] = 0;
  339. }
  340. }
  341. if(linked == false)
  342. {
  343. SendClientMessageEx(playerid, COLOR_GREY, "You must linked at minimum one dynamic door to your sale.");
  344. ShowDynamicDoorDialog(playerid);
  345. return 1;
  346. }
  347. fine = CalculatePercentage(DDSalePrice[playerid], 10, 1000000);
  348. if(GetPlayerCash(playerid) < fine)
  349. {
  350. format(string, sizeof(string), "You do not have the sufficient funds for the transfer fine ($%s).", number_format(fine));
  351. SendClientMessageEx(playerid, COLOR_GREY, string);
  352. return 1;
  353. }
  354. format(string, sizeof(string), "You have sent your dynamic door sale request offer to %s for $%s.", GetPlayerNameEx(DDSaleTarget[playerid]), number_format(DDSalePrice[playerid]));
  355. SendClientMessageEx(playerid, COLOR_CYAN, string);
  356. SendClientMessageEx(playerid, COLOR_GREY, "To cancel your dynamic door sale request offer, use (/cancel door).");
  357. format(string, sizeof(string), "** NEW DYNAMIC DOOR SALE OFFER FROM %s: **", GetPlayerNameEx(playerid));
  358. SendClientMessageEx(DDSaleTarget[playerid], COLOR_CYAN, string);
  359. format(string, sizeof(string), "» (Price): $%s", number_format(DDSalePrice[playerid]));
  360. SendClientMessageEx(DDSaleTarget[playerid], COLOR_WHITE, string);
  361. for(new i = 0; i < sizeof(DDSaleDoors[]); i ++)
  362. {
  363. if(DDSaleDoors[playerid][i] != 0 && GetPlayerSQLId(playerid) == DDoorsInfo[DDSaleDoors[playerid][i]][ddOwner])
  364. {
  365. format(string, sizeof(string), "» (Door ID %d): %s", DDSaleDoors[playerid][i], DDoorsInfo[DDSaleDoors[playerid][i]][ddDescription]);
  366. SendClientMessageEx(DDSaleTarget[playerid], COLOR_WHITE, string);
  367. }
  368. }
  369. SendClientMessageEx(DDSaleTarget[playerid], COLOR_CYAN, "Use (/accept door) to accept the dynamic door sale offer.");
  370. DDSalePendingPlayer[playerid] = true;
  371. DDSaleTimer[playerid] = defer DDSaleTimerEx(playerid);
  372. return 1;
  373. }
  374. }
  375. return 1;
  376. }
  377. }
  378. return 1;
  379. }
  380. case DIALOG_DDSALEPRICE:
  381. {
  382. switch(response)
  383. {
  384. case false: return ShowDynamicDoorDialog(playerid);
  385. case true:
  386. {
  387. if(!IsPlayerConnected(DDSaleTarget[playerid]) || DDSaleTarget[playerid] == INVALID_PLAYER_ID)
  388. {
  389. SendClientMessageEx(playerid, COLOR_GREY, "The specified buyer is no longer connected.");
  390. ClearDoorSaleVariables(playerid);
  391. return 1;
  392. }
  393. if(DDSalePendingPlayer[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from the specified buyer.");
  394. if(DDSalePendingAdmin[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from server administration.");
  395. new price, fine;
  396. if(sscanf(inputtext, "d", price))
  397. {
  398. SendClientMessageEx(playerid, COLOR_GREY, "The specified dynamic door sale price must be numerical.");
  399. ShowPlayerDialogEx(playerid, DIALOG_DDSALEPRICE, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input the total price of the sale below.", "Okay", "Cancel");
  400. return 1;
  401. }
  402. if(price < 1 || price > 1000000000)
  403. {
  404. SendClientMessageEx(playerid, COLOR_GREY, "The specified dynamic door sale price cannot be under $1 or over $1,000,000,000.");
  405. ShowPlayerDialogEx(playerid, DIALOG_DDSALEPRICE, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input the total price of the sale below.", "Okay", "Cancel");
  406. return 1;
  407. }
  408. if(GetPlayerCash(DDSaleTarget[playerid]) < price)
  409. {
  410. format(string, sizeof(string), "%s does not have enough money for the transaction ($%s).", GetPlayerNameEx(DDSaleTarget[playerid]), number_format(price));
  411. SendClientMessageEx(playerid, COLOR_GREY, string);
  412. ShowPlayerDialogEx(playerid, DIALOG_DDSALEPRICE, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input the total price of the sale below.", "Okay", "Cancel");
  413. return 1;
  414. }
  415. fine = CalculatePercentage(price, 10, 1000000);
  416. if(GetPlayerCash(playerid) < fine)
  417. {
  418. format(string, sizeof(string), "You do not have the sufficient funds for the transfer fine ($%s).", number_format(fine));
  419. SendClientMessageEx(playerid, COLOR_GREY, string);
  420. ShowPlayerDialogEx(playerid, DIALOG_DDSALEPRICE, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input the total price of the sale below.", "Okay", "Cancel");
  421. return 1;
  422. }
  423. DDSalePrice[playerid] = price;
  424. SendClientMessageEx(playerid, COLOR_GREEN, "You have updated your dynamic door sale price.");
  425. ShowDynamicDoorDialog(playerid);
  426. return 1;
  427. }
  428. }
  429. return 1;
  430. }
  431. case DIALOG_DDSALELINK:
  432. {
  433. switch(response)
  434. {
  435. case false: return ShowDynamicDoorDialog(playerid);
  436. case true:
  437. {
  438. if(!IsPlayerConnected(DDSaleTarget[playerid]) || DDSaleTarget[playerid] == INVALID_PLAYER_ID)
  439. {
  440. SendClientMessageEx(playerid, COLOR_GREY, "The specified buyer is no longer connected.");
  441. ClearDoorSaleVariables(playerid);
  442. return 1;
  443. }
  444. if(DDSalePendingPlayer[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from the specified buyer.");
  445. if(DDSalePendingAdmin[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from server administration.");
  446. new doorid;
  447. if(sscanf(inputtext, "d", doorid))
  448. {
  449. SendClientMessageEx(playerid, COLOR_GREY, "The specified door ID must be numerical.");
  450. ShowPlayerDialogEx(playerid, DIALOG_DDSALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the dynamic door you would like to link to the sale. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  451. return 1;
  452. }
  453. if(doorid < 0 || doorid >= MAX_DDOORS)
  454. {
  455. SendClientMessageEx(playerid, COLOR_GREY, "Invalid door ID specified.");
  456. ShowPlayerDialogEx(playerid, DIALOG_DDSALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the dynamic door you would like to link to the sale. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  457. return 1;
  458. }
  459. for(new i = 0; i < sizeof(DDSaleDoors[]); i ++)
  460. {
  461. if(DDSaleDoors[playerid][i] == doorid && doorid != 0)
  462. {
  463. SendClientMessageEx(playerid, COLOR_GREY, "The specified dynamic door is already linked to your sale.");
  464. ShowPlayerDialogEx(playerid, DIALOG_DDSALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the dynamic door you would like to link to the sale. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  465. return 1;
  466. }
  467. }
  468. switch(doorid)
  469. {
  470. case 0:
  471. {
  472. if(DDSaleDoors[playerid][DDSaleTracking[playerid]] == 0)
  473. {
  474. SendClientMessageEx(playerid, COLOR_GREY, "You do not currently have a linked dynamic door in the specified slot.");
  475. ShowPlayerDialogEx(playerid, DIALOG_DDSALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the dynamic door you would like to link to the sale. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  476. return 1;
  477. }
  478. DDSaleDoors[playerid][DDSaleTracking[playerid]] = 0;
  479. SendClientMessageEx(playerid, COLOR_GREEN, "You have updated/removed the linked dynamic door(s) to your sale.");
  480. ShowDynamicDoorDialog(playerid);
  481. return 1;
  482. }
  483. default:
  484. {
  485. if(DDoorsInfo[doorid][ddOwner] != GetPlayerSQLId(playerid))
  486. {
  487. SendClientMessageEx(playerid, COLOR_GREY, "You do not own the specified dynamic door.");
  488. ShowPlayerDialogEx(playerid, DIALOG_DDSALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the dynamic door you would like to link to the sale. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  489. return 1;
  490. }
  491. DDSaleDoors[playerid][DDSaleTracking[playerid]] = doorid;
  492. SendClientMessageEx(playerid, COLOR_GREEN, "You have updated the linked dynamic door(s) to your sale.");
  493. ShowDynamicDoorDialog(playerid);
  494. return 1;
  495. }
  496. }
  497. return 1;
  498. }
  499. }
  500. return 1;
  501. }
  502. case DIALOG_GARAGESALELINK:
  503. {
  504. switch(response)
  505. {
  506. case false: return ShowDynamicDoorDialog(playerid);
  507. case true:
  508. {
  509. if(!IsPlayerConnected(DDSaleTarget[playerid]) || DDSaleTarget[playerid] == INVALID_PLAYER_ID)
  510. {
  511. SendClientMessageEx(playerid, COLOR_GREY, "The specified buyer is no longer connected.");
  512. ClearDoorSaleVariables(playerid);
  513. return 1;
  514. }
  515. if(DDSalePendingPlayer[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from the specified buyer.");
  516. if(DDSalePendingAdmin[playerid] == true) return SendClientMessageEx(playerid, COLOR_GREY, "Your dynamic door sale is pending approval from server administration.");
  517. new garageid;
  518. if(sscanf(inputtext, "d", garageid))
  519. {
  520. SendClientMessageEx(playerid, COLOR_GREY, "The specified garage ID must be numerical.");
  521. ShowPlayerDialogEx(playerid, DIALOG_GARAGESALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the garage you would like to link to the sale. Input \"0\" to remove a garage.", "Okay", "Cancel");
  522. return 1;
  523. }
  524. if(garageid < 0 || garageid >= MAX_GARAGES)
  525. {
  526. SendClientMessageEx(playerid, COLOR_GREY, "Invalid garage ID specified.");
  527. ShowPlayerDialogEx(playerid, DIALOG_GARAGESALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the garage you would like to link to the sale. Input \"0\" to remove a garage.", "Okay", "Cancel");
  528. return 1;
  529. }
  530. if(garageid == 0)
  531. {
  532. DDSaleDoors[playerid][DDSaleTracking[playerid]] = 0;
  533. ShowDynamicDoorDialog(playerid);
  534. return 1;
  535. }
  536. for(new i = 0; i < sizeof(DDSaleDoors[]); i ++)
  537. {
  538. if(DDSaleDoors[playerid][i] == garageid && garageid != 0)
  539. {
  540. SendClientMessageEx(playerid, COLOR_GREY, "The specified garage is already linked to your sale.");
  541. ShowPlayerDialogEx(playerid, DIALOG_GARAGESALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the garage you would like to link to the sale. Input \"0\" to remove a garage.", "Okay", "Cancel");
  542. return 1;
  543. }
  544. }
  545. switch(garageid)
  546. {
  547. case 0:
  548. {
  549. if(DDSaleDoors[playerid][DDSaleTracking[playerid]] == 0)
  550. {
  551. SendClientMessageEx(playerid, COLOR_GREY, "You do not currently have a linked garage in the specified slot.");
  552. ShowPlayerDialogEx(playerid, DIALOG_GARAGESALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the garage you would like to link to the sale. Input \"0\" to remove a garage.", "Okay", "Cancel");
  553. return 1;
  554. }
  555. DDSaleDoors[playerid][DDSaleTracking[playerid]] = 0;
  556. SendClientMessageEx(playerid, COLOR_GREEN, "You have updated/removed the linked garage(s) to your sale.");
  557. ShowDynamicDoorDialog(playerid);
  558. return 1;
  559. }
  560. default:
  561. {
  562. if(GarageInfo[garageid][gar_Owner] != GetPlayerSQLId(playerid))
  563. {
  564. SendClientMessageEx(playerid, COLOR_GREY, "You do not own the specified garage.");
  565. ShowPlayerDialogEx(playerid, DIALOG_GARAGESALELINK, DIALOG_STYLE_INPUT, "Dynamic Door Selling", "Input below the ID of the garage you would like to link to the sale. Input \"0\" to remove a garage.", "Okay", "Cancel");
  566. return 1;
  567. }
  568. DDSaleDoors[playerid][DDSaleTracking[playerid]] = garageid;
  569. SendClientMessageEx(playerid, COLOR_GREEN, "You have updated the linked garage(s) to your sale.");
  570. ShowDynamicDoorDialog(playerid);
  571. return 1;
  572. }
  573. }
  574. return 1;
  575. }
  576. }
  577. return 1;
  578. }
  579. }
  580. return 0;
  581. }