AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spawn Player like in opposite team (https://forums.alliedmods.net/showthread.php?t=270583)

Phant 08-24-2015 10:00

Spawn Player like in opposite team
 
Hello. I looking for best algorythm for Spawn Player like in opposite team, ie:
Player playing for T, in next round he Spawns on CT base with CT player-model. For CTs he still enemy (T).
How to do this?

Arkshine 08-24-2015 10:31

Re: Spawn Player like in opposite team
 
The tricky and easy way would be likely like hooking Spawn as pre, setting m_iTeam to CT, call ClientUserInfoChanged to update model, then in Spawn as post, set back team to T.

To lower possible issue of m_iTeam binge used by others plugin at this point, you can hook instead Ham_StartSneaking, which is called in Spawn, but right before the spawnpoint stuff. (You could also hook Spawn, and hooking StartSneaking insside, but it's unlikely a plugin would call this function, it does nothing).

HamletEagle 08-24-2015 11:30

Re: Spawn Player like in opposite team
 
Quote:

call ClientUserInfoChanged to update model
Also, check if user is alive before doing something.

Phant 08-24-2015 11:45

Re: Spawn Player like in opposite team
 
Thanks for replies. Current code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>

const m_iTeam 114;

enum _:teamIndexes
{
    
TEAM_UNASSIGNED 0,
    
TEAM_TERRORIST 1,
    
TEAM_CT 2,
    
TEAM_SPECTATOR 3
};

new 
g_div_player_id 2

public plugin_init()
{
    
register_plugin("""""" )
    
RegisterHam(Ham_Spawn,  "player""Ham_Spawn_player_Pre",  0)
    
RegisterHam(Ham_Spawn,  "player""Ham_Spawn_player_Post",  1)
    
    
register_clcmd("say /d""clcmdD"0)
}

public 
change_team(iPlrId)
{
    switch(
get_pdata_int(iPlrIdm_iTeam))
    {
        case 
TEAM_TERRORIST:
        {
            
set_pdata_int(iPlrIdm_iTeamTEAM_CT)
        }
        case 
TEAM_CT:
        {
            
set_pdata_int(iPlrIdm_iTeamTEAM_TERRORIST)
        }
    }
}

public 
clcmdD(id)
{
    
g_div_player_id id
}

public 
Ham_Spawn_player_Pre(iPlrId)
{
    if(
iPlrId == g_div_player_id)
    {
        
change_team(iPlrId)
    }
}

public 
Ham_Spawn_player_Post(iPlrId)
{
    if(
iPlrId == g_div_player_id)
    {
        
change_team(iPlrId)
        
g_div_player_id 0
    
}


Player "say /d" and wait for respawn. All okay, player respawns with enemies and like enemy, but in scoreboard, scores, chat, etc. we got inconsistency.
http://5.firepic.org/5/thumbs/2015-0...56kvy2xko4.jpg
Any way for change this team-info (in scoreboard, say, chat, etc.)?

Arkshine 08-24-2015 12:03

Re: Spawn Player like in opposite team
 
Then reset in Precache (player), it's called a bit after but before the TeamInfo message and such. Of course it's up to you to test and add relevant checks (Precache is likely to be called on player put in server).

siriusmd99 08-24-2015 13:38

Re: Spawn Player like in opposite team
 
See warcraft code of the spion item from shopmenu and just use that, its the same as you have requested.
P.s its easy , safe and fast.

Phant 08-25-2015 00:59

Re: Spawn Player like in opposite team
 
Quote:

Originally Posted by Arkshine (Post 2336521)
Then reset in Precache (player), it's called a bit after but before the TeamInfo message and such. Of course it's up to you to test and add relevant checks (Precache is likely to be called on player put in server).

Quote:

Originally Posted by Arkshine (Post 2336521)
Then reset in Precache (player)

How I can do this? I can't find anything about "player precache"... only resources precache (models, sprites, etc.).

Arkshine 08-25-2015 03:24

Re: Spawn Player like in opposite team
 
Ham_Precache with "player"

Phant 09-06-2015 08:21

Re: Spawn Player like in opposite team
 
Arkshine, I found very offensively defect:
When Player use cl_minmodels 1, then Diversant Player looks like enemy :(. There is some way to fix it?
Or I should totally change Diversant team to opposite and add some code like in CSDM FFA Mode ("Friend as Enemy")?


All times are GMT -4. The time now is 02:39.

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