Raised This Month: $ Target: $400
 0% 

Detecting team change, tag mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 16:05   Re: Detecting team change, tag mismatch
Reply With Quote #1

Is it the same on Ham_Spawn?
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-14-2020 , 16:07   Re: Detecting team change, tag mismatch
Reply With Quote #2

This website is your friend - https://www.amxmodx.org/api/ham_const
Instead of asking, you can find the answer there.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 16:24   Re: Detecting team change, tag mismatch
Reply With Quote #3

Okay, now is this okay?
PHP Code:
public OnPlayerDeath(id)
{
    new 
iPlayers[32], iPnum
    get_players
(iPlayersiPnum)

    for(new 
iid2iPnumi++)
    {
        
id2 iPlayers[i]
        if (
get_user_flags(id2) & ADMIN_LEVEL_H)
        {

            
g_PreTeam[id2] = cs_get_user_team(id2);
        }
    }
}

public 
OnPlayerSpawn(id)
{
    new 
iPlayers[32], iPnum
    get_players
(iPlayersiPnum)

    for(new 
iid3iPnumi++)
    {
        
id3 iPlayers[i]
        if(
g_HasModel[id] == true)
        {
            if (
get_user_flags(id3) & ADMIN_LEVEL_H)
            {
                
g_PostTeam[id3] = cs_get_user_team(id3);
            
                if(
g_PostTeam[id3] == g_PreTeam[id3])
                {
                    
CC_SendMessage(id3"&x01>> &x04Your model was set, no need for change!");
                }
                else if(
g_PostTeam[id3] != g_PreTeam[id3])
                {
                    
cs_reset_user_model(id3)
                    
g_HasModel[id] = false;
                    
CC_SendMessage(id3"&x01>> &x04Model reset applied, change your model!");
                }
            }
        }
    }

__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 16:28   Re: Detecting team change, tag mismatch
Reply With Quote #4

Using the link OciXCrom posted, you would find how Ham_Killed works.

Code:
Description:     Normally called whenever an entity dies. For Team Fortress Classic mod, see Ham_TFC_Killed. Forward params:  function(this, idattacker, shouldgib) Return type:     None. Execute params:  ExecuteHam(Ham_Killed, this, idattacker, shouldgib);

Using this, you would know the function would be defined this way:
PHP Code:
public Ham_Killed/*'this' is entity the hook was created for, in this case 'player', so use*/ iVictim idattackershouldgib)
{


__________________

Last edited by Bugsy; 06-14-2020 at 16:30.
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 16:35   Re: Detecting team change, tag mismatch
Reply With Quote #5

But if I use only one that I named id, will it work as iVictim? Do I really need all 3 defined? And does that mean that my code isn't good?
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 16:39   Re: Detecting team change, tag mismatch
Reply With Quote #6

Yes, you are correct. I always include all params even when not used, but that's just me.
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 16:41   Re: Detecting team change, tag mismatch
Reply With Quote #7

Sorry if I sound stupid. Please correct me if I did anything dumb in my code.
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 20:29   Re: Detecting team change, tag mismatch
Reply With Quote #8

Why do you need to check team at death and spawn?

if you want to hook team change,use the TeamInfo event
PHP Code:

#include <amxmodx>

new const Version[] = "1.0";

new 
g_iCurTeamMAX_PLAYERS ] = { 'U' , ... };

public 
plugin_init() 
{
    
register_plugin"Team Change" Version "bugsy" );
    
    
register_event"TeamInfo" "TeamInfo" "a" );
}

public 
TeamInfo( )
{
    new 
id szTeam];
    
    
id read_data);
    
read_dataszTeam charsmaxszTeam ) );
    
    
//Team change occurred. Including first team selection from unassigned to T,CT,Spec
    
if ( g_iCurTeamid ] != szTeam] )
    {
        
g_iCurTeamid ] = szTeam];
        
        switch( 
szTeam] )
        {
            case 
'T'
            {
                
//terrorist
            
}
            case 
'C'
            {
                
//CT
            
}
            case 
'S':
            {
                
//spectator
            
}
        }
        
        
    }

__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 20:34   Re: Detecting team change, tag mismatch
Reply With Quote #9

Tried it, didn't work for some reason, I searched it on forum, and I found that it didn't work for a lot of people. Anyways, thanks
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
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 17:12.


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