Другое С/С++ Вопрос - Ответ

Gunborg Johansson

Потрачен
32
21
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
void SendChat(const std::string& text)
    {
        typedef int(__stdcall* SendCommand)(const char*);
        typedef int(__stdcall* SendText)(const char*);
        static SendCommand sendCommand = (SendCommand)((DWORD)GetModuleHandle("samp.dll") + 0x65C60);
        static SendText sendText = (SendText)((DWORD)GetModuleHandle("samp.dll") + 0x57F0);

        /*
        какой-нибудь способ конвертировать std::string -> const char*, чтобы оно не крашило через n повторений
        */

        if (text[0] == '/')
            sendCommand(cstr);
        else
           sendText(cstr);
    }
Почему то тут не передаёт человек только указатель на строку и у него работает (если что, из этой темы)
C++:
const uint32_t sampHandle = ...;

void AddRecail(const char *const recailString)
{
    using AddRecail_t = void(__thiscall *)(class CInput *, const char *const);
    auto addRecail{reinterpret_cast<AddRecail_t>(sampHandle + 0x68E60)};
   
    addRecail(*reinterpret_cast<class CInput **>(sampHandle + 0x26E8CC), recailString);
}
 
Последнее редактирование:

Gunborg Johansson

Потрачен
32
21
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
const uint32_t sampHandle = ...;

void AddRecail(const char *const recailString)
{
    using AddRecail_t = void(__thiscall *)(class CInput *, const char *const);
    auto addRecail{reinterpret_cast<AddRecail_t>(sampHandle + 0x68E60)};
  
    addRecail(*reinterpret_cast<class CInput **>(sampHandle + 0x26E8CC), recailString);
}
Just don't forget to check CInput for nullptr.
 

Gunborg Johansson

Потрачен
32
21
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

#Northn

Pears Project — уже запущен!
Всефорумный модератор
2,652
2,550

Vintik

Через тернии к звёздам
Проверенный
1,564
1,038

Gunborg Johansson

Потрачен
32
21
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
void AddRecail(const char* const recailString)
{
    using AddRecail_t = void(__thiscall*)(class CInput*, const char* const);
    auto addRecail{ reinterpret_cast<AddRecail_t>(dwSAMP + 0x68E60) };

    addRecail(*reinterpret_cast<class CInput**>(dwSAMP + 0x26E8CC), recailString);
}
Strange, on MinGW compiles. What line is the error on?
 

Gunborg Johansson

Потрачен
32
21
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
class CInput;

void AddRecail(const char *const recailString)
{
    using AddRecail_t = void(__thiscall*)(CInput *, const char *const);
    auto addRecail{reinterpret_cast<AddRecail_t>(dwSAMP + 0x68E60)};

    addRecail(*reinterpret_cast<CInput **>(dwSAMP + 0x26E8CC), recailString);
}
 
  • Нравится
Реакции: Vintik

dekname

Участник
44
2
Как можно рисовать на загрузочном экране SA-MP'a? (черный экран и где логотип nvdia, raknet и т.д)