Raised This Month: $32 Target: $400
 8% 

Team change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-08-2016 , 19:11   Team change
Reply With Quote #1

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(addrCallConv_ThisCallNULLpass1); 
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(vstkNULL); 

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->pEntityZM_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);

__________________

Last edited by gubka; 12-08-2016 at 20:03.
gubka is offline
Send a message via ICQ to gubka
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-11-2016 , 22:23   Re: Team change
Reply With Quote #2

So may be smbd now , where i did mistake ? I also tried on linux, but it same, no working may be my signature is wrong?
Quote:
"SwitchTeam"
{
"library" "server"
"windows" "\x55\x8B\xEC\x83\xEC\x10\x53\x56\x8B\x75\x08 \x57\x8B\xF9\x85\xF6\x0F\x88\x2A\x2A\x2A\x2A\ x3B\x35"
"linux" "\x55\x89\xE5\x83\xEC\x68\x89\x75\xF8\x8B\x75 \x0C\x89\x5D\xF4\x8B\x5D\x08\x89\x7D\xFC\x89\ x34\x24\xE8\x2A\x2A\x2A\x2A\x85\xC0"
}
I just don't now how to solve problem, if i will fix it , my extension mod will be ready, Help pls
__________________

Last edited by gubka; 12-11-2016 at 22:28.
gubka is offline
Send a message via ICQ to gubka
psychonic

BAFFLED
Join Date: May 2008
Old 12-11-2016 , 23:05   Re: Team change
Reply With Quote #3

Extensions exist to extend plugin functionality. Plugins already have the CS_SwitchTeam native available, which works without issue.
psychonic is offline
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-12-2016 , 09:48   Re: Team change
Reply With Quote #4

Quote:
Originally Posted by psychonic View Post
Extensions exist to extend plugin functionality. Plugins already have the CS_SwitchTeam native available, which works without issue.
Interesting for me that, i used same code from cstrike extension and i have that problem ((( i don't know why i have it
Please help, i need to know my mistake, because i put set team function on player_spawn and i can't spawn actuaaly and i dont have any crash and errors
__________________

Last edited by gubka; 12-12-2016 at 10:41.
gubka is offline
Send a message via ICQ to gubka
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-14-2016 , 12:28   Re: Team change
Reply With Quote #5

Solved , in cs go team change work in the player_spawned hook but not in the player_spawn
Thanks for great help
__________________
gubka is offline
Send a message via ICQ to gubka
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode