1
0

GunLicense.pwn 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include <YSI\y_hooks>
  2. /*CMD:gunlicenseapply(playerid, params[]) {
  3. szMiscArray[0] = 0;
  4. if(!IsPlayerInRangeOfPoint(playerid, 5.0, 1464.3099, -1747.5853, 15.6267))
  5. return SendClientMessageEx(playerid, COLOR_GRAD1, "You aren't at the government arms point at City Hall in Los Santos.");
  6. if(PlayerInfo[playerid][pGunLic] > gettime()) return SendClientMessageEx(playerid, COLOR_GRAD2, "You already have a valid gun license");
  7. ShowPlayerDialogEx(playerid, APPLY_GUN_LIC, DIALOG_STYLE_MSGBOX,
  8. "Gun License Application",
  9. "You are about to apply for a gun license\nYou will have a background check for crimes for the last 3 weeks\nThis process will cost $100,000",
  10. "Apply",
  11. "Cancel"
  12. );
  13. return 1;
  14. }*/
  15. CMD:issuegl(playerid, params[]) return cmd_issuegunlicense(playerid, params);
  16. CMD:issuegunlicense(playerid, params[])
  17. {
  18. if((0 <= PlayerInfo[playerid][pLeader] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pLeader]][g_iGroupType] == GROUP_TYPE_GOV)
  19. {
  20. new iTargetID;
  21. szMiscArray[0] = 0;
  22. if(sscanf(params, "u", iTargetID)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /issuegunlicense [playerid]");
  23. PlayerInfo[iTargetID][pGunLic] = gettime() + (86400*30);
  24. format(szMiscArray, sizeof(szMiscArray), "%s has renewed %s's gun license.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID));
  25. foreach(new i : Player)
  26. if((0 <= PlayerInfo[i][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[i][pMember]][g_iGroupType] == GROUP_TYPE_GOV)
  27. SendClientMessageEx(i, COLOR_RED, szMiscArray);
  28. format(szMiscArray, sizeof(szMiscArray), "%s(%d) (%s) has issued %s(%d) (%s) a gun license.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), GetPlayerNameEx(iTargetID), GetPlayerSQLId(iTargetID), GetPlayerIpEx(iTargetID));
  29. Log("logs/licenses.log", szMiscArray);
  30. }
  31. else SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to use this command!");
  32. return 1;
  33. }
  34. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  35. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  36. switch(dialogid) {
  37. case APPLY_GUN_LIC: {
  38. if(!response) return SendClientMessageEx(playerid, COLOR_WHITE, "You have chosen not to apply for a gun license!");
  39. else {
  40. if(GetPlayerCash(playerid) >= 100000) SubmitGunLicApp(playerid);
  41. else SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money.");
  42. }
  43. }
  44. }
  45. return 0;
  46. }
  47. SubmitGunLicApp(iPlayerID) {
  48. szMiscArray[0] = 0;
  49. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT * FROM `mdc` WHERE `id` = '%d' AND (`time` > DATE_SUB(NOW(), INTERVAL 21 DAY))", PlayerInfo[iPlayerID][pId]);
  50. mysql_tquery(MainPipeline, szMiscArray, "OnSubmitGunLicApp", "i", iPlayerID);
  51. return 1;
  52. }
  53. forward OnSubmitGunLicApp(iPlayerID);
  54. public OnSubmitGunLicApp(iPlayerID) {
  55. szMiscArray[0] = 0;
  56. new iRows;
  57. cache_get_row_count(iRows);
  58. if(iRows > 0) {
  59. ShowPlayerDialogEx(iPlayerID, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "Gun License Application - Denied",
  60. "We have run a background check and found a history within the past 21 days\nPlease reapply once 21 days have past from your last crime!",
  61. "Close", ""
  62. );
  63. }
  64. else {
  65. ShowPlayerDialogEx(iPlayerID, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "Gun License Application - Approved", "Your gun license has been renewed for 30 days more.\nHave a good day!", "Close", "");
  66. PlayerInfo[iPlayerID][pGunLic] = gettime() + (86400*30); // 30 days.
  67. GivePlayerCash(iPlayerID, -100000);
  68. Tax+=100000;
  69. format(szMiscArray, sizeof(szMiscArray), "%s has renewed their gun license for $100,000.", GetPlayerNameEx(iPlayerID));
  70. Log("logs/licenses.log", szMiscArray);
  71. }
  72. return 1;
  73. }