Hey im a noobie coder of gta v in my menu of gta v online i have got this code to load custom .ytd and show the images on it:
bool FileExists(const std::string& fileName)
{
struct stat buffer;
return (stat(fileName.c_str(), &buffer) == 0);
}
const std::string GetModulePath(HMODULE module)
{
std::string path;
char buffer[MAX_PATH];
GetModuleFileNameA(module, buffer, MAX_PATH);
PathRemoveFileSpecA(buffer);
path = buffer;
return path;
}
typedef bool(__fastcall* tFileRegister)(int*, const char*, bool, const char*, bool);
bool FileRegister(int* textureID, std::string texturePath, bool enable, std::string textureName, bool _false)
{
static tFileRegister oFileRegister = (tFileRegister)(tFileRegister)(Memory:
attern("48 89 5C 24 ? 48 89 6C 24 ? 48 89 7C 24 ? 41 54 41 56 41 57 48 83 EC 50 48 8B EA 4C 8B FA 48 8B D9 4D 85 C9").count(1).get(0).get<void>(0));
return oFileRegister;
}
void loadimages(HMODULE hmodule)
{
//ScriptMain
const std::string name = "images_misc.ytd";
std::string fullPath = GetModulePath(hmodule) + name;
if (FileExists(fullPath))
{
int TextureID = 0;
Log::Msg("Creating Textures");
if(FileRegister(&TextureID, fullPath.c_str(), true, name.c_str(), false))
{
Log::Msg("Registered Texture %s with ID : %i", fullPath.c_str(), TextureID);
}
else
{
Log::Error("Failed to register %s", fullPath.c_str());
Hooking::Cleanup();
}
}
else
{
Log::Error("File Not Found ");
}
}
void Hooking::Start(HMODULE hmoduleDLL)
{
loadimages(hmoduleDLL);
}
For some reason the menu load correctly but when i open in sp my game crashed and i dont know hot to fix it pls help me i dont finding a copy paste solution im finding an explanation