Advertisement
SinceModz

Untitled

Jan 23rd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.98 KB | None | 0 0
  1. //Menu base created by 2much4u
  2.  
  3. #include <cellstatus.h>
  4. #include <sys/prx.h>
  5. #include <sys/ppu_thread.h>
  6. #include <string.h>
  7. #include <sys/memory.h>
  8. #include <sys/timer.h>
  9. #include <sys/process.h>
  10. #include <ppu_intrinsics.h>
  11. #include <stdarg.h>
  12. #include <stdio.h>
  13. #include <cstdlib>
  14. #include "Enums.h"
  15. #include "Natives.h"
  16.  
  17. SYS_MODULE_INFO("GTAV_Native_Invoker", 0, 1, 1);
  18. SYS_MODULE_START(PRX_ENTRY);
  19.  
  20. #pragma region Variables
  21. Native_s** g_Natives;
  22. int submenu = 0;
  23. int submenuLevel;
  24. int lastSubmenu[20];
  25. int lastOption[20];
  26. int currentOption;
  27. int optionCount;
  28. bool optionPress = false;
  29. bool rightPress = false;
  30. bool leftPress = false;
  31. bool fastRightPress = false;
  32. bool fastLeftPress = false;
  33. bool squarePress = false;
  34. int selectedPlayer;
  35. bool menuSounds = true;
  36. bool keyboardActive = false;
  37. int keyboardAction;
  38. int *keyboardVar = 0;
  39. char *infoText;
  40.  
  41. bool newTimerTick = true;
  42. int maxTimerCount;
  43. bool newTimerTick2 = true;
  44. int maxTimerCount2;
  45.  
  46. bool instructions = true;
  47. int instructCount;
  48. int mov;
  49. bool instructionsSetupThisFrame;
  50. bool xInstruction;
  51. bool squareInstruction;
  52. bool lrInstruction;
  53.  
  54. int bannerTextRed = 255;
  55. int bannerTextGreen = 255;
  56. int bannerTextBlue = 255;
  57. int bannerTextOpacity = 255;
  58. int bannerTextFont = 1;
  59. int bannerRectRed = 0;
  60. int bannerRectGreen = 255;
  61. int bannerRectBlue = 255;
  62. int bannerRectOpacity = 255;
  63. int backgroundRed = 16;
  64. int backgroundGreen = 16;
  65. int backgroundBlue = 16;
  66. int backgroundOpacity = 70;
  67. int optionsRed = 255;
  68. int optionsGreen = 255;
  69. int optionsBlue = 255;
  70. int optionsOpacity = 255;
  71. int optionsFont = 0;
  72. int scrollerRed = 255;
  73. int scrollerGreen = 255;
  74. int scrollerBlue = 255;
  75. int scrollerOpacity = 50;
  76. int indicatorRed = 255;
  77. int indicatorGreen = 255;
  78. int indicatorBlue = 255;
  79. int indicatorOpacity = 255;
  80. float menuXCoord = 0.845f;
  81. float textXCoord = 0.76f;
  82. int maxOptions = 18;
  83. #pragma endregion
  84.  
  85. #pragma region Internals
  86. void HookNative(int native, int dest) {
  87. int FuncBytes[1];
  88. FuncBytes[0] = *(int*)dest;
  89. memcpy((void*)native, FuncBytes, 4);
  90. }
  91. int write_process(void* destination, const void* source, size_t size)
  92. {
  93. system_call_4(905, (uint64_t)sys_process_getpid(), (uint64_t)destination, size, (uint64_t)source);
  94. return_to_user_prog(int);
  95. }
  96. void PatchInJump(uint64_t Address, int Destination, bool Linked)
  97. {
  98. int FuncBytes[4]; // Use this data to copy over the address.
  99. Destination = *(int*)Destination; // Get the actual destination address (pointer to void).
  100. FuncBytes[0] = 0x3D600000 + ((Destination >> 16) & 0xFFFF); // lis %r11, dest>>16
  101. if (Destination & 0x8000) // if bit 16 is 1...
  102. FuncBytes[0] += 1;
  103. FuncBytes[1] = 0x396B0000 + (Destination & 0xFFFF); // addi %r11, %r11, dest&OxFFFF
  104. FuncBytes[2] = 0x7D6903A6; // mtctr %r11
  105. FuncBytes[3] = 0x4E800420; // bctr
  106. if (Linked)
  107. FuncBytes[3] += 1; // bctrl
  108. write_process((void*)Address, FuncBytes, 4 * 4);
  109. //memcpy((void*)Address, FuncBytes, 4 * 4);
  110. }
  111. unsigned int FindNativeTableAddress()
  112. {
  113. unsigned int l_uiNativeTableAddress = 0;
  114. unsigned int l_uiStartAddress = 0x390000;
  115. unsigned int l_uiAddress = 0;
  116. for (unsigned int i = 0; i < 0x10000; i++)
  117. {
  118. if (*(unsigned int*)(l_uiStartAddress + i) == 0x3C6072BD)
  119. if (*(unsigned int*)(l_uiStartAddress + i + 8) == 0x6063E002)
  120. {
  121. l_uiAddress = *(unsigned int*)(l_uiStartAddress + i + 0x10);
  122. l_uiAddress &= 0xFFFFFF;
  123. l_uiAddress += (l_uiStartAddress + i + 0x10) - 1;
  124. printf("address: 0x%08x\n", l_uiAddress);
  125. break;
  126. }
  127. }
  128. l_uiNativeTableAddress = (*(unsigned int*)(l_uiAddress + 0x24) << 16) + (*(unsigned int*)(l_uiAddress + 0x2C) & 0xFFFF);
  129. l_uiNativeTableAddress -= 0x10000;
  130. return l_uiNativeTableAddress;
  131. }
  132. int NativeAddress(int Native, bool PatchInJump = true)
  133. {
  134. int Hash = Native & 0xFF;
  135. int Table = *(int*)(FindNativeTableAddress() + (Hash * 4));
  136. while (Table != 0)
  137. {
  138. int NativeCount = *(int*)(Table + 0x20);
  139. for (int i = 0; i < NativeCount; i++)
  140. {
  141. if (*(int*)((Table + 0x24) + (i * 4)) == Native)
  142. {
  143. if (PatchInJump)
  144. {
  145. int NativeLocation = *(int*)(*(int*)((Table + 4) + (i * 4)));
  146. for (int i = 0; i < 50; ++i)
  147. {
  148. short CurrentPlace = *(short*)(NativeLocation + (i * 4));
  149. if (CurrentPlace == 0x4AE6 || CurrentPlace == 0x4AA8 || CurrentPlace == 0x4AE4 || CurrentPlace == 0x4AE5)
  150. {
  151. return (((*(int*)(NativeLocation + (i * 4))) - 0x48000001) + (NativeLocation + (i * 4))) - 0x4000000;
  152. }
  153. }
  154. }
  155. else
  156. {
  157. return *(int*)((Table + 4) + (i * 4));
  158. }
  159.  
  160. }
  161. }
  162. Table = *(int*)(Table);
  163. }
  164. }
  165. void sleep(usecond_t time) //1 second = 1000
  166. {
  167. sys_timer_usleep(time * 1000);
  168. }
  169. void set_text_component(char *text)
  170. {
  171. GRAPHICS::_0x3AC9CB55("STRING");
  172. UI::_ADD_TEXT_COMPONENT_STRING(text);
  173. GRAPHICS::_0x386CE0B8();
  174. }
  175. void instructionsSetup()
  176. {
  177. mov = GRAPHICS::REQUEST_SCALEFORM_MOVIE("instructional_buttons");
  178. GRAPHICS::_0x7B48E696(mov, 255, 255, 255, 0);
  179. GRAPHICS::_0x215ABBE8(mov, "CLEAR_ALL");
  180. GRAPHICS::_0x02DBF2D7();
  181. GRAPHICS::_0x215ABBE8(mov, "SET_CLEAR_SPACE");
  182. GRAPHICS::_0x716777CB(200);
  183. GRAPHICS::_0x02DBF2D7();
  184. instructCount = 0;
  185. }
  186. void addInstruction(int button, char *text)
  187. {
  188. if (!instructionsSetupThisFrame)
  189. {
  190. instructionsSetup();
  191. instructionsSetupThisFrame = true;
  192. }
  193. GRAPHICS::_0x215ABBE8(mov, "SET_DATA_SLOT");
  194. GRAPHICS::_0x716777CB(instructCount);
  195. GRAPHICS::_0x716777CB(button);
  196. set_text_component(text);
  197. GRAPHICS::_0x02DBF2D7();
  198. instructCount++;
  199. }
  200. void instructionsClose()
  201. {
  202. GRAPHICS::_0x215ABBE8(mov, "DRAW_INSTRUCTIONAL_BUTTONS");
  203. GRAPHICS::_0x02DBF2D7();
  204. GRAPHICS::_0x215ABBE8(mov, "SET_BACKGROUND_COLOUR");
  205. GRAPHICS::_0x716777CB(0);
  206. GRAPHICS::_0x716777CB(0);
  207. GRAPHICS::_0x716777CB(0);
  208. GRAPHICS::_0x716777CB(80);
  209. GRAPHICS::_0x02DBF2D7();
  210. }
  211. void drawText(char * text, int font, float x, float y, float scalex, float scaley, int r, int b, int g, int a, bool center)
  212. {
  213. UI::SET_TEXT_FONT(font);
  214. UI::SET_TEXT_SCALE(scalex, scaley);
  215. UI::SET_TEXT_COLOUR(r, g, b, a);
  216. UI::SET_TEXT_WRAP(0.0f, 1.0f);
  217. UI::SET_TEXT_CENTRE(center);
  218. UI::SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);
  219. UI::SET_TEXT_OUTLINE();
  220. UI::_SET_TEXT_ENTRY("STRING");
  221. UI::_ADD_TEXT_COMPONENT_STRING(text);
  222. UI::_DRAW_TEXT(x, y);
  223. }
  224. void drawNotification(char* msg)
  225. {
  226. if (menuXCoord == 0.845f)
  227. {
  228. UI::_0x574EE85C("STRING");
  229. UI::_ADD_TEXT_COMPONENT_STRING(msg);
  230. UI::_SET_NOTIFICATION_MESSAGE("CHAR_SOCIAL_CLUB", "CHAR_SOCIAL_CLUB", true, 4, "Menu Base", "");
  231. UI::_DRAW_NOTIFICATION(false, true);
  232. }
  233. else
  234. {
  235. UI::_0xF42C43C7("STRING");
  236. UI::_ADD_TEXT_COMPONENT_STRING(msg);
  237. UI::_0x38F82261(3000, 1);
  238. }
  239. }
  240. void playSound(char* sound)
  241. {
  242. if (menuSounds)
  243. AUDIO::PLAY_SOUND_FRONTEND(-1, sound, "HUD_FRONTEND_DEFAULT_SOUNDSET");
  244. }
  245. bool isNumericChar(char x)
  246. {
  247. return (x >= '0' && x <= '9') ? true : false;
  248. }
  249. int StoI(char *str)
  250. {
  251. if (*str == NULL)
  252. return 0;
  253.  
  254. int res = 0,
  255. sign = 1,
  256. i = 0;
  257.  
  258. if (str[0] == '-')
  259. {
  260. sign = -1;
  261. i++;
  262. }
  263. for (; str[i] != '\0'; ++i)
  264. {
  265. if (isNumericChar(str[i]) == false)
  266. return 0;
  267. res = res * 10 + str[i] - '0';
  268. }
  269. return sign*res;
  270. }
  271. char *ItoS(int num)
  272. {
  273. char buf[30];
  274. snprintf(buf, sizeof(buf), "%i", num);
  275. return buf;
  276. }
  277. char* FtoS(float input)
  278. {
  279. char returnvalue[64];
  280. int wholenumber = (int)input;
  281. input -= wholenumber;
  282. input *= 100;
  283. sprintf(returnvalue, "%d.%d", wholenumber, (int)input);
  284. return returnvalue;
  285. }
  286. void startKeyboard(int action, char *defaultText, int maxLength)
  287. {
  288. GAMEPLAY::DISPLAY_ONSCREEN_KEYBOARD(0, "FMMC_KEY_TIP8", "", defaultText, "", "", "", maxLength);
  289. keyboardAction = action;
  290. keyboardActive = true;
  291. }
  292. void changeSubmenu(int newSubmenu)
  293. {
  294. lastSubmenu[submenuLevel] = submenu;
  295. lastOption[submenuLevel] = currentOption;
  296. currentOption = 1;
  297. submenu = newSubmenu;
  298. submenuLevel++;
  299. }
  300. void SetupTimer(int tickTime)
  301. {
  302. if (newTimerTick) {
  303. maxTimerCount = GAMEPLAY::GET_GAME_TIMER() + tickTime;
  304. newTimerTick = false;
  305. }
  306. }
  307. bool IsTimerReady()
  308. {
  309. return GAMEPLAY::GET_GAME_TIMER() > maxTimerCount;
  310. }
  311. void ResetTimer()
  312. {
  313. newTimerTick = true;
  314. }
  315. void SetupTimer2(int tickTime)
  316. {
  317. if (newTimerTick2) {
  318. maxTimerCount2 = GAMEPLAY::GET_GAME_TIMER() + tickTime;
  319. newTimerTick2 = false;
  320. }
  321. }
  322. bool IsTimerReady2()
  323. {
  324. return GAMEPLAY::GET_GAME_TIMER() > maxTimerCount2;
  325. }
  326. void ResetTimer2()
  327. {
  328. newTimerTick2 = true;
  329. }
  330. void addTitle(char *title)
  331. {
  332. drawText(title, bannerTextFont, menuXCoord, 0.1f, 0.75f, 0.75f, bannerTextRed, bannerTextGreen, bannerTextBlue, bannerTextOpacity, true);
  333. GRAPHICS::DRAW_RECT(menuXCoord, 0.1175f, 0.19f, 0.083f, bannerRectRed, bannerRectGreen, bannerRectBlue, bannerRectOpacity);
  334. }
  335. #pragma region Option Helpers
  336. void addOption(char *option, char *info = NULL)
  337. {
  338. optionCount++;
  339. if (currentOption == optionCount)
  340. infoText = info;
  341. if (currentOption <= maxOptions && optionCount <= maxOptions)
  342. drawText(option, optionsFont, textXCoord, (optionCount * 0.035f + 0.125f), 0.4f, 0.4f, optionsRed, optionsGreen, optionsBlue, optionsOpacity, false);
  343. else if ((optionCount > (currentOption - maxOptions)) && optionCount <= currentOption)
  344. drawText(option, optionsFont, textXCoord, ((optionCount - (currentOption - maxOptions)) * 0.035f + 0.125f), 0.4f, 0.4f, optionsRed, optionsGreen, optionsBlue, optionsOpacity, false);
  345. }
  346. void addSubmenuOption(char *option, int newSubmenu, char *info = NULL)
  347. {
  348. addOption(option, info);
  349. if (currentOption == optionCount)
  350. {
  351. xInstruction = true;
  352. if (optionPress)
  353. changeSubmenu(newSubmenu);
  354. }
  355. }
  356. void addBoolOption(char *option, bool b00l, char *info = NULL)
  357. {
  358. char buf[30];
  359. if (b00l)
  360. {
  361. snprintf(buf, sizeof(buf), "%s: On", option);
  362. addOption(buf, info);
  363. }
  364. else
  365. {
  366. snprintf(buf, sizeof(buf), "%s: Off", option);
  367. addOption(buf, info);
  368. }
  369. }
  370. template<typename TYPE>
  371. void addCustomBoolOption(char *option, TYPE value, TYPE match, char *info = NULL)
  372. {
  373. char buf[30];
  374. if (value == match)
  375. {
  376. snprintf(buf, sizeof(buf), "%s: On", option);
  377. addOption(buf, info);
  378. }
  379. else
  380. {
  381. snprintf(buf, sizeof(buf), "%s: Off", option);
  382. addOption(buf, info);
  383. }
  384. }
  385. void addIntOption(char *option, int *var, int min, int max, bool keyboard, char *info = NULL)
  386. {
  387. char buf[30];
  388. snprintf(buf, sizeof(buf), "%s: < %i >", option, *var);
  389. addOption(buf, info);
  390. if (currentOption == optionCount)
  391. {
  392. lrInstruction = true;
  393. if (rightPress)
  394. {
  395. playSound("NAV_UP_DOWN");
  396. if (*var >= max)
  397. *var = min;
  398. else
  399. *var = *var + 1;
  400. }
  401. else if (leftPress)
  402. {
  403. playSound("NAV_UP_DOWN");
  404. if (*var <= min)
  405. *var = max;
  406. else
  407. *var = *var - 1;
  408. }
  409. if (keyboard)
  410. {
  411. squareInstruction = true;
  412. if (squarePress)
  413. {
  414. startKeyboard(0, "", (strlen(ItoS(max)) + 1));
  415. keyboardVar = var;
  416. }
  417. }
  418. }
  419. }
  420. void addFloatOption(char *option, float *var, float min, float max, bool holdPress, char *info = NULL)
  421. {
  422. char buf[30];
  423. snprintf(buf, sizeof(buf), "%s: < %s >", option, FtoS(*var));
  424. addOption(buf, info);
  425. if (currentOption == optionCount)
  426. {
  427. lrInstruction = true;
  428. if (holdPress)
  429. {
  430. if (fastRightPress)
  431. {
  432. playSound("NAV_UP_DOWN");
  433. if (*var >= max)
  434. *var = min;
  435. else
  436. *var = *var + 0.01f;
  437. }
  438. else if (fastLeftPress)
  439. {
  440. playSound("NAV_UP_DOWN");
  441. if (*var <= min)
  442. *var = max;
  443. else
  444. *var = *var - 0.01f;
  445. }
  446. }
  447. else
  448. {
  449. if (rightPress)
  450. {
  451. playSound("NAV_UP_DOWN");
  452. if (*var >= max)
  453. *var = min;
  454. else
  455. *var = *var + 0.01f;
  456. }
  457. else if (leftPress)
  458. {
  459. playSound("NAV_UP_DOWN");
  460. if (*var <= min)
  461. *var = max;
  462. else
  463. *var = *var - 0.01f;
  464. }
  465. }
  466. }
  467. }
  468. void addKeyboardOption(char *option, int action, char *defaultText, int maxLength, char *info = NULL)
  469. {
  470. addOption(option, info);
  471. if (currentOption == optionCount)
  472. {
  473. xInstruction = true;
  474. if (optionPress)
  475. startKeyboard(action, defaultText, maxLength);
  476. }
  477. }
  478. #pragma endregion
  479. int getOption()
  480. {
  481. xInstruction = true;
  482. if (optionPress)
  483. return currentOption;
  484. else return 0;
  485. }
  486. void monitorButtons()
  487. {
  488. SetupTimer(20);
  489. if (submenu == Closed)
  490. {
  491. if (IsTimerReady())
  492. {
  493. if (CONTROLS::IS_CONTROL_PRESSED(0, Button_R1) && CONTROLS::IS_CONTROL_PRESSED(0, Dpad_Left))
  494. {
  495. submenu = Main_Menu;
  496. submenuLevel = 0;
  497. currentOption = 1;
  498. playSound("YES");
  499. }
  500. ResetTimer();
  501. }
  502. }
  503. else {
  504. if (IsTimerReady())
  505. {
  506. if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Button_B))
  507. {
  508. if (submenu == Main_Menu)
  509. {
  510. submenu = Closed;
  511. }
  512. else {
  513. submenu = lastSubmenu[submenuLevel - 1];
  514. currentOption = lastOption[submenuLevel - 1];
  515. submenuLevel--;
  516. }
  517. playSound("Back");
  518. }
  519. else if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Button_A))
  520. {
  521. optionPress = true;
  522. playSound("SELECT");
  523. }
  524. else if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Dpad_Up))
  525. {
  526. currentOption--;
  527. if (currentOption < 1)
  528. {
  529. currentOption = optionCount;
  530. }
  531. playSound("NAV_UP_DOWN");
  532. }
  533. else if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Dpad_Down))
  534. {
  535. currentOption++;
  536. if (currentOption > optionCount)
  537. {
  538. currentOption = 1;
  539. }
  540. playSound("NAV_UP_DOWN");
  541. }
  542. else if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Dpad_Right))
  543. {
  544. rightPress = true;
  545. }
  546. else if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Dpad_Left))
  547. {
  548. leftPress = true;
  549. }
  550. else if (CONTROLS::IS_CONTROL_PRESSED(0, Dpad_Right))
  551. {
  552. fastRightPress = true;
  553. }
  554. else if (CONTROLS::IS_CONTROL_PRESSED(0, Dpad_Left))
  555. {
  556. fastLeftPress = true;
  557. }
  558. else if (CONTROLS::IS_CONTROL_JUST_PRESSED(0, Button_X))
  559. {
  560. squarePress = true;
  561. }
  562. ResetTimer();
  563. }
  564. }
  565. }
  566. void normalMenuActions()
  567. {
  568. UI::HIDE_HELP_TEXT_THIS_FRAME();
  569. CAM::SET_CINEMATIC_BUTTON_ACTIVE(0);
  570. UI::HIDE_HUD_COMPONENT_THIS_FRAME(10);
  571. UI::HIDE_HUD_COMPONENT_THIS_FRAME(6);
  572. UI::HIDE_HUD_COMPONENT_THIS_FRAME(7);
  573. UI::HIDE_HUD_COMPONENT_THIS_FRAME(9);
  574. UI::HIDE_HUD_COMPONENT_THIS_FRAME(8);
  575. CONTROLS::DISABLE_CONTROL_ACTION(0, 19);
  576. CONTROLS::DISABLE_CONTROL_ACTION(0, 20);
  577. CONTROLS::DISABLE_CONTROL_ACTION(0, 21);
  578. CONTROLS::DISABLE_CONTROL_ACTION(0, 27);
  579. CONTROLS::DISABLE_CONTROL_ACTION(0, 54);
  580. CONTROLS::DISABLE_CONTROL_ACTION(0, 123);
  581. CONTROLS::DISABLE_CONTROL_ACTION(0, 124);
  582. CONTROLS::DISABLE_CONTROL_ACTION(0, 125);
  583. CONTROLS::DISABLE_CONTROL_ACTION(0, 126);
  584. CONTROLS::DISABLE_CONTROL_ACTION(0, 138);
  585. CONTROLS::DISABLE_CONTROL_ACTION(0, 139);
  586. CONTROLS::DISABLE_CONTROL_ACTION(0, 140);
  587. CONTROLS::DISABLE_CONTROL_ACTION(0, 177);
  588. CONTROLS::DISABLE_CONTROL_ACTION(0, 178);
  589. CONTROLS::DISABLE_CONTROL_ACTION(0, 179);
  590. CONTROLS::DISABLE_CONTROL_ACTION(0, 207);
  591. CONTROLS::SET_INPUT_EXCLUSIVE(2, 166);
  592. CONTROLS::SET_INPUT_EXCLUSIVE(2, 167);
  593. CONTROLS::SET_INPUT_EXCLUSIVE(2, 177);
  594. CONTROLS::SET_INPUT_EXCLUSIVE(2, 178);
  595. CONTROLS::SET_INPUT_EXCLUSIVE(2, 193);
  596. CONTROLS::SET_INPUT_EXCLUSIVE(2, 194);
  597. CONTROLS::SET_INPUT_EXCLUSIVE(2, 195);
  598. CONTROLS::SET_INPUT_EXCLUSIVE(2, 202);
  599. CONTROLS::SET_INPUT_EXCLUSIVE(2, 203);
  600. CONTROLS::SET_INPUT_EXCLUSIVE(2, 204);
  601. CONTROLS::SET_INPUT_EXCLUSIVE(2, 205);
  602. if (optionCount > maxOptions)
  603. {
  604. GRAPHICS::DRAW_RECT(menuXCoord, (((maxOptions * 0.035f) / 2) + 0.159f), 0.19f, (maxOptions * 0.035f), backgroundRed, backgroundGreen, backgroundBlue, backgroundOpacity); //Background
  605. if (currentOption > maxOptions)
  606. {
  607. GRAPHICS::DRAW_RECT(menuXCoord, ((maxOptions * 0.035f) + 0.1415f), 0.19f, 0.035f, scrollerRed, scrollerGreen, scrollerBlue, scrollerOpacity); //Scroller
  608. GRAPHICS::DRAW_RECT(menuXCoord, 0.156f, 0.19f, 0.005f, indicatorRed, indicatorGreen, indicatorBlue, indicatorOpacity); //Up Indicator
  609. }
  610. else
  611. {
  612. GRAPHICS::DRAW_RECT(menuXCoord, ((currentOption * 0.035f) + 0.1415f), 0.19f, 0.035f, scrollerRed, scrollerGreen, scrollerBlue, scrollerOpacity); //Scroller
  613. }
  614. if (currentOption != optionCount)
  615. {
  616. GRAPHICS::DRAW_RECT(menuXCoord, ((maxOptions * 0.035f) + 0.161f), 0.19f, 0.005f, indicatorRed, indicatorGreen, indicatorBlue, indicatorOpacity); //Down Indicator
  617. }
  618. }
  619. else
  620. {
  621. GRAPHICS::DRAW_RECT(menuXCoord, (((optionCount * 0.035f) / 2) + 0.159f), 0.19f, (optionCount * 0.035f), backgroundRed, backgroundGreen, backgroundBlue, backgroundOpacity); //Background
  622. GRAPHICS::DRAW_RECT(menuXCoord, ((currentOption * 0.035f) + 0.1415f), 0.19f, 0.035f, scrollerRed, scrollerGreen, scrollerBlue, scrollerOpacity); //Scroller
  623. }
  624. if (!GAMEPLAY::IS_STRING_NULL_OR_EMPTY(infoText))
  625. {
  626. if (optionCount > maxOptions)
  627. {
  628. drawText(infoText, optionsFont, menuXCoord, ((maxOptions + 1) * 0.035f + 0.125f), 0.4f, 0.4f, bannerTextRed, bannerTextGreen, bannerTextBlue, bannerTextOpacity, true);
  629. GRAPHICS::DRAW_RECT(menuXCoord, (((maxOptions + 1) * 0.035f) + 0.1415f), 0.19f, 0.035f, bannerRectRed, bannerRectGreen, bannerRectBlue, bannerRectOpacity); //Info Box
  630. }
  631. else
  632. {
  633. drawText(infoText, optionsFont, menuXCoord, ((optionCount + 1) * 0.035f + 0.125f), 0.4f, 0.4f, bannerTextRed, bannerTextGreen, bannerTextBlue, bannerTextOpacity, true);
  634. GRAPHICS::DRAW_RECT(menuXCoord, (((optionCount + 1) * 0.035f) + 0.1415f), 0.19f, 0.035f, bannerRectRed, bannerRectGreen, bannerRectBlue, bannerRectOpacity); //Info Box
  635. }
  636. }
  637. SetupTimer2(20);
  638. if (instructions)
  639. {
  640. if (IsTimerReady2())
  641. {
  642. if (xInstruction)
  643. addInstruction(BUTTON_A, "Select");
  644. if (squareInstruction)
  645. addInstruction(BUTTON_X, "Keyboard");
  646. if (lrInstruction)
  647. addInstruction(BUTTON_DPAD_LEFT_RIGHT, "Scroll");
  648. addInstruction(BUTTON_DPAD_UP_DOWN, "Scroll");
  649. addInstruction(BUTTON_B, "Back");
  650. instructionsClose();
  651. ResetTimer2();
  652. }
  653. }
  654. }
  655. void resetVars()
  656. {
  657. if (submenu != Closed)
  658. normalMenuActions();
  659. optionPress = false;
  660. rightPress = false;
  661. leftPress = false;
  662. fastRightPress = false;
  663. fastLeftPress = false;
  664. squarePress = false;
  665. infoText = NULL;
  666. instructionsSetupThisFrame = false;
  667. squareInstruction = false;
  668. xInstruction = false;
  669. lrInstruction = false;
  670. }
  671. #pragma endregion
  672.  
  673. #pragma region Other Loop
  674. void otherLoop()
  675. {
  676. if (keyboardActive)
  677. {
  678. if (GAMEPLAY::UPDATE_ONSCREEN_KEYBOARD() == 1)
  679. {
  680. keyboardActive = false;
  681. switch (keyboardAction)
  682. {
  683. case 0: //addIntOption
  684. *keyboardVar = StoI(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT());
  685. break;
  686. }
  687. }
  688. else if (GAMEPLAY::UPDATE_ONSCREEN_KEYBOARD() == 2 || GAMEPLAY::UPDATE_ONSCREEN_KEYBOARD() == 3)
  689. {
  690. keyboardActive = false;
  691. }
  692. }
  693. }
  694. #pragma endregion
  695.  
  696. int Hook()
  697. {
  698. monitorButtons();
  699. otherLoop();
  700. optionCount = 0;
  701. switch (submenu)
  702. {
  703. #pragma region Main Menu
  704. case Main_Menu:
  705. addTitle("Main Menu");
  706. addSubmenuOption("Players List", Players_List);
  707. addSubmenuOption("Self Options", Self_Options);
  708. addSubmenuOption("Settings", Settings, "Customize the menu");
  709. break;
  710. #pragma endregion
  711. #pragma region Players List
  712. case Players_List:
  713. addTitle("Players List");
  714. for (int i = 0; i < 18; i++)
  715. {
  716. addOption(PLAYER::GET_PLAYER_NAME(i));
  717. }
  718. if (optionPress && PLAYER::IS_PLAYER_PLAYING(currentOption - 1))
  719. {
  720. selectedPlayer = currentOption - 1;
  721. changeSubmenu(Player_Options);
  722. }
  723. break;
  724. #pragma endregion
  725. #pragma region Player Options
  726. case Player_Options:
  727. addTitle(PLAYER::GET_PLAYER_NAME(selectedPlayer));
  728. //various player options here
  729. //use PLAYER::GET_PLAYER_PED(selectedPlayer) to get the ped rather than player.
  730. break;
  731. #pragma endregion
  732. #pragma region Self Options
  733. case Self_Options:
  734. addTitle("Self Options");
  735. addBoolOption("Godmode", PLAYER::GET_PLAYER_INVINCIBLE(PLAYER::PLAYER_ID()));
  736. addBoolOption("Invisibility", !ENTITY::IS_ENTITY_VISIBLE(PLAYER::PLAYER_PED_ID()));
  737. switch (getOption())
  738. {
  739. case 1: PLAYER::SET_PLAYER_INVINCIBLE(PLAYER::PLAYER_ID(), !PLAYER::GET_PLAYER_INVINCIBLE(PLAYER::PLAYER_ID())); break;
  740. case 2: ENTITY::SET_ENTITY_VISIBLE(PLAYER::PLAYER_PED_ID(), !ENTITY::IS_ENTITY_VISIBLE(PLAYER::PLAYER_PED_ID())); break;
  741. }
  742. break;
  743. #pragma endregion
  744. #pragma region Settings
  745. case Settings:
  746. addTitle("Settings");
  747. addSubmenuOption("Banners", Settings_Banners);
  748. addSubmenuOption("Body", Settings_Body);
  749. addSubmenuOption("Scroller", Settings_Scroller);
  750. addSubmenuOption("Indicators", Settings_Indicators);
  751. addBoolOption("Sounds", menuSounds);
  752. addBoolOption("Instructions", instructions);
  753. addCustomBoolOption("Left Sided", menuXCoord, 0.145f);
  754. addIntOption("Max Options", &maxOptions, 1, 20, false);
  755. switch (getOption())
  756. {
  757. case 5: menuSounds = !menuSounds; break;
  758. case 6: instructions = !instructions; break;
  759. case 7:
  760. if (menuXCoord == 0.145f)
  761. {
  762. menuXCoord = 0.845f;
  763. textXCoord = 0.76f;
  764. }
  765. else
  766. {
  767. menuXCoord = 0.145f;
  768. textXCoord = 0.06f;
  769. }
  770. break;
  771. }
  772. break;
  773. case Settings_Banners:
  774. addTitle("Banners");
  775. addIntOption("Text Red", &bannerTextRed, 0, 255, true);
  776. addIntOption("Text Green", &bannerTextGreen, 0, 255, true);
  777. addIntOption("Text Blue", &bannerTextBlue, 0, 255, true);
  778. addIntOption("Text Opacity", &bannerTextOpacity, 0, 255, true);
  779. addIntOption("Text Font", &bannerTextFont, 0, 7, false);
  780. addIntOption("Rect Red", &bannerRectRed, 0, 255, true);
  781. addIntOption("Rect Green", &bannerRectGreen, 0, 255, true);
  782. addIntOption("Rect Blue", &bannerRectBlue, 0, 255, true);
  783. addIntOption("Rect Opacity", &bannerRectOpacity, 0, 255, true);
  784. break;
  785. case Settings_Body:
  786. addTitle("Body");
  787. addIntOption("Text Red", &optionsRed, 0, 255, true);
  788. addIntOption("Text Green", &optionsGreen, 0, 255, true);
  789. addIntOption("Text Blue", &optionsBlue, 0, 255, true);
  790. addIntOption("Text Opacity", &optionsOpacity, 0, 255, true);
  791. addIntOption("Text Font", &optionsFont, 0, 7, false);
  792. addIntOption("Rect Red", &backgroundRed, 0, 255, true);
  793. addIntOption("Rect Green", &backgroundGreen, 0, 255, true);
  794. addIntOption("Rect Blue", &backgroundBlue, 0, 255, true);
  795. addIntOption("Rect Opacity", &backgroundOpacity, 0, 255, true);
  796. break;
  797. case Settings_Scroller:
  798. addTitle("Scroller");
  799. addIntOption("Red", &scrollerRed, 0, 255, true);
  800. addIntOption("Green", &scrollerGreen, 0, 255, true);
  801. addIntOption("Blue", &scrollerBlue, 0, 255, true);
  802. addIntOption("Opacity", &scrollerOpacity, 0, 255, true);
  803. break;
  804. case Settings_Indicators:
  805. addTitle("Indicators");
  806. addIntOption("Red", &indicatorRed, 0, 255, true);
  807. addIntOption("Green", &indicatorGreen, 0, 255, true);
  808. addIntOption("Blue", &indicatorBlue, 0, 255, true);
  809. addIntOption("Opacity", &indicatorOpacity, 0, 255, true);
  810. break;
  811. #pragma endregion
  812. }
  813. resetVars();
  814. return true;
  815. }
  816. void Thread(uint64_t nothing)
  817. {
  818. sleep(30000); //Wait until native table initialization
  819. g_Natives = (Native_s**)FindNativeTableAddress();
  820. PatchInJump(NativeAddress(0x9FAB6729, true), (int)Hook, false); //IS_PLAYER_ONLINE
  821. sys_ppu_thread_exit(nothing);
  822. }
  823. extern "C" int PRX_ENTRY()
  824. {
  825. sys_ppu_thread_t ThreadModuleID;
  826. sys_ppu_thread_create(&ThreadModuleID, Thread, 0, 10, 0x10, 0, "Menu Base");
  827. return SYS_PRX_RESIDENT;
  828. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement