AccountSettings.pwn 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. #include <YSI\y_hooks>
  2. #define ACCOUNT_SETTINGS 10020
  3. #define ACCOUNT_TOGGLEMENU 10021
  4. #define ACCOUNT_CHATBOX 10022
  5. CMD:settings(playerid, params[]) {
  6. ShowAccountSettings(playerid);
  7. return 1;
  8. }
  9. ShowAccountSettings(playerid, menu = 0) {
  10. if(!gPlayerLogged{playerid}) return SendClientMessageEx(playerid, COLOR_WHITE, "You must be logged in to use this.");
  11. szMiscArray[0] = 0;
  12. new szTitle[32];
  13. switch(menu) {
  14. case 0: {
  15. format(szTitle, sizeof(szTitle), "Account Settings - %s", GetPlayerNameEx(playerid));
  16. format(szMiscArray, sizeof(szMiscArray), "Toggle Menu\nChange Account Email\nAccount Password\nChange Shop Pin");
  17. ShowPlayerDialogEx(playerid, ACCOUNT_SETTINGS, DIALOG_STYLE_LIST, szTitle, szMiscArray, "Select", "Cancel");
  18. }
  19. case 1: {
  20. format(szMiscArray, sizeof(szMiscArray), "Item\tStatus\n\
  21. {FFFFFF}---General---\t\n\
  22. {FFFFFF}NG:RP Phone Mod\t%s\n\
  23. {FFFFFF}Newbie Chat\t%s\n\
  24. {FFFFFF}News\t%s\n\
  25. {FFFFFF}OOC Chat\t%s\n\
  26. {FFFFFF}Whispers\t%s\n\
  27. {FFFFFF}First ChatBox\t%s\n\
  28. {FFFFFF}Private Radio\t%s\n\
  29. {FFFFFF}Phone\t%s\n\
  30. {FFFFFF}Famed\t%s\n\
  31. {FFFFFF}VIP\t%s\n",
  32. (PlayerInfo[playerid][pToggledChats][20] == 1) ? ("{00FF00}On") : ("{FF0000}Off"),
  33. (PlayerInfo[playerid][pToggledChats][0] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  34. (PlayerInfo[playerid][pToggledChats][1] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  35. (PlayerInfo[playerid][pToggledChats][2] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  36. (PlayerInfo[playerid][pToggledChats][3] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  37. (PlayerInfo[playerid][pToggledChats][4] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  38. // (PlayerInfo[playerid][pToggledChats][19] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  39. (PlayerInfo[playerid][pToggledChats][5] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  40. (PlayerInfo[playerid][pToggledChats][6] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  41. (PlayerInfo[playerid][pToggledChats][7] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  42. (PlayerInfo[playerid][pToggledChats][8] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  43. (PlayerInfo[playerid][pToggledChats][9] == 0) ? ("{00FF00}On") : ("{FF0000}Off")
  44. );
  45. format(szMiscArray, sizeof(szMiscArray), "%s\
  46. {FFFFFF}---Groups---\t\n\
  47. {FFFFFF}Dept\t%s\n\
  48. {FFFFFF}International\t%s\n\
  49. {FFFFFF}OOC Group\t%s\n\
  50. {FFFFFF}Radio\t%s\n\
  51. {FFFFFF}Bug Chat\t%s\n\
  52. {FFFFFF}Biz Radio\t%s\n\
  53. {FFFFFF}Point Messages\t%s\n\
  54. {FFFFFF}--- Staff ---\t\n\
  55. {FFFFFF}Staff Chat\t%s\n\
  56. {FFFFFF}Advisor Chat\t%s\n\
  57. {FFFFFF}Watchdog Chat\t%s\n",
  58. szMiscArray,
  59. (PlayerInfo[playerid][pToggledChats][10] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  60. (PlayerInfo[playerid][pToggledChats][21] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  61. (PlayerInfo[playerid][pToggledChats][11] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  62. (PlayerInfo[playerid][pToggledChats][12] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  63. (PlayerInfo[playerid][pToggledChats][13] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  64. (PlayerInfo[playerid][pToggledChats][14] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  65. (PlayerInfo[playerid][pToggledChats][15] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  66. (PlayerInfo[playerid][pToggledChats][22] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  67. (PlayerInfo[playerid][pToggledChats][16] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  68. (PlayerInfo[playerid][pToggledChats][17] == 0) ? ("{00FF00}On") : ("{FF0000}Off"),
  69. (PlayerInfo[playerid][pToggledChats][18] == 0) ? ("{00FF00}On") : ("{FF0000}Off")
  70. );
  71. ShowPlayerDialogEx(playerid, ACCOUNT_TOGGLEMENU, DIALOG_STYLE_TABLIST_HEADERS, "Toggle Menu", szMiscArray, "Select", "Cancel");
  72. }
  73. case 2: {
  74. format(szMiscArray, sizeof(szMiscArray), "Item\tChatbox\n\
  75. ---General---\t\n\
  76. Newbie Chat\t%d\n\
  77. News\t%d\n\
  78. OOC Chat\t%d\n\
  79. Whispers\t%d\n\
  80. Private Radio\t%d\n\
  81. Phone\t%d\n\
  82. Famed\t%d\n\
  83. VIP\t%d\n\
  84. ---Groups---\t\n\
  85. Dept\t%d\n\
  86. OOC Group\t%d\n\
  87. Radio\t%d\n\
  88. Bug Chat\t%d\n\
  89. Biz Radio\t%d\n\
  90. --- Staff ---\t\n\
  91. Staff Chat\t%d\n\
  92. Advisor Chat\t%d\n\
  93. Watchdog Chat\t%d\n",
  94. PlayerInfo[playerid][pChatbox][0],
  95. PlayerInfo[playerid][pChatbox][1],
  96. PlayerInfo[playerid][pChatbox][2],
  97. PlayerInfo[playerid][pChatbox][3],
  98. PlayerInfo[playerid][pChatbox][5],
  99. PlayerInfo[playerid][pChatbox][7],
  100. PlayerInfo[playerid][pChatbox][8],
  101. PlayerInfo[playerid][pChatbox][9],
  102. PlayerInfo[playerid][pChatbox][10],
  103. PlayerInfo[playerid][pChatbox][11],
  104. PlayerInfo[playerid][pChatbox][12],
  105. PlayerInfo[playerid][pChatbox][13],
  106. PlayerInfo[playerid][pChatbox][14],
  107. PlayerInfo[playerid][pChatbox][15],
  108. PlayerInfo[playerid][pChatbox][16],
  109. PlayerInfo[playerid][pChatbox][17],
  110. PlayerInfo[playerid][pChatbox][18]
  111. );
  112. ShowPlayerDialogEx(playerid, ACCOUNT_CHATBOX, DIALOG_STYLE_TABLIST_HEADERS, "Chat Preferences", szMiscArray, "Select", "Cancel");
  113. }
  114. case 3: { // account email
  115. ShowPlayerDialogEx(playerid, EMAIL_VALIDATION, DIALOG_STYLE_INPUT, "E-mail Registration", "Please enter a valid e-mail address to associate with your account.", "Submit", "");
  116. }
  117. case 4: { // account password
  118. ShowPlayerDialogEx(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Password Change", "Please enter your new password!\nStaff members will never ask for your password!", "Change", "Exit" );
  119. }
  120. case 5: { // shop pin
  121. if(GetPVarInt(playerid, "PinConfirmed")) {
  122. SetPVarInt(playerid, "ChangePin", 1);
  123. ShowPlayerDialogEx(playerid, DIALOG_CREATEPIN, DIALOG_STYLE_INPUT, "Change Pin Number", "Enter a new pin number to change your current one.", "Change", "Cancel");
  124. }
  125. else PinLogin(playerid);
  126. }
  127. }
  128. return 1;
  129. }
  130. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  131. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  132. switch(dialogid) {
  133. case ACCOUNT_SETTINGS: {
  134. if(!response) {
  135. return 1;
  136. }
  137. switch(listitem) {
  138. case 0: {
  139. ShowAccountSettings(playerid, 1); // toggle settings
  140. }
  141. case 1: {
  142. ShowAccountSettings(playerid, 3); // account email
  143. }
  144. case 2: {
  145. ShowAccountSettings(playerid, 4);
  146. }
  147. case 3: {
  148. ShowAccountSettings(playerid, 5);
  149. }
  150. /*case 4: {
  151. ShowAccountSettings(playerid, 5);
  152. }*/
  153. }
  154. }
  155. case ACCOUNT_TOGGLEMENU: {
  156. if(!response) return ShowAccountSettings(playerid, 0);
  157. new id = -1;
  158. if(strcmp(inputtext, "NG:RP Phone Mod", true) == 0) id = 20;
  159. else if(strcmp(inputtext, "Newbie Chat", true) == 0) id = 0;
  160. else if(strcmp(inputtext, "News", true) == 0) id = 1;
  161. else if(strcmp(inputtext, "OOC Chat", true) == 0) id = 2;
  162. else if(strcmp(inputtext, "Whispers", true) == 0) id = 3;
  163. else if(strcmp(inputtext, "First ChatBox", true) == 0) id = 4;
  164. else if(strcmp(inputtext, "Secondary ChatBox", true) == 0) id = 19;
  165. else if(strcmp(inputtext, "Private Radio", true) == 0) id = 5;
  166. else if(strcmp(inputtext, "Phone", true) == 0) id = 7;
  167. else if(strcmp(inputtext, "Famed", true) == 0) id = 8;
  168. else if(strcmp(inputtext, "VIP", true) == 0) id = 9;
  169. else if(strcmp(inputtext, "Dept", true) == 0) id = 10;
  170. else if(strcmp(inputtext, "International", true) == 0) id = 21;
  171. else if(strcmp(inputtext, "OOC Group", true) == 0) id = 11;
  172. else if(strcmp(inputtext, "Radio", true) == 0) id = 12;
  173. else if(strcmp(inputtext, "Bug Chat", true) == 0) id = 13;
  174. else if(strcmp(inputtext, "Biz Radio", true) == 0) id = 14;
  175. else if(strcmp(inputtext, "Point Messages", true) == 0) id = 22;
  176. else if(strcmp(inputtext, "Staff Chat", true) == 0) id = 15;
  177. else if(strcmp(inputtext, "Advisor Chat", true) == 0) id = 16;
  178. else if(strcmp(inputtext, "Watchdog Chat", true) == 0) id = 17;
  179. // else if(strcmp(inputtext, "Admin", true) == 0) id = 18;
  180. if(id == -1) return ShowAccountSettings(playerid, 1);
  181. if(PlayerInfo[playerid][pToggledChats][id] == 0) {
  182. PlayerInfo[playerid][pToggledChats][id] = 1;
  183. switch(id) {
  184. case 7: PhoneOnline[playerid] = 1;
  185. case 15: advisorchat[playerid] = 0;
  186. case 19: for(new i; i < sizeof(TD_ChatBox); ++i) PlayerTextDrawHide(playerid, TD_ChatBox[i]);
  187. }
  188. }
  189. else {
  190. PlayerInfo[playerid][pToggledChats][id] = 0;
  191. switch(id) {
  192. case 7: PhoneOnline[playerid] = 0;
  193. case 15: advisorchat[playerid] = 1;
  194. case 19: for(new i; i < sizeof(TD_ChatBox); ++i) PlayerTextDrawShow(playerid, TD_ChatBox[i]);
  195. }
  196. }
  197. ShowAccountSettings(playerid, 1);
  198. return 1;
  199. }
  200. case ACCOUNT_CHATBOX: {
  201. if(!response) return DeletePVar(playerid, "ChatboxPref"), ShowAccountSettings(playerid, 0);
  202. if(GetPVarType(playerid, "ChatboxPref")) {
  203. if(0 > strval(inputtext) > 1) return DeletePVar(playerid, "ChatboxPref"), SendClientMessage(playerid, COLOR_GRAD1, "You specified an invalid value.");
  204. PlayerInfo[playerid][pChatbox][GetPVarInt(playerid, "ChatBoxPref")] = strval(inputtext);
  205. DeletePVar(playerid, "ChatboxPref");
  206. ShowAccountSettings(playerid, 2);
  207. return 1;
  208. }
  209. else {
  210. new id = -1;
  211. if(strcmp(inputtext, "Newbie Chat", true) == 0) id = 0;
  212. else if(strcmp(inputtext, "News", true) == 0) id = 1;
  213. else if(strcmp(inputtext, "OOC Chat", true) == 0) id = 2;
  214. else if(strcmp(inputtext, "Whispers", true) == 0) id = 3;
  215. else if(strcmp(inputtext, "Private Radio", true) == 0) id = 5;
  216. else if(strcmp(inputtext, "Phone", true) == 0) id = 7;
  217. else if(strcmp(inputtext, "Famed", true) == 0) id = 8;
  218. else if(strcmp(inputtext, "VIP", true) == 0) id = 9;
  219. else if(strcmp(inputtext, "Dept", true) == 0) id = 10;
  220. else if(strcmp(inputtext, "OOC Group", true) == 0) id = 11;
  221. else if(strcmp(inputtext, "Radio", true) == 0) id = 12;
  222. else if(strcmp(inputtext, "Bug Chat", true) == 0) id = 13;
  223. else if(strcmp(inputtext, "Biz Radio", true) == 0) id = 14;
  224. else if(strcmp(inputtext, "Staff Chat", true) == 0) id = 15;
  225. else if(strcmp(inputtext, "Advisor Chat", true) == 0) id = 16;
  226. else if(strcmp(inputtext, "Watchdog Chat", true) == 0) id = 17;
  227. if(id == -1) return ShowAccountSettings(playerid, 1);
  228. // else if(strcmp(inputtext, "Admin", true) == 0) id = 18;
  229. SetPVarInt(playerid, "ChatboxPref", id);
  230. ShowPlayerDialogEx(playerid, ACCOUNT_CHATBOX, DIALOG_STYLE_INPUT, "Chatbox Preferences", "In which chatbox would you like this chat channel?\n\nAvailable options: Main (0), Bottom Right (1).", "Select", "Cancel");
  231. }
  232. }
  233. }
  234. return 0;
  235. }
  236. CMD:tog(playerid, params[]) {
  237. if(isnull(params)) {
  238. SendClientMessageEx(playerid, COLOR_GRAD1, "USAGE: /tog [option]");
  239. SendClientMessageEx(playerid, COLOR_GRAD1, "OPTIONS: newbie | ooc | whisper | pr | phone | famed | vip | dept | gooc | radio | bug");
  240. SendClientMessageEx(playerid, COLOR_GRAD1, "OPTIONS: biz | staff | advisor | news | chatbox | advisor | points | rf");
  241. return 1;
  242. }
  243. new iChatID = -1, chatname[50];
  244. mysql_escape_string(params, chatname);
  245. if(strcmp(params, "newbie", true) == 0) iChatID = 0;
  246. else if(strcmp(params, "ooc", true) == 0) iChatID = 2;
  247. else if(strcmp(params, "whisper", true) == 0) iChatID = 3;
  248. else if(strcmp(params, "pr", true) == 0) iChatID = 5;
  249. else if(strcmp(params, "phone", true) == 0) iChatID = 7;
  250. else if(strcmp(params, "famed", true) == 0) iChatID = 8;
  251. else if(strcmp(params, "vip", true) == 0) iChatID = 9;
  252. else if(strcmp(params, "dept", true) == 0) iChatID = 10;
  253. else if(strcmp(params, "gooc", true) == 0) iChatID = 11;
  254. else if(strcmp(params, "radio", true) == 0) iChatID = 12;
  255. else if(strcmp(params, "bug", true) == 0) iChatID = 13;
  256. else if(strcmp(params, "biz", true) == 0) iChatID = 14;
  257. else if(strcmp(params, "staff", true) == 0) iChatID = 15;
  258. else if(strcmp(params, "advisor", true) == 0) iChatID = 16;
  259. else if(strcmp(params, "news", true) == 0) iChatID = 1;
  260. else if(strcmp(params, "chatbox", true) == 0) iChatID = 4;
  261. else if(strcmp(params, "advisor", true) == 0) iChatID = 16;
  262. else if(strcmp(params, "points", true) == 0) iChatID = 22;
  263. else if(strcmp(params, "rf", true) == 0) iChatID = 23;
  264. if(!(0 <= iChatID < MAX_CHATSETS)) return 1; // preventing OOB issues.
  265. if(PlayerInfo[playerid][pToggledChats][iChatID] == 0) {
  266. PlayerInfo[playerid][pToggledChats][iChatID] = 1;
  267. switch(iChatID) {
  268. case 7: PhoneOnline[playerid] = 1;
  269. case 15: advisorchat[playerid] = 0;
  270. case 19: for(new i; i < sizeof(TD_ChatBox); ++i) PlayerTextDrawHide(playerid, TD_ChatBox[i]);
  271. case 23: TextDrawHideForPlayer(playerid, TD_RepFam);
  272. }
  273. format(szMiscArray, sizeof(szMiscArray), "You have toggled %s off.", chatname);
  274. SendClientMessage(playerid, COLOR_GRAD1, szMiscArray);
  275. }
  276. else {
  277. PlayerInfo[playerid][pToggledChats][iChatID] = 0;
  278. switch(iChatID) {
  279. case 7: PhoneOnline[playerid] = 0;
  280. case 15: advisorchat[playerid] = 1;
  281. case 19: for(new i; i < sizeof(TD_ChatBox); ++i) PlayerTextDrawShow(playerid, TD_ChatBox[i]);
  282. case 23: if(GetPVarInt(playerid, "RepFam_TL")) TextDrawShowForPlayer(playerid, TD_RepFam);
  283. }
  284. format(szMiscArray, sizeof(szMiscArray), "You have toggled %s on.", chatname);
  285. SendClientMessage(playerid, COLOR_GRAD1, szMiscArray);
  286. }
  287. return 1;
  288. }