SDK360

New System

May 25th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.45 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <string>
  4. #include <stdlib.h>
  5. #include "Hud_Elems.h"
  6.  
  7. struct Items
  8. {
  9.     char* Name;
  10.     void(*OnSelect)(void* Stuff);
  11.     void* Param;
  12.     void Items::AddOption(char* _Name, void (*_OnSelect)(void* _Stuff),void* _Param)
  13.     {
  14.         Name = _Name;
  15.         OnSelect = _OnSelect;
  16.         Param = _Param;
  17.     }
  18. };
  19.  
  20. enum MenuFlags : int
  21. {
  22.     NO_FLAG,
  23.     IsVIP_Only = 0x10,
  24.     IsHost_Only = 0x20
  25. };
  26.  
  27. struct Menu
  28. {
  29.     char* Title;
  30.     int Size;
  31.     Items Options[18];
  32.     MenuFlags Flags;
  33.     void(*OnClose)(void* Stuff);
  34.     void* Param;
  35.     void Menu::AddMenu(char* _Title, int _Size, Items _Options[18], MenuFlags _Flags, void (*_OnClose)(void*),void* _Param)
  36.     {
  37.         Title = _Title;
  38.         Size = _Size;
  39.         OnClose = _OnClose;
  40.         Param = _Param;
  41.         for(int i = 0; i < 18; i++)
  42.             Options[i] = _Options[i];
  43.     }
  44. };
  45.  
  46. enum Status : int
  47. {
  48.     MenuIsClosed,
  49.     MenuIsOpen,
  50.     IsVerified,
  51.     IsVIP = 4,
  52.     IsHost = 8,
  53.     ElemCached = 16
  54. };
  55.  
  56. struct ClientStatus
  57. {
  58.     int Status;
  59.     int MenuY;
  60.     Menu Current_Menu;
  61. };
  62.  
  63. ClientStatus ClientInfo_t[18];
  64. game_hudelem_s *Background[18];
  65. game_hudelem_s *Scrollbar[18];
  66. game_hudelem_s *MenuTitle[18];
  67. game_hudelem_s *Option1[18];
  68. game_hudelem_s *Option2[18];
  69. game_hudelem_s *Option3[18];
  70. game_hudelem_s *Option4[18];
  71. game_hudelem_s *Option5[18];
  72. game_hudelem_s *Option6[18];
  73. game_hudelem_s *Option7[18];
  74. game_hudelem_s *Option8[18];
  75. game_hudelem_s *Option9[18];
  76. game_hudelem_s *Option10[18];
  77. game_hudelem_s *Option11[18];
  78. game_hudelem_s *Option12[18];
  79. game_hudelem_s *Option13[18];
  80. game_hudelem_s *Option14[18];
  81. game_hudelem_s *Option15[18];
  82. game_hudelem_s *Option16[18];
  83. game_hudelem_s *Option17[18];
  84. game_hudelem_s *Option18[18];
  85.  
  86. int CurrentClient = 0;
  87.  
  88. typedef bool (__cdecl * Dvar_GetBool_t)(const char * dvarName);
  89. Dvar_GetBool_t Dvar_GetBool = (Dvar_GetBool_t)0x8229EF58;
  90. typedef void (*SV_GameSendServerCommand_t)(int Client, int Type, const char* CMD);
  91. SV_GameSendServerCommand_t SV_GameSendServerCommand = (SV_GameSendServerCommand_t)0x822548C8;
  92.  
  93. unsigned int getPlayerState(unsigned int Client)
  94. {
  95.     return (0x830CBF80 + (Client * 0x3700));
  96. }
  97.  
  98. void Blank(void* Blank)
  99. {
  100. }
  101.  
  102. Menu _Main;
  103. Menu Main2;
  104.  
  105. void CloseMenu(void* Client)
  106. {
  107.     int TempClient = *(int*)Client;
  108.     setShader(Background[TempClient],"white",0,0,0,0,0,0,0);
  109.     printf("Background hiden\n");
  110.     setShader(Scrollbar[TempClient],"white",0,0,0,0,0,0,0);
  111.     printf("Scrollbar hiden\n");
  112.     ClientInfo_t[TempClient].Status ^= MenuIsOpen;
  113. }
  114.  
  115. void OpenMenu(int Client, Menu C_Menu)
  116. {
  117.     setShader(Background[Client],"white",320,200,200,800,1,5,0,0,0,0,245);
  118.     setShader(Scrollbar[Client],"white",320,97,200,20,1,0x5,.5f,255,255,255,195);
  119.     if((ClientInfo_t[Client].Status & MenuIsOpen) != MenuIsOpen)
  120.         ClientInfo_t[Client].Status |= MenuIsOpen;
  121.        
  122. }
  123.  
  124. void SubMenu(void* _Menu)
  125. {
  126.     Menu* Temp = (Menu*)_Menu;
  127.     if(Temp->Flags & IsVIP_Only)
  128.     {
  129.         if(ClientInfo_t[CurrentClient].Status & IsVIP || ClientInfo_t[CurrentClient].Status & IsHost)
  130.         {
  131.             ClientInfo_t[CurrentClient].Current_Menu.AddMenu(Temp->Title,Temp->Size,Temp->Options,Temp->Flags,Temp->OnClose,Temp->Param);
  132.             OpenMenu(CurrentClient, ClientInfo_t[CurrentClient].Current_Menu);
  133.         }
  134.         else
  135.             SV_GameSendServerCommand(CurrentClient,0,"f \"\x0015^1Access Denied.\"");
  136.     }
  137.     else if(Temp->Flags & IsHost_Only)
  138.     {
  139.         if(ClientInfo_t[CurrentClient].Status & IsHost)
  140.         {
  141.             ClientInfo_t[CurrentClient].Current_Menu.AddMenu(Temp->Title,Temp->Size,Temp->Options,Temp->Flags,Temp->OnClose,Temp->Param);
  142.             OpenMenu(CurrentClient, ClientInfo_t[CurrentClient].Current_Menu);
  143.         }
  144.         else
  145.             SV_GameSendServerCommand(CurrentClient,0,"f \"\x0015^1Access Denied.\"");
  146.     }
  147.     else if(ClientInfo_t[CurrentClient].Status & IsVerified)
  148.     {
  149.         ClientInfo_t[CurrentClient].Current_Menu.AddMenu(Temp->Title,Temp->Size,Temp->Options,Temp->Flags,Temp->OnClose,Temp->Param);
  150.         OpenMenu(CurrentClient, ClientInfo_t[CurrentClient].Current_Menu);
  151.     }
  152. }
  153.  
  154. void CacheElems(int Client)
  155. {
  156.     Background[Client] = HudElem_Alloc(Client,0);
  157.     Scrollbar[Client] = HudElem_Alloc(Client,0);
  158.     MenuTitle[Client] = HudElem_Alloc(Client,0);
  159.     Option1[Client] = HudElem_Alloc(Client,0);
  160.     Option2[Client] = HudElem_Alloc(Client,0);
  161.     Option3[Client] = HudElem_Alloc(Client,0);
  162.     Option4[Client] = HudElem_Alloc(Client,0);
  163.     Option5[Client] = HudElem_Alloc(Client,0);
  164.     Option6[Client] = HudElem_Alloc(Client,0);
  165.     Option7[Client] = HudElem_Alloc(Client,0);
  166.     Option8[Client] = HudElem_Alloc(Client,0);
  167.     Option9[Client] = HudElem_Alloc(Client,0);
  168.     Option10[Client] = HudElem_Alloc(Client,0);
  169.     Option11[Client] = HudElem_Alloc(Client,0);
  170.     Option12[Client] = HudElem_Alloc(Client,0);
  171.     Option13[Client] = HudElem_Alloc(Client,0);
  172.     Option14[Client] = HudElem_Alloc(Client,0);
  173.     Option15[Client] = HudElem_Alloc(Client,0);
  174.     Option16[Client] = HudElem_Alloc(Client,0);
  175.     Option17[Client] = HudElem_Alloc(Client,0);
  176.     Option18[Client] = HudElem_Alloc(Client,0);
  177.     ClientInfo_t[Client].Status ^= ElemCached;
  178. }
  179.  
  180. void LoadOptions()
  181. {
  182.     Items Temp[18];
  183.     Temp[0].AddOption("Option 1", Blank, NULL);
  184.     Temp[1].AddOption("Option 2", Blank, NULL);
  185.     Temp[2].AddOption("Option 3", Blank, NULL);
  186.     Temp[3].AddOption("Option 4", Blank, NULL);
  187.     Temp[4].AddOption("Option 5", Blank, NULL);
  188.     Temp[5].AddOption("Option 6", Blank, NULL);
  189.     _Main.AddMenu("Main", 6, Temp, NO_FLAG, &CloseMenu, (void*)CurrentClient);
  190.     Temp[0].AddOption("Option 1", Blank, NULL);
  191.     Temp[1].AddOption("Option 2", Blank, NULL);
  192.     Temp[2].AddOption("Option 3", Blank, NULL);
  193.     Temp[3].AddOption("Option 4", Blank, NULL);
  194.     Temp[4].AddOption("Option 5", Blank, NULL);
  195.     Temp[5].AddOption("Option 6", Blank, NULL);
  196.     Main2.AddMenu("Sub Menu", 6, Temp, NO_FLAG, Blank, NULL);
  197. }
  198.  
  199. void Monitor(int Client)
  200. {
  201.    
  202.     if((ClientInfo_t[Client].Status & ElemCached) != ElemCached)
  203.     {
  204.         CacheElems(Client);
  205.         printf("Cache Elems Called\n");
  206.     }
  207.     int ButtonPressed = *(int *)(getPlayerState((unsigned int)Client) + 0x3438);
  208.     if(ButtonPressed & 0x4000)
  209.     {
  210.         printf("RB Pressed\n");
  211.         if(ClientInfo_t[Client].MenuY <= 0)
  212.             ClientInfo_t[Client].MenuY = ClientInfo_t[Client].Current_Menu.Size;
  213.         else
  214.             ClientInfo_t[Client].MenuY--;
  215.         MoveOverTime(Scrollbar[Client], 1000, 100, 50 + (18.75f + ClientInfo_t[Client].MenuY));
  216.     }
  217.     else if(ButtonPressed & 0x8000)
  218.     {
  219.         printf("LB Pressed\n");
  220.         if(ClientInfo_t[Client].MenuY >= ClientInfo_t[Client].Current_Menu.Size)
  221.             ClientInfo_t[Client].MenuY = 0;
  222.         else
  223.             ClientInfo_t[Client].MenuY++;
  224.         MoveOverTime(Scrollbar[Client], 1000, 100, 50 + (18.75f + ClientInfo_t[Client].MenuY));
  225.     }
  226.     else if(ButtonPressed == 0x20)
  227.     {
  228.         printf("X Pressed\n");
  229.         ClientInfo_t[Client].Current_Menu.Options[ClientInfo_t[Client].MenuY].OnSelect(ClientInfo_t[Client].Current_Menu.Options[ClientInfo_t[Client].MenuY].Param);
  230.         Sleep(25);
  231.     }
  232.     else if(ButtonPressed == 0x4)
  233.     {
  234.         printf("RS Pressed\n");
  235.         if(ClientInfo_t[Client].Status & MenuIsOpen)
  236.         {
  237.             printf("Close Menu Called\n");
  238.             ClientInfo_t[Client].Current_Menu.OnClose((void*)&CurrentClient);
  239.             Sleep(25);
  240.         }
  241.         else
  242.         {
  243.             SubMenu((void*)&_Main);
  244.             Sleep(25);
  245.         }
  246.     }
  247. }
  248.  
  249. DWORD WINAPI commands(LPVOID)
  250. {
  251.     for(;;)
  252.     {
  253.         Sleep(0.1);
  254.         if(Dvar_GetBool("Cl_InGame"))
  255.         {
  256.             if(CurrentClient >= 18)
  257.                 CurrentClient = 0;
  258.             Monitor(CurrentClient);
  259.             CurrentClient++;
  260.         }
  261.     }
  262. }
  263.  
  264. BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD reason, LPVOID lpReserved)
  265. {
  266.   switch(reason)
  267.   {
  268.     case DLL_PROCESS_ATTACH:
  269.       CreateThread(0,0,commands,0,0,0);
  270.       printf("Xex Hooked, Thread Created\n");
  271.       break;
  272.   }
  273.   return TRUE;
  274. }
Advertisement
Add Comment
Please, Sign In to add comment