I trying to change team on CS:GO
Init SwitchTeam signature
PHP Code:
addr = NULL;
if (!g_pZombieConfig->GetMemSig("SwitchTeam", &addr) || !addr) {
g_SMAPI->ConPrintf("Failed to get memory signature for \"%s\"\n", "SwitchTeam");
return;
}
pass[0].flags = PASSFLAG_BYVAL;
pass[0].size = sizeof(int);
pass[0].type = PassType_Basic);
g_pSwitchTeam = bintools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 1);
g_CallWrappers.push_back(g_pSwitchTeam);
SwitchTeam func
PHP Code:
unsigned char vstk[sizeof(CBaseEntity *) + sizeof(int)];
unsigned char *vptr = vstk;
*(CBaseEntity **)vptr = entity;
vptr += sizeof(CBaseEntity *);
*(int *) vptr = pEntity;
g_pSwitchTeam->Execute(vstk, NULL);
I put this function, in the player_spawn, i have alive validations etc, because i check other func like SetEntityModel etc, but they work
Change team didn't work, i just can't start play and always in spectators
I want to make change team suitable for WIN and linux is well
I also tried that, but didn't work
PHP Code:
static void *addr = NULL;
if(!addr)
{
GET_MEMSIG("SwitchTeam");
}
void *gamerules = g_pSDKTools->GetGameRules();
if (gamerules == NULL)
{
return pContext->ThrowNativeError("GameRules not available. SwitchTeam native disabled.");
}
__asm
{
push team
mov ecx, pEntity
mov ebx, gamerules
call addr
}
player spawn event
PHP Code:
// Validate client
CBaseClient *CPlayer = GetPlayer(playerhelpers->GetClientOfUserId(event->GetInt("userid")));
if (!CPlayer || !CPlayer->pEntity)
{
return;
}
// If player is dead, then stop
if(!IsPlayerAlive(CPlayer))
{
return;
}
// Force to swith team
UTIL_SetTeam(CPlayer->pEntity, ZM_TEAM_T);
On connect
PHP Code:
void ClientListener::OnClientPutInServer(int clientIndex)
{
// Validate client
CBaseClient *CPlayer = GetPlayer(clientIndex);
if (!CPlayer)
{
return;
}
// Validate entity
CBaseEntity *pEntity = GetBaseEntity(clientIndex);
if (!pEntity)
{
return;
}
// Update main player variables
CPlayer->pEdict = gamehelpers->EdictOfIndex(clientIndex);
CPlayer->pEntity = pEntity;
CPlayer->pInfo = playerinfomngr->GetPlayerInfo(CPlayer->pEdict);
CPlayer->pBot = botmanager->GetBotController(CPlayer->pEdict);
CPlayer->userid = engine->GetPlayerUserId(CPlayer->pEdict);
}
__________________