
16.12.2014, 13:14
|
|
Участник форума
Регистрация: 02.02.2014
Сообщений: 135
С нами:
6460176
Репутация:
0
|
|
Сообщение от AxweII
Даже если так сделать:
Код:
Код:
#include
#include
#include
#include "CSAMPFUNCS.h"
CSAMPFUNCS *SF = new CSAMPFUNCS();
void _cdecl cmd_show_info_player( char *param ){};
void CALLBACK mainloop(void)
{
static bool init = false;
if(!init)
{
if( !SF->getSAMP()->IsInitialized() )
return;
if(!SF->getSAMP()->IsInitialized()) return;
SF->getSAMP()->registerChatCommand("ubot", cmd_show_info_player);
init = true;
}
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved )
{
switch ( dwReasonForCall )
{
case DLL_PROCESS_ATTACH:
SF->initPlugin( mainloop, hModule );
}
return true;
Все равно краш. Проблема именно в регистрации команды, если в место нее засунуть вывод сообщения в чат то все пашет.
Код:
Код:
#include
#include
#include
#include "CSAMPFUNCS.h"
CSAMPFUNCS *SF = new CSAMPFUNCS();
void cmd_show_info_player( char *param )
{
int i = atoi( param );
char buf[128];
stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ i ];
sprintf_s( buf, "Nickname - %s, Ping - %d, Score - %d, isNPC - %d, AFKState - %d",
pPlayer->szPlayerName,
pPlayer->iPing,
pPlayer->iScore,
pPlayer->iIsNPC,
pPlayer->pPlayerData->iAFKState );
SF->getSAMP()->getChat()->AddChatMessage( -1, buf );
}
void CALLBACK mainloop(void)
{
static bool init = false;
if(!init)
{
if(!SF->getSAMP()->IsInitialized()) return;
SF->getSAMP()->registerChatCommand("ubot",(CMDPROC) cmd_show_info_player);
init = true;
}
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved )
{
switch ( dwReasonForCall )
{
case DLL_PROCESS_ATTACH:
SF->initPlugin( mainloop, hModule );
}
return true;
}
вот абсалютли рабочий код
вот что сделал SF->getSAMP()->registerChatCommand("ubot", (CMDPROC) cmd_show_info_player);
|
|
|