Raised This Month: $12 Target: $400
 3% 

Spawn Player like in opposite team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 08-24-2015 , 10:00   Spawn Player like in opposite team
Reply With Quote #1

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?
Phant is offline
Send a message via ICQ to Phant
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2015 , 10:31   Re: Spawn Player like in opposite team
Reply With Quote #2

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).
__________________
Arkshine is offline
Old 08-24-2015, 11:26
Phant
This message has been deleted by Phant. Reason: Mistake
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-24-2015 , 11:30   Re: Spawn Player like in opposite team
Reply With Quote #3

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

Last edited by HamletEagle; 08-24-2015 at 12:01.
HamletEagle is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 08-24-2015 , 11:45   Re: Spawn Player like in opposite team
Reply With Quote #4

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.

Any way for change this team-info (in scoreboard, say, chat, etc.)?
Phant is offline
Send a message via ICQ to Phant
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2015 , 12:03   Re: Spawn Player like in opposite team
Reply With Quote #5

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).
__________________

Last edited by Arkshine; 08-24-2015 at 12:08.
Arkshine is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-24-2015 , 13:38   Re: Spawn Player like in opposite team
Reply With Quote #6

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.

Last edited by siriusmd99; 08-24-2015 at 13:39.
siriusmd99 is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 08-25-2015 , 00:59   Re: Spawn Player like in opposite team
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
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 View Post
Then reset in Precache (player)
How I can do this? I can't find anything about "player precache"... only resources precache (models, sprites, etc.).
Phant is offline
Send a message via ICQ to Phant
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2015 , 03:24   Re: Spawn Player like in opposite team
Reply With Quote #8

Ham_Precache with "player"
__________________

Last edited by Arkshine; 08-25-2015 at 03:24.
Arkshine is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 09-06-2015 , 08:21   Re: Spawn Player like in opposite team
Reply With Quote #9

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")?
Phant is offline
Send a message via ICQ to Phant
Reply


Thread Tools
Display Modes

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 07:58.


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