Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <string>
- #include <stdlib.h>
- #include "Hud_Elems.h"
- struct Items
- {
- char* Name;
- void(*OnSelect)(void* Stuff);
- void* Param;
- void Items::AddOption(char* _Name, void (*_OnSelect)(void* _Stuff),void* _Param)
- {
- Name = _Name;
- OnSelect = _OnSelect;
- Param = _Param;
- }
- };
- enum MenuFlags : int
- {
- NO_FLAG,
- IsVIP_Only = 0x10,
- IsHost_Only = 0x20
- };
- struct Menu
- {
- char* Title;
- int Size;
- Items Options[18];
- MenuFlags Flags;
- void(*OnClose)(void* Stuff);
- void* Param;
- void Menu::AddMenu(char* _Title, int _Size, Items _Options[18], MenuFlags _Flags, void (*_OnClose)(void*),void* _Param)
- {
- Title = _Title;
- Size = _Size;
- OnClose = _OnClose;
- Param = _Param;
- for(int i = 0; i < 18; i++)
- Options[i] = _Options[i];
- }
- };
- enum Status : int
- {
- MenuIsClosed,
- MenuIsOpen,
- IsVerified,
- IsVIP = 4,
- IsHost = 8,
- ElemCached = 16
- };
- struct ClientStatus
- {
- int Status;
- int MenuY;
- Menu Current_Menu;
- };
- ClientStatus ClientInfo_t[18];
- game_hudelem_s *Background[18];
- game_hudelem_s *Scrollbar[18];
- game_hudelem_s *MenuTitle[18];
- game_hudelem_s *Option1[18];
- game_hudelem_s *Option2[18];
- game_hudelem_s *Option3[18];
- game_hudelem_s *Option4[18];
- game_hudelem_s *Option5[18];
- game_hudelem_s *Option6[18];
- game_hudelem_s *Option7[18];
- game_hudelem_s *Option8[18];
- game_hudelem_s *Option9[18];
- game_hudelem_s *Option10[18];
- game_hudelem_s *Option11[18];
- game_hudelem_s *Option12[18];
- game_hudelem_s *Option13[18];
- game_hudelem_s *Option14[18];
- game_hudelem_s *Option15[18];
- game_hudelem_s *Option16[18];
- game_hudelem_s *Option17[18];
- game_hudelem_s *Option18[18];
- int CurrentClient = 0;
- typedef bool (__cdecl * Dvar_GetBool_t)(const char * dvarName);
- Dvar_GetBool_t Dvar_GetBool = (Dvar_GetBool_t)0x8229EF58;
- typedef void (*SV_GameSendServerCommand_t)(int Client, int Type, const char* CMD);
- SV_GameSendServerCommand_t SV_GameSendServerCommand = (SV_GameSendServerCommand_t)0x822548C8;
- unsigned int getPlayerState(unsigned int Client)
- {
- return (0x830CBF80 + (Client * 0x3700));
- }
- void Blank(void* Blank)
- {
- }
- Menu _Main;
- Menu Main2;
- void CloseMenu(void* Client)
- {
- int TempClient = *(int*)Client;
- setShader(Background[TempClient],"white",0,0,0,0,0,0,0);
- printf("Background hiden\n");
- setShader(Scrollbar[TempClient],"white",0,0,0,0,0,0,0);
- printf("Scrollbar hiden\n");
- ClientInfo_t[TempClient].Status ^= MenuIsOpen;
- }
- void OpenMenu(int Client, Menu C_Menu)
- {
- setShader(Background[Client],"white",320,200,200,800,1,5,0,0,0,0,245);
- setShader(Scrollbar[Client],"white",320,97,200,20,1,0x5,.5f,255,255,255,195);
- if((ClientInfo_t[Client].Status & MenuIsOpen) != MenuIsOpen)
- ClientInfo_t[Client].Status |= MenuIsOpen;
- }
- void SubMenu(void* _Menu)
- {
- Menu* Temp = (Menu*)_Menu;
- if(Temp->Flags & IsVIP_Only)
- {
- if(ClientInfo_t[CurrentClient].Status & IsVIP || ClientInfo_t[CurrentClient].Status & IsHost)
- {
- ClientInfo_t[CurrentClient].Current_Menu.AddMenu(Temp->Title,Temp->Size,Temp->Options,Temp->Flags,Temp->OnClose,Temp->Param);
- OpenMenu(CurrentClient, ClientInfo_t[CurrentClient].Current_Menu);
- }
- else
- SV_GameSendServerCommand(CurrentClient,0,"f \"\x0015^1Access Denied.\"");
- }
- else if(Temp->Flags & IsHost_Only)
- {
- if(ClientInfo_t[CurrentClient].Status & IsHost)
- {
- ClientInfo_t[CurrentClient].Current_Menu.AddMenu(Temp->Title,Temp->Size,Temp->Options,Temp->Flags,Temp->OnClose,Temp->Param);
- OpenMenu(CurrentClient, ClientInfo_t[CurrentClient].Current_Menu);
- }
- else
- SV_GameSendServerCommand(CurrentClient,0,"f \"\x0015^1Access Denied.\"");
- }
- else if(ClientInfo_t[CurrentClient].Status & IsVerified)
- {
- ClientInfo_t[CurrentClient].Current_Menu.AddMenu(Temp->Title,Temp->Size,Temp->Options,Temp->Flags,Temp->OnClose,Temp->Param);
- OpenMenu(CurrentClient, ClientInfo_t[CurrentClient].Current_Menu);
- }
- }
- void CacheElems(int Client)
- {
- Background[Client] = HudElem_Alloc(Client,0);
- Scrollbar[Client] = HudElem_Alloc(Client,0);
- MenuTitle[Client] = HudElem_Alloc(Client,0);
- Option1[Client] = HudElem_Alloc(Client,0);
- Option2[Client] = HudElem_Alloc(Client,0);
- Option3[Client] = HudElem_Alloc(Client,0);
- Option4[Client] = HudElem_Alloc(Client,0);
- Option5[Client] = HudElem_Alloc(Client,0);
- Option6[Client] = HudElem_Alloc(Client,0);
- Option7[Client] = HudElem_Alloc(Client,0);
- Option8[Client] = HudElem_Alloc(Client,0);
- Option9[Client] = HudElem_Alloc(Client,0);
- Option10[Client] = HudElem_Alloc(Client,0);
- Option11[Client] = HudElem_Alloc(Client,0);
- Option12[Client] = HudElem_Alloc(Client,0);
- Option13[Client] = HudElem_Alloc(Client,0);
- Option14[Client] = HudElem_Alloc(Client,0);
- Option15[Client] = HudElem_Alloc(Client,0);
- Option16[Client] = HudElem_Alloc(Client,0);
- Option17[Client] = HudElem_Alloc(Client,0);
- Option18[Client] = HudElem_Alloc(Client,0);
- ClientInfo_t[Client].Status ^= ElemCached;
- }
- void LoadOptions()
- {
- Items Temp[18];
- Temp[0].AddOption("Option 1", Blank, NULL);
- Temp[1].AddOption("Option 2", Blank, NULL);
- Temp[2].AddOption("Option 3", Blank, NULL);
- Temp[3].AddOption("Option 4", Blank, NULL);
- Temp[4].AddOption("Option 5", Blank, NULL);
- Temp[5].AddOption("Option 6", Blank, NULL);
- _Main.AddMenu("Main", 6, Temp, NO_FLAG, &CloseMenu, (void*)CurrentClient);
- Temp[0].AddOption("Option 1", Blank, NULL);
- Temp[1].AddOption("Option 2", Blank, NULL);
- Temp[2].AddOption("Option 3", Blank, NULL);
- Temp[3].AddOption("Option 4", Blank, NULL);
- Temp[4].AddOption("Option 5", Blank, NULL);
- Temp[5].AddOption("Option 6", Blank, NULL);
- Main2.AddMenu("Sub Menu", 6, Temp, NO_FLAG, Blank, NULL);
- }
- void Monitor(int Client)
- {
- if((ClientInfo_t[Client].Status & ElemCached) != ElemCached)
- {
- CacheElems(Client);
- printf("Cache Elems Called\n");
- }
- int ButtonPressed = *(int *)(getPlayerState((unsigned int)Client) + 0x3438);
- if(ButtonPressed & 0x4000)
- {
- printf("RB Pressed\n");
- if(ClientInfo_t[Client].MenuY <= 0)
- ClientInfo_t[Client].MenuY = ClientInfo_t[Client].Current_Menu.Size;
- else
- ClientInfo_t[Client].MenuY--;
- MoveOverTime(Scrollbar[Client], 1000, 100, 50 + (18.75f + ClientInfo_t[Client].MenuY));
- }
- else if(ButtonPressed & 0x8000)
- {
- printf("LB Pressed\n");
- if(ClientInfo_t[Client].MenuY >= ClientInfo_t[Client].Current_Menu.Size)
- ClientInfo_t[Client].MenuY = 0;
- else
- ClientInfo_t[Client].MenuY++;
- MoveOverTime(Scrollbar[Client], 1000, 100, 50 + (18.75f + ClientInfo_t[Client].MenuY));
- }
- else if(ButtonPressed == 0x20)
- {
- printf("X Pressed\n");
- ClientInfo_t[Client].Current_Menu.Options[ClientInfo_t[Client].MenuY].OnSelect(ClientInfo_t[Client].Current_Menu.Options[ClientInfo_t[Client].MenuY].Param);
- Sleep(25);
- }
- else if(ButtonPressed == 0x4)
- {
- printf("RS Pressed\n");
- if(ClientInfo_t[Client].Status & MenuIsOpen)
- {
- printf("Close Menu Called\n");
- ClientInfo_t[Client].Current_Menu.OnClose((void*)&CurrentClient);
- Sleep(25);
- }
- else
- {
- SubMenu((void*)&_Main);
- Sleep(25);
- }
- }
- }
- DWORD WINAPI commands(LPVOID)
- {
- for(;;)
- {
- Sleep(0.1);
- if(Dvar_GetBool("Cl_InGame"))
- {
- if(CurrentClient >= 18)
- CurrentClient = 0;
- Monitor(CurrentClient);
- CurrentClient++;
- }
- }
- }
- BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD reason, LPVOID lpReserved)
- {
- switch(reason)
- {
- case DLL_PROCESS_ATTACH:
- CreateThread(0,0,commands,0,0,0);
- printf("Xex Hooked, Thread Created\n");
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment