bool (*old_AddItem)(void *instance, monoString *item_id, int item_value);
bool AddItem((*old_AddItem)(void *instance, monoString *item_id, int item_value) {
if(instance!=nullptr) {
return true;
}
return old_AddItem(instance, item_id, item_value);
}
Thanks sir.C++:bool (*old_AddItem)(void *instance, monoString *item_id, int item_value); bool AddItem((*old_AddItem)(void *instance, monoString *item_id, int item_value) { if(instance!=nullptr) { return true; } return old_AddItem(instance, item_id, item_value); }
How to fix?C++:bool (*old_AddItem)(void *instance, monoString *item_id, int item_value); bool AddItem((*old_AddItem)(void *instance, monoString *item_id, int item_value) { if(instance!=nullptr) { return true; } return old_AddItem(instance, item_id, item_value); }
You need a monoString struct. Add a new file in your Includes folder called mono.h then paste this code inside...How to fix?
typedef struct _monoString
{
void *klass;
void *monitor;
int length;
char chars[1];
int getLength()
{
return length;
}
char *getChars()
{
return chars;
}
} monoString;
monoString *CreateString(const char *str)
{
monoString *(*CreateString)(void *instance, const char *str, int start, int length) = (monoString * (*)(void *, const char *, int, int)) getAbsoluteAddress(0xOFFSET); //offset here
int length = (int)strlen(str);
return CreateString(NULL, str, 0, length);
}
#include "Includes/Mono.h"
Where to download Mono.h, in LGL Mod Menu 3.2 there is no Mono.hYou need a monoString struct. Add a new file in your Includes folder called mono.h then paste this code inside...
C++:typedef struct _monoString { void *klass; void *monitor; int length; char chars[1]; int getLength() { return length; } char *getChars() { return chars; } } monoString; monoString *CreateString(const char *str) { monoString *(*CreateString)(void *instance, const char *str, int start, int length) = (monoString * (*)(void *, const char *, int, int)) getAbsoluteAddress(0xOFFSET); //offset here int length = (int)strlen(str); return CreateString(NULL, str, 0, length); }
Replace where it says 0xOFFSET with the correct offset from your dump...
private string CreateString(sbyte* value, int startIndex, int length) {}
Then add this line to main.cpp at top...
C++:#include "Includes/Mono.h"
bool (*old_AddItem)(void *instance, monoString *item_id, int item_value);
bool AddItem(void *instance, monoString *item_id, int item_value) {
if(instance!=nullptr) {
return true;
}
return old_AddItem(instance, item_id, item_value);
}
Go to Includes folder and create a new file called mono.hWhere to download Mono.h, in LGL Mod Menu 3.2 there is no Mono.h
Help, sorry to bother youGo to Includes folder and create a new file called mono.h
I want add item, item_id is "faith" and item_value is 50How to fix?
I made a typo in the monoString struct, replace it with this...Help, sorry to bother you
typedef struct _monoString
{
void *klass;
void *monitor;
int length;
char chars[1];
int getLength()
{
return length;
}
char *getChars()
{
return chars;
}
} monoString;
monoString *CreateString(const char *str)
{
monoString *(*CreateString)(void *instance, const char *str, int start, int length) = (monoString * (*)(void *, const char *, int, int)) getAbsoluteAddress("libil2cpp.so", 0xOFFSET); //offset here
int length = (int)strlen(str);
return CreateString(NULL, str, 0, length);
}
bool (*AddItem)(void *instance, monoString *item_id, int item_value);
void (*old_Update)(void *instance);
void Update(void *instance) {
if(instance!=nullptr) {
if(IncludeItem) {
AddItem(instance, (CreateString("faith")), 50);
IncludeItem=false;
}
}
old_Update(instance);
}
AddItem = (bool(*)(void*, monoString*, int)) getAbsoluteAddress(targetLibName, 0x61B174);
HOOK("0xOFFSET", Update, old_Update);
It's okay, I was wrong for not telling you what I wanted to do at the beginning. and thank you for helping.Also forget the bool hook that I made previously, I thought you just wanted to return true or false value.
You need to hook AddItem method like this...
C++:bool (*AddItem)(void *instance, monoString *item_id, int item_value);
Then find an update method (preferably from the same class as AddItem method, this can be Update, FixedUdate, or LateUpdate...
C++:void (*old_Update)(void *instance); void Update(void *instance) { if(instance!=nullptr) { if(IncludeItem) { AddItem(instance, (CreateString("faith")), 50); IncludeItem=false; } } old_Update(instance); }
Then under hackthread...
C++:AddItem = (bool(*)(void*, monoString*, int)) getAbsoluteAddress(targetLibName, 0x61B174); HOOK("0xOFFSET", Update, old_Update);
Make sure this line in your main.cpp...It's okay, I was wrong for not telling you what I wanted to do at the beginning. and thank you for helping.
then how to fix this, error in mono.h
#include "Includes/Mono.h"
#include "Includes/Utils.h"
What game?Good no errors, but it doesn't work. whether bool has called true
never mind, this is working, I entered the wrong offset earlier, thank you very much sirWhat game?
I also want to ask something, what if I use the update in another class. what code should be changed?What game?
What do you mean? Like an update from a different class than the class AddItem is in?I also want to ask something, what if I use the update in another class. what code should be changed?
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies