1
0

marriage.pwn 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Marriage 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. stock ClearMarriage(playerid)
  34. {
  35. if(IsPlayerConnected(playerid)) {
  36. new string[MAX_PLAYER_NAME];
  37. format(string, sizeof(string), "Nobody");
  38. strmid(PlayerInfo[playerid][pMarriedName], string, 0, strlen(string), MAX_PLAYER_NAME);
  39. PlayerInfo[playerid][pMarriedID] = -1;
  40. }
  41. return 1;
  42. }
  43. CMD:divorce(playerid, params[])
  44. {
  45. if(!IsAJudge(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not part of the Judicial System!");
  46. if(PlayerInfo[playerid][pRank] < 5) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command - only rank 5+ can do this.");
  47. new targets[2];
  48. if(sscanf(params, "uu", targets[0], targets[1])) return SendClientMessageEx(playerid, COLOR_GRAD1, "USAGE: /divorce [Part Of Name/ ID] [Part Of Name/ ID]");
  49. if(!IsPlayerConnected(targets[0]) || !IsPlayerConnected(targets[1])) return SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player(s) specified.");
  50. if(strcmp(GetPlayerNameEx(targets[0]), PlayerInfo[targets[1]][pMarriedName], true) != 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "The two players specified aren't married to one another.");
  51. if(!ProxDetectorS(25.0, playerid, targets[0]) || !ProxDetectorS(25.0, playerid, targets[1])) return SendClientMessageEx(playerid, COLOR_GRAD1, "You aren't near the couple you are attempting to divorce.");
  52. ClearMarriage(targets[0]);
  53. ClearMarriage(targets[1]);
  54. szMiscArray[0] = 0;
  55. format(szMiscArray, sizeof(szMiscArray), "You have divorced %s and %s.", GetPlayerNameEx(targets[0]), GetPlayerNameEx(targets[1]));
  56. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMiscArray);
  57. format(szMiscArray, sizeof(szMiscArray), "You have been divorced from %s by %s.", GetPlayerNameEx(targets[1]), GetPlayerNameEx(playerid));
  58. SendClientMessageEx(targets[0], COLOR_LIGHTBLUE, szMiscArray);
  59. format(szMiscArray, sizeof(szMiscArray), "You have been divorced from %s by %s.", GetPlayerNameEx(targets[0]), GetPlayerNameEx(playerid));
  60. SendClientMessageEx(targets[1], COLOR_LIGHTBLUE, szMiscArray);
  61. format(szMiscArray, sizeof(szMiscArray), "%s has divorced %s and %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(targets[0]), GetPlayerNameEx(targets[1]));
  62. GroupLog(PlayerInfo[playerid][pMember], szMiscArray);
  63. return 1;
  64. }
  65. /*CMD:divorce(playerid, params[])
  66. {
  67. if(PlayerInfo[playerid][pMarriedID] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You're not married!");
  68. new string[128], giveplayerid;
  69. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /divorce [player]");
  70. if(IsPlayerConnected(giveplayerid))
  71. {
  72. if (ProxDetectorS(8.0, playerid, giveplayerid))
  73. {
  74. new dstring[MAX_PLAYER_NAME];
  75. new wstring[MAX_PLAYER_NAME];
  76. new giveplayer[MAX_PLAYER_NAME];
  77. GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  78. format(string, sizeof(string), "%s", giveplayer);
  79. strmid(wstring, string, 0, strlen(string), 24);
  80. format(string, sizeof(string), "%s", PlayerInfo[playerid][pMarriedName]);
  81. strmid(dstring, string, 0, strlen(string), 24);
  82. if(strcmp(dstring ,wstring, true ) == 0 )
  83. {
  84. format(string, sizeof(string), "* You've sent Divorce Papers to %s.", GetPlayerNameEx(giveplayerid));
  85. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  86. format(string, sizeof(string), "* %s just sent you their Divorce Papers (type /accept divorce) to accept.", GetPlayerNameEx(playerid));
  87. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  88. DivorceOffer[giveplayerid] = playerid;
  89. return 1;
  90. }
  91. else
  92. {
  93. SendClientMessageEx(playerid, COLOR_GREY, " That person is not Married to you!");
  94. return 1;
  95. }
  96. }
  97. else
  98. {
  99. SendClientMessageEx(playerid, COLOR_GREY, "That person isn't near you.");
  100. return 1;
  101. }
  102. }
  103. else
  104. {
  105. SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  106. return 1;
  107. }
  108. }*/
  109. CMD:adivorce(playerid, params[])
  110. {
  111. if(PlayerInfo[playerid][pAdmin] >= 3)
  112. {
  113. new string[128], giveplayerid;
  114. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /adivorce [player]");
  115. if(IsPlayerConnected(giveplayerid))
  116. {
  117. if(PlayerInfo[giveplayerid][pMarriedID] != -1)
  118. {
  119. foreach(new i: Player)
  120. {
  121. if(PlayerInfo[i][pMarriedID] == GetPlayerSQLId(giveplayerid)) ClearMarriage(i);
  122. }
  123. mysql_format(MainPipeline, string, sizeof(string), "UPDATE `accounts` SET `MarriedID` = -1 WHERE id = %d", PlayerInfo[giveplayerid][pMarriedID]);
  124. mysql_tquery(MainPipeline, string, "OnQueryFinish", "i", SENDDATA_THREAD);
  125. }
  126. ClearMarriage(giveplayerid);
  127. format(string, sizeof(string), "* You've admin divorced %s.", GetPlayerNameEx(giveplayerid));
  128. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  129. format(string, sizeof(string), "* You have been admin divorced by an admin.", GetPlayerNameEx(playerid));
  130. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  131. return 1;
  132. }
  133. else
  134. {
  135. SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  136. return 1;
  137. }
  138. }
  139. else
  140. {
  141. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  142. return 1;
  143. }
  144. }
  145. CMD:propose(playerid, params[])
  146. {
  147. if(GetPlayerCash(playerid) < 100000) return SendClientMessageEx(playerid, COLOR_GREY, " The marriage and reception costs $100,000!");
  148. if(PlayerInfo[playerid][pMarriedID] != -1) return SendClientMessageEx(playerid, COLOR_GREY, " You're already married!");
  149. new string[128], giveplayerid;
  150. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /propose [player]");
  151. if(IsPlayerConnected(giveplayerid))
  152. {
  153. if(PlayerInfo[giveplayerid][pMarriedID] != -1) return SendClientMessageEx(playerid, COLOR_GREY, " That person is already married!");
  154. else if(MarryWitness[playerid] == giveplayerid || MarryWitnessOffer[giveplayerid] == playerid) return SendClientMessageEx(playerid, COLOR_GREY, " You can't marry the witness!");
  155. if(ProxDetectorS(8.0, playerid, giveplayerid))
  156. {
  157. if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You cannot Propose to yourself!"); return 1; }
  158. format(string, sizeof(string), "* You proposed to %s.", GetPlayerNameEx(giveplayerid));
  159. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  160. format(string, sizeof(string), "* %s just proposed to you (type /accept marriage) to accept.", GetPlayerNameEx(playerid));
  161. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  162. ProposeOffer[giveplayerid] = playerid;
  163. ShowPlayerDialogEx(playerid, DIALOG_MARRIAGE, DIALOG_STYLE_MSGBOX, "Marriage Last Name",
  164. "As the proposer you have the initial option to keep your last name or use your spouse's.\n\
  165. If you decide to keep your last name, your spouse will be given same option.\n\
  166. Please use the buttons below to make your decision.", "Keep", "Use Their's");
  167. }
  168. else return SendClientMessageEx(playerid, COLOR_GREY, "That person isn't near you.");
  169. }
  170. else return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  171. return 1;
  172. }
  173. CMD:witness(playerid, params[])
  174. {
  175. new string[128], giveplayerid;
  176. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /witness [player]");
  177. if(IsPlayerConnected(giveplayerid))
  178. {
  179. if (ProxDetectorS(8.0, playerid, giveplayerid))
  180. {
  181. if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You cannot Propose to yourself!"); return 1; }
  182. if(ProposeOffer[giveplayerid] == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "Your spouse can't be the marriage witness!"); return 1; }
  183. format(string, sizeof(string), "* You requested %s to be your Marriage Witness.", GetPlayerNameEx(giveplayerid));
  184. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  185. format(string, sizeof(string), "* %s just requested you to be their Marriage Witness (type /accept witness) to accept.", GetPlayerNameEx(playerid));
  186. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  187. MarryWitnessOffer[giveplayerid] = playerid;
  188. }
  189. else
  190. {
  191. SendClientMessageEx(playerid, COLOR_GREY, "That person isn't near you.");
  192. return 1;
  193. }
  194. }
  195. else
  196. {
  197. SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  198. return 1;
  199. }
  200. return 1;
  201. }