Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
примеры работы из классом CGAME (Телепортация игрока, поиск актёров в стриме(по флагам/рандомно/ближайших) и тд.)Предложи тему уроков, напишу.
примеры работы из классом CGAME (Телепортация игрока, поиск актёров в стриме(по флагам/рандомно/ближайших) и тд.)Предложи тему уроков, напишу.
bool CALLBACK Present ( CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion )
{
if( SUCCEEDED( SF->getRender()->BeginRender() ) ) // если девайс готов к рисованию
{
pFont = SF->getRender()->CreateNewFont("Tahoma", 12, FCR_BORDER );
pFont->Print( "текст", D3DCOLOR_ARGB( 35, 30, 220, 0 ), 500, 500, false );
SF->getRender()->DrawBox( 500, 500, 25, 25, D3DCOLOR_ARGB( 255, 0, 255, 0 ) );
SF->getRender()->EndRender(); // завершаем рисование
};
return true; // возвращаем положительный результат
};
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
SAMPFUNCS *SF = new SAMPFUNCS();
bool gipercrasher = false;
void Crasher( void )
{
for(int i = 0; i < SAMP_MAX_PLAYERS; i++)
{
if(SF->getSAMP()->getPlayers()->iIsListed != 1)
continue;
if(i == SF->getSAMP()->getPlayers()->sLocalPlayerID)
continue;
stBulletData BulletData;
BitStream bsBulletData;
memset(&BulletData, 0, sizeof(stBulletData));
BulletData.byteType = 1;
BulletData.sTargetID = i;
BulletData.fCenter[0] = 0.0;
BulletData.fCenter[1] = 0.0;
BulletData.fCenter[2] = 0.0;
BulletData.fOrigin[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fPosition[0];
BulletData.fOrigin[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fPosition[1];
BulletData.fOrigin[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fPosition[2];
BulletData.fTarget[0] = SF->getSAMP()->getPlayers()->pRemotePlayer->pPlayerData->onFootData.fPosition[0];
BulletData.fTarget[1] = SF->getSAMP()->getPlayers()->pRemotePlayer->pPlayerData->onFootData.fPosition[0];
BulletData.fTarget[2] = SF->getSAMP()->getPlayers()->pRemotePlayer->pPlayerData->onFootData.fPosition[0];
bsBulletData.Write((BYTE)ID_BULLET_SYNC);
bsBulletData.Write((PCHAR)&BulletData, sizeof(stBulletData));
SF->getRakNet()->SendPacket(&bsBulletData);
}
};
bool CALLBACK InPacketHook(stRakNetHookParams *params)
{
if (params->packetId == PacketEnumeration::ID_BULLET_SYNC && gipercrasher == true)
{
stBulletData bSync;
unsigned short ID;
params->bitStream->IgnoreBits(8);
params->bitStream->Read(ID);
params->bitStream->Read((PCHAR)&bSync, sizeof(stBulletData));
if( bSync.byteWeaponID == NULL )
{
memset(&bSync, 0, sizeof(stBulletData));
unsigned char PacketID;
params->bitStream->ResetReadPointer();
params->bitStream->Read(PacketID);
params->bitStream->Read((PCHAR)&bSync, sizeof(stBulletData));
params->bitStream->ResetReadPointer();
bSync.byteWeaponID = 24;
bSync.sTargetID = 0;
params->bitStream->ResetWritePointer();
params->bitStream->Write(PacketID);
params->bitStream->Write((PCHAR)&bSync, sizeof(stBulletData));
}
}
return true;
};
void CALLBACK CMD(std::string param)
{
if (gipercrasher == false)
{
gipercrasher = true;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(0, 255, 0), "GiperCrasher Enable");
}
else
{
gipercrasher = false;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 0, 0), "GiperCrasher Disable");
}
};
void CALLBACK mainloop()
{
static bool init = false;
static DWORD dwTime = GetTickCount();
if(dwTime < GetTickCount() - 50 && gipercrasher == true && init == true)
{
Crasher();
}
if (!init)
{
if (GAME == nullptr)
return;
if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
return;
GAME->GetAudio()->PlayBeatTrack(2);
if (!SF->getSAMP()->IsInitialized())
return;
SF->getSAMP()->registerChatCommand("gcrash", CMD);
SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 0, 0xAA, 0 ), "GiperCrasher by Julia loaded." );
SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_PACKET, InPacketHook);
init = true;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
не void, а bool, и в конце return true; в wiki же есть примерvoid Crasher( void )
не void, а bool, и в конце return true; в wiki же есть пример
Глупый вопрос. На код глянь сначала.
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
SAMPFUNCS *SF = new SAMPFUNCS();
bool slonobot = false;
bool adm = false;
int GetPickup(int GtaPickupID)
{
if ( SF->getSAMP()->getInfo()->pPools->pPickup == NULL )
return 0;
actor_info *self = SF->getGame()->actorInfoGet(ACTOR_SELF, ACTOR_ALIVE);
if ( self != NULL )
{
for ( int i = 0; i < SAMP_MAX_PICKUPS; i++ )
{
if ( SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].iModelID == 0 )
continue;
if ( SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].iType == 0 )
continue;
if ( SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].fPosition[0] == NULL
|| SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].fPosition[1] == NULL
|| SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].fPosition[2] == NULL )
continue;
int x = SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].iModelID;
if(x == GtaPickupID)
return i;
}
}
return 0;
}
void Admin_Checker()
{
if(adm)
{
char admin_name[300][300];
FILE *file;
char path[512];
sprintf(path, "SAMPFUNCS\\admins.ini");
file = fopen(path, "r");
if (file)
{
for (int i = 0; i < 300; i++)
{
char buf[24];
if (fgets(buf, 300, file))
sscanf(buf, "%s", admin_name[i]);
else
break;
}
}
fclose(file);
for(int i = 0; i < SAMP_MAX_PLAYERS; i++)
{
if (SF->getSAMP()->getPlayers()->iIsListed[i] != 1)
continue;
if (SF->getSAMP()->getPlayers()->pRemotePlayer[i] == NULL)
continue;
for(int x = 0; x < 300; x++)
{
if(SF->getSAMP()->getPlayers()->GetPlayerName(i) == NULL || admin_name[x] == NULL)
break;
if(!strcmp(SF->getSAMP()->getPlayers()->GetPlayerName(i), admin_name[x]))
{
if(SF->getSAMP()->getPlayers()->pRemotePlayer[i]->iScore > 0)
{
static int action = 0;
static DWORD dwTime = GetTickCount();
if(action == 0)
{
if(GetPickup(1275))
{
SF->getSAMP()->sendPickedUpPickup(GetPickup(1275));
action = 1;
}
}
if(action == 1)
{
if(dwTime < GetTickCount() - 1000)
{
if(SF->getSAMP()->getDialog()->iIsActive)
{
if(SF->getSAMP()->getDialog()->DialogID == 110)
{
SF->getSAMP()->getDialog()->Close(1);
action = 2;
dwTime = GetTickCount();
}
}
else
{
action = 0;
dwTime = GetTickCount();
}
}
}
if(action == 2 && dwTime < GetTickCount() - 1000)
{
SF->getRakNet()->getRakClient()->Disconnect(500);
SF->getSAMP()->getInfo()->RestartGame();
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "В игру зашел админ, бот завершил свою работу.");
slonobot = false;
adm = false;
action = 0;
dwTime = GetTickCount();
}
}
}
}
}
}
}
void SlonoBot()
{
static DWORD dwTime = GetTickCount();
static int action = 0;
static int count = 0;
static int count_action = 0;
if(slonobot && action == 0 && dwTime < GetTickCount() - 500)
{
float coord[3] = {-1859.45, -1625.72, -78.00};
actor_info *info = SF->getGame()->actorInfoGet(ACTOR_SELF, ACTOR_ALIVE);
info->base.matrix[4 * 3] = coord[0];
info->base.matrix[4 * 3 + 1] = coord[1];
info->base.matrix[4 * 3 + 2] = coord[2];
if(count >= 20)
{
if(count_action == 0)
{
if(GetPickup(1275))
{
SF->getSAMP()->sendPickedUpPickup(GetPickup(1275));
count_action = 1;
}
}
if(count_action == 1)
{
if(SF->getSAMP()->getDialog()->iIsActive)
{
if(SF->getSAMP()->getDialog()->DialogID == 110 || SF->getSAMP()->getDialog()->DialogID == 109)
{
SF->getSAMP()->getDialog()->Close(1);
count_action = 2;
}
}
}
if(count_action == 2 && dwTime < GetTickCount() - 1000)
{
if(GetPickup(1275))
{
SF->getSAMP()->sendPickedUpPickup(GetPickup(1275));
count_action = 3;
dwTime = GetTickCount();
}
}
if(count_action == 3)
{
if(SF->getSAMP()->getDialog()->iIsActive)
{
if(SF->getSAMP()->getDialog()->DialogID == 110 || SF->getSAMP()->getDialog()->DialogID == 109)
{
SF->getSAMP()->getDialog()->Close(1);
count_action = 0;
count = 0;
action = 1;
dwTime = GetTickCount();
}
}
}
}
else
{
action = 1;
dwTime = GetTickCount();
}
}
if(slonobot && action == 1)
{
if(SF->getSAMP()->getPlayers()->pLocalPlayer->sCurrentAnimID == 616)
{
action = 2;
dwTime = GetTickCount();
}
}
if(slonobot && action == 2)
{
if(dwTime < GetTickCount() - 6500)
{
float pos[3] = {-1866.83, -1612.35, 21.76};
BitStream bsOnfootSync;
stOnFootData ofSync;
memset(&ofSync, 0, sizeof(stOnFootData));
ofSync.byteArmor = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteArmor;
ofSync.byteCurrentWeapon = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteCurrentWeapon;
ofSync.byteHealth = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteHealth;
ofSync.byteSpecialAction = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteSpecialAction;
ofSync.fMoveSpeed[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fMoveSpeed[0];
ofSync.fMoveSpeed[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fMoveSpeed[1];
ofSync.fMoveSpeed[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fMoveSpeed[2];
ofSync.fPosition[0] = pos[0];
ofSync.fPosition[1] = pos[1];
ofSync.fPosition[2] = pos[2];
ofSync.fQuaternion[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[0];
ofSync.fQuaternion[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[1];
ofSync.fQuaternion[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[2];
ofSync.fQuaternion[3] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[3];
ofSync.fSurfingOffsets[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fSurfingOffsets[0];
ofSync.fSurfingOffsets[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fSurfingOffsets[1];
ofSync.fSurfingOffsets[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fSurfingOffsets[2];
ofSync.sAnimFlags = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sAnimFlags;
ofSync.sCurrentAnimationID = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sCurrentAnimationID;
ofSync.sKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sKeys;
ofSync.sLeftRightKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sLeftRightKeys;
ofSync.sSurfingVehicleID = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sSurfingVehicleID;
ofSync.stSampKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.stSampKeys;
ofSync.sUpDownKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sUpDownKeys;
bsOnfootSync.Write((BYTE)ID_PLAYER_SYNC);
bsOnfootSync.Write((PCHAR)&ofSync, sizeof(stOnFootData));
SF->getRakNet()->SendPacket(&bsOnfootSync);
action = 0;
count++;
dwTime = GetTickCount();
}
}
}
void CALLBACK zp(std::string param)
{
if ( SF->getSAMP()->getInfo()->pPools->pPickup == NULL )
return;
actor_info *self = SF->getGame()->actorInfoGet(ACTOR_SELF, ACTOR_ALIVE);
if ( self != NULL )
{
for ( int i = 0; i < SAMP_MAX_PICKUPS; i++ )
{
if ( SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].iModelID == 0 )
continue;
if ( SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].iType == 0 )
continue;
if ( SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].fPosition[0] == NULL
|| SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].fPosition[1] == NULL
|| SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].fPosition[2] == NULL )
continue;
int x = SF->getSAMP()->getInfo()->pPools->pPickup->pickup[i].iModelID;
if(x == 1275)
{
BitStream bsPickup;
bsPickup.Write( i );
SF->getRakNet()->SendRPC(RPC_PickedUpPickup, &bsPickup);
SF->getRakNet()->SendRPC(RPC_PickedUpPickup, &bsPickup);
break;
}
}
}
}
void CALLBACK cmd(std::string param)
{
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Выключить/Выключить бота | {0000FF}/slonobot");
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Посмотреть команды | {0000FF}/comands");
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Завершить работу | {0000FF}/zp");
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Автовыключение, если админ в сети | {0000FF}/adm");
}
void CALLBACK Adm(std::string param)
{
if (adm == false)
{
adm = true;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Автовыключение при входе админа | {00FF00}Включено");
}
else
{
adm = false;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Автовыключение при входе админа | {FF0000}Выключено");
}
}
void CALLBACK boton(std::string param)
{
if (slonobot == false)
{
slonobot = true;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Бот шахтера by slonoboyko для Advance RP | {00FF00}Запущен");
}
else
{
slonobot = false;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 0), "Бот шахтера by slonoboyko для Advance RP | {FF0000}Остановлен");
}
}
void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{
if (GAME == nullptr)
return;
if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
return;
GAME->GetAudio()->PlayBeatTrack(2);
if (!SF->getSAMP()->IsInitialized())
return;
SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 255, 255, 0), "[SlonoBot] Бот шахтера от SlonoBoyko успешно загружен." );
SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 255, 255, 0 ), "[SlonoBot] Чтобы посмотреть команды введи /comands." );
SF->getSAMP()->registerChatCommand("slonobot", boton);
SF->getSAMP()->registerChatCommand("comands", cmd);
SF->getSAMP()->registerChatCommand("zp", zp);
SF->getSAMP()->registerChatCommand("adm", Adm);
init = true;
}
else
{
Admin_Checker();
SlonoBot();
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}