AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   game_team_master & game_team_set fix (CS 1.6) v0.3 [UPDATE 15/09/10] (https://forums.alliedmods.net/showthread.php?t=136500)

AlexALX 08-26-2010 23:42

game_team_master & game_team_set fix (CS 1.6) v0.3 [UPDATE 15/09/10]
 
3 Attachment(s)
game_team_master & game_team_set fix (CS 1.6) v0.3
Description:
This plugin fix game_team_master and game_team_set entities for CS 1.6.
Without this plugin, these entities are always activated, regardless of the team player.

Modules:
Сstrike
Fakemeta
Hamsandwich

How to use:
Quote:

For game_team_master specify team in team index:
-1 - anyone can activate
1 - only Terrorist can activate
2 - only CT can activate

For game_team_set is now possible to specify a team to change for game_team_master:
-1 - changes team to all
0 - changes team to activator team (default)
1 - changes team to Terrorist
2 - changes team to CT

For specify team you must disable SmartEdit in Valve Hammer Editor and add manualy this:
Key: team, Value: 2 (or other). (see image)

Attention! Do not fix error in Valve Hammer Editor (alt+p):
Entity (game_team_set) has unused keyvalues.

See test map, which shows an example of work. I hope everything is understood.
Copyright and thanks:
Quote:

Created by AlexALX (c) 2010 http://alex-php.net/
Created special for map deathrun_skills_edited
Big thank Arkshine (http://forums.alliedmods.net/member.php?u=7779)
For help in creating plugin.
Created special for map deathrun_skills_edited.

ChangeLog:
Quote:

[15.09.10 - v0.3]
* Completely changed the code (thanks Arkshine), the function now works as on HL SDK (except for the added new option "team" for the game_team_set entity).
[28.08.10 - v0.2]
* Updated test map.
* Now for specify team for game_team_set you need disable SmartEdit in Valve Hammer Editor and add manualy: Key: team, Value: 2 (or other).
* Now teamindex is work, do not need use Yaw.
* You want to change the field Yaw on teamindex (for game_team_master) or team (for game_team_set). Otherwise Entites stop working on the map.
[27.08.10 - v0.1]
* First release.

xPaw 08-27-2010 05:22

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Use Yaw or Roll field in Valve Hammer Editor for set team, not Team Index (do not work).
That's fail fix tbh

AlexALX 08-27-2010 09:06

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by xPaw (Post 1283083)
That's fail fix tbh

I do not understand what you said (I am bad speak English). If you are speak russian - please say to pm or here if this do not inappropriate...

DruGzOG 08-27-2010 09:53

Re: game_team_master&game_team_set Fix (CS 1.6)
 
This plugin fails out teh asshole.

Arkshine 08-27-2010 09:54

Re: game_team_master&game_team_set Fix (CS 1.6)
 
You say teamindex doesn't work, how did you tested ? Looking at the CS code, the keyvalue "teamindex" is well implemented and its offset should be 34 or 35.

AlexALX 08-27-2010 10:25

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1283265)
You say teamindex doesn't work, how did you tested ? Looking at the CS code, the keyvalue "teamindex" is well implemented and its offset should be 34 or 35.

I've had I will give that team index does not work without fix (activates all in not depending on the team), I just do not know offset, right now, try to do differently, but no game_team_set this value initially, but without smartedit can of course manually add. Ok I'll try. Thanks for the tip. Wait new version...

ps someone can give a list Entites where used as a team set game_team_master? (as game_player_hurt) They also like in CS does not work.

AlexALX 08-27-2010 10:40

Re: game_team_master&game_team_set Fix (CS 1.6)
 
I testet get_pdata_cbase(ent, 34) - always return -1, regardless of what is really set in editor. 35 - error.

Quote:

Originally Posted by DruGzOG (Post 1283263)
This plugin fails out teh asshole.

Not understand...

Arkshine 08-27-2010 12:04

Re: game_team_master&game_team_set Fix (CS 1.6)
 
After some checks, the code is the same as HL1, so like you can see in HLSDK :

Code:
void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {     if ( !CanFireForActivator( pActivator ) )         return;     if ( useType == USE_SET )     {         if ( value < 0 )         {             m_teamIndex = -1;         }         else         {             m_teamIndex = g_pGameRules->GetTeamIndex( pActivator->TeamID() );         }         return;     }     if ( TeamMatch( pActivator ) )     {         SUB_UseTargets( pActivator, triggerType, value );         if ( RemoveOnFire() )             UTIL_Remove( this );     } }
Code:
const char *CGameTeamMaster::TeamID( void ) {     if ( m_teamIndex < 0 )      // Currently set to "no team"         return "";     return g_pGameRules->GetIndexedTeamName( m_teamIndex );     // UNDONE: Fill this in with the team from the "teamlist" }
Code:
BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) {     if ( m_teamIndex < 0 && AnyTeam() )         return TRUE;     if ( !pActivator )         return FALSE;     return UTIL_TeamsMatch( pActivator->TeamID(), TeamID() ); }

The problem is in UTIL_TeamsMatch(), because CBaseEntity::TeamID() and CGameTeamMaster::TeamID() return "" in CS. So yes, you can put any teamindex value, it will return always "", thus the check UTIL_TeamsMatch() always true.

As solution, you can hook CGameTeamMaster::TeamMatch() with Orpheu and redo the function and checking manually with the offset 35 (m_teamIndex) and cs_get_user_team for activor.

EDIT : I was writting the signature of the function when i've seen that in the windows decompiled code, the function is integrated as inline into CGameTeamMaster::Use(). Meaning, for windows It would need to redo the Use() function... :/ Will do it later, anyway.

AlexALX 08-27-2010 12:22

Re: game_team_master&game_team_set Fix (CS 1.6)
 
What should I do? oO

Arkshine 08-27-2010 12:32

Re: game_team_master&game_team_set Fix (CS 1.6)
 
You can try to do like I've said, after all it's your plugin. But the current solution is not appropriate because the issue is not the teamindex keyvalue, and you should anyway use a proper version which doesn't require a specific change to get working the entity.

AlexALX 08-27-2010 12:36

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1283380)
You can try to do like I've said, after all it's your plugin. But the current solution is not appropriate because the issue is not the teamindex keyvalue, and you should anyway use a proper version which doesn't require a specific change to get working the entity.

Ok... Try to think of something. Buy what about game_team_set? This entity do not have teamindex in standart keyvalues...

Arkshine 08-27-2010 12:48

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Actually, you could also simply rewrite Use() without using orpheu. (So hooking Ham_Use, and superceding at the end) You have the HLSDK to help you what does each function. Since it won't called often, it would be fine. If you don't know, tell me I will do.

About game_team_set, it should not a problem if you redo the function of game_team_master. Nothing to fix.

AlexALX 08-27-2010 12:59

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1283400)
Actually, you could also simply rewrite Use() without using orpheu. (So hooking Ham_Use, and superceding at the end) You have the HLSDK to help you what does each function. Since it won't called often, it would be fine. If you don't know, tell me I will do.

About game_team_set, it should not a problem if you redo the function of game_team_master. Nothing to fix.

I working now with Ham_Use... Thank you.

But about game_team_set - you dont undestand... With this plugin i can write team to change for game_team_master, as standart - team change only for activator team, do not possible to change to other team... Yes of course you can make a copy game_team_master and use trigger_changetarget but it's faster and easier...

Arkshine 08-27-2010 13:15

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Sorry not sure to understand you. I'm not used at all of such entities at all.

"team change only for activator team, do not possible to change to other team"

why ? like you said, it changes with the activator team, so it just a matter to trigger with the team you want, right ?

AlexALX 08-27-2010 13:30

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1283423)
Sorry not sure to understand you. I'm not used at all of such entities at all.

"team change only for activator team, do not possible to change to other team"

why ? like you said, it changes with the activator team, so it just a matter to trigger with the team you want, right ?

.... Bad english speak.... try to explain.

Standart game_team_set:
if CT use game_team_set - game_team_master now activate only for CTs.
if T use game_team_set - game_team_master now activate only for Ts.

I create teamindex value in game_team_set, and now:
if CT or T use game_team_set and teamindex=0 - game_team_master now activate all teams.
else if CT or T use game_team_set and teamindex=1 - game_team_master now activate only for Ts.
else if CT or T use game_team_set and teamindex=2 - game_team_master now activate only for CTs.
else if CT or T use game_team_set and teamindex=3 - game_team_master now activate only activator team (team of player who use game_team_set).

understand? or not oO

ps
I've already figured out how to use teamindex, so right now I will make a new version, but until about game_team_set must resolve the issue with non-standard field teamindex. And as I understood this to be done to fix all Entin that somehow intersect with game_team_master...? (game_team_set, game_player_hurt etc)

Arkshine 08-27-2010 13:38

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Yes, but still I don't think there is a need to fix something.

- if CT uses game_team_set - game_team_master now activates only for CTs.
- if T uses game_team_set - game_team_master now activates only for Ts.
- if SF_TEAMSET_CLEARTEAM is used to clear the team - game_team_master now activate for both.

So, what is the difference ?

For me, you need only to fix CGameTeamMaster::Use() only.

AlexALX 08-27-2010 13:58

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1283437)
Yes, but still I don't think there is a need to fix something.

- if CT uses game_team_set - game_team_master now activates only for CTs.
- if T uses game_team_set - game_team_master now activates only for Ts.
- if SF_TEAMSET_CLEARTEAM is used to clear the team - game_team_master now activate for both.

So, what is the difference ?

For me, you need only to fix CGameTeamMaster::Use() only.

SF_TEAMSET_CLEARTEAM? What this? And do not possible:

if CT uses game_team_set - game_team_master now activates only for Ts.
if T uses game_team_set - game_team_master now activates only for CTs.

:nono:

Arkshine 08-27-2010 14:05

Re: game_team_master&game_team_set Fix (CS 1.6)
 
spawnflags, look at the HLSDK :

Code:
// // CGameTeamSet / game_team_set -- Changes the team of the entity it targets to the activator's team // Flag: Fire once // Flag: Clear team             -- Sets the team to "NONE" instead of activator #define SF_TEAMSET_FIREONCE         0x0001 #define SF_TEAMSET_CLEARTEAM        0x0002 class CGameTeamSet : public CRulePointEntity { public:     void        Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );     inline BOOL RemoveOnFire( void ) { return (pev->spawnflags & SF_TEAMSET_FIREONCE) ? TRUE : FALSE; }     inline BOOL ShouldClearTeam( void ) { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) ? TRUE : FALSE; } private: }; LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ); void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {     if ( !CanFireForActivator( pActivator ) )         return;     if ( ShouldClearTeam() )     {         SUB_UseTargets( pActivator, USE_SET, -1 );     }     else     {         SUB_UseTargets( pActivator, USE_SET, 0 );     }     if ( RemoveOnFire() )     {         UTIL_Remove( this );     } }


Quote:

And do not possible

if CT uses game_team_set - game_team_master now activates only for Ts.
if T uses game_team_set - game_team_master now activates only for CTs.
why ? Looking at the definition http://www.thewavelength.net/oldcont..._team_set.html :

"When someone triggers this entity, that player's team will be assigned to the "game_team_master" that this entity targets"

AlexALX 08-27-2010 14:57

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Arkshine - no, i testet, only possibly to change in this format:

If CT activate game_team_set - game_team_master now activate only CTs.
If T activate game_team_set - game_team_master now activate only Ts.

And no other way. Etc:
If T activate game_team_set - game_team_master now activate only CTs.
If CT activate game_team_set - game_team_master now activate only Ts.
If CT or T activate game_team_set - game_team_master now activate all.
This is impossible in standart game_team_set. You must use trigger_changetarget and copy of game_team_master with the right team player. That's what I mean.

Arkshine 08-27-2010 17:31

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Ok, I understand better. But for game_team_set, I would use pev_team ( "team" ) instead, then storing its value in m_teamIndex.

AlexALX 08-27-2010 18:38

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Released v0.2... Test this...

Arkshine - very thanks you.

Arkshine 08-27-2010 18:47

Re: game_team_master&game_team_set Fix (CS 1.6)
 
A major problem with your plugin is it doesn't care about the others things. The purpose is to provide a fix, it means your plugin must have all the functionalities of entities. The code should be the same as the HLSDK with what you add.

AlexALX 08-27-2010 19:09

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1283682)
A major problem with your plugin is it doesn't care about the others things. The purpose is to provide a fix, it means your plugin must have all the functionalities of entities. The code should be the same as the HLSDK with what you add.

Code:

void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
    if ( !CanFireForActivator( pActivator ) )
        return;

    if ( useType == USE_SET )
    {
        if ( value < 0 )
        {
            m_teamIndex = -1;
        }
        else
        {
            m_teamIndex = g_pGameRules->GetTeamIndex( pActivator->TeamID() );
        }
        return;
    }

    if ( TeamMatch( pActivator ) )
    {
        SUB_UseTargets( pActivator, triggerType, value );
        if ( RemoveOnFire() )
            UTIL_Remove( this );
    }
}

How this? What is:
Code:

if ( !CanFireForActivator( pActivator ) )
        return;

And this
Code:

if ( TeamMatch( pActivator ) )
    {
        SUB_UseTargets( pActivator, triggerType, value );
        if ( RemoveOnFire() )
            UTIL_Remove( this );
    }

This is flag "remove on fire" but did not understand the previous condition (if ( TeamMatch( pActivator)))
Code:

if ( RemoveOnFire() )
            UTIL_Remove( this );

And what about game_team_set...

Arkshine 08-27-2010 19:51

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Something like that :

PHP Code:

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

    
enum USE_TYPE USE_OFF 0USE_ON 1USE_SET 2USE_TOGGLE };

    const 
m_iszMaster 34;
    const 
m_teamIndex 35;
    const 
triggerType 36;
    
    
#define RemoveOnFire(%0)     ( pev( %0, pev_spawnflags ) & SF_TEAMMASTER_FIREONCE )
    #define ShouldClearTeam(%0)  ( pev( %0, pev_spawnflags ) & SF_TEAMSET_CLEARTEAM   )
    #define AnyTeam(%0)          ( pev( %0, pev_spawnflags ) & SF_TEAMMASTER_ANYTEAM  )
    
    
public plugin_init()
    {
        
register_plugin"""""" );

        
RegisterHamHam_Use"game_team_master""CGameTeamMaster_Use" );
        
RegisterHamHam_Use"game_team_set"   "CGameTeamSet_Use"    );
    }

    public 
CGameTeamMaster_Use( const gameTeamMaster, const activator, const caller, const USE_TYPE:useType, const Float:value )
    {
        if ( !
CanFireForActivatorgameTeamMasteractivator ) )
        {
            return 
HAM_IGNORED;
        }

        if ( 
CGameTeamMaster_TeamMatchgameTeamMasteractivator ) )
        {
            
SUB_UseTargetsgameTeamMasteractivatorUSE_TYPE:get_pdata_inttriggerType), value );
            
            if ( 
RemoveOnFiregameTeamMaster ) )
            {
                
UTIL_RemovegameTeamMaster );
            }
        }
        
        return 
HAM_SUPERCEDE;
    }

    public 
CGameTeamSet_Use( const gameTeamSet, const activator, const caller, const USE_TYPE:useType, const Float:value )
    {
        if ( !
CanFireForActivatorgameTeamSetactivator ) )
        {
            return 
HAM_IGNORED;
        }
        
        new 
team pevgameTeamSetpev_team );
        
        new 
target32 ];
        
pevgameTeamSetpev_targettargetcharsmaxtarget ) );
            
        new 
master engfuncEngFunc_FindEntityByStringFM_NULLENT"targetname"target );
        new 
value team;
        
        if ( 
team || ShouldClearTeamgameTeamSet ) )
        {
            
value = -1;
        }
        else if ( !
team )
        {
            
value _:cs_get_user_teamactivator );
        }
        
        
set_pdata_intmasterm_teamIndexvalue );
        
        if ( 
RemoveOnFiregameTeamSet ) )
        {
            
UTIL_RemovegameTeamSet );
        }
        
        return 
HAM_SUPERCEDE;
    }

    
bool:CGameTeamMaster_TeamMatch( const entity, const activator )
    {
        new 
teamIndex get_pdata_intentitym_teamIndex);
        
        if ( 
teamIndex || AnyTeamentity ) )
        {
            return 
true;
        }

        if ( !
activator )
        {
            return 
false;
        }

        return 
cs_get_user_teamactivator ) == CsTeams:teamIndex;
    }
    
    
bool:CanFireForActivator( const entity, const activator )
    {
        new 
master get_pdata_intentitym_iszMaster);

        if ( 
master )
        {
            return 
UTIL_IsMasterTriggeredmasteractivator )
        }

        return 
true;
    }
    
    
bool:UTIL_IsMasterTriggered( const master, const activator )
    {
        if ( 
master )
        {
            new 
stringMaster32 ];
            
engfuncEngFunc_SzFromIndexstringMastercharsmaxstringMaster ) );

            new 
target engfuncEngFunc_FindEntityByStringFM_NULLENT"targetname"stringMaster );

            if ( 
target && ( ExecuteHamHam_ObjectCapstarget ) & FCAP_MASTER ) )
            {
                return 
CGameTeamMaster_TeamMatchtargetactivator );
            }
        }

        return 
true;
    }
    
    
SUB_UseTargets( const entity, const activatorUSE_TYPE:useTypeFloat:value )
    {
        new 
target32 ];
        
peventitypev_targettargetcharsmaxtarget ) );
    
        if ( 
target] )
        {
            
FireTargetstargetactivatorentityuseTypevalue );
        }
    }
    
    
FireTargets( const targetName[], const activator, const callerUSE_TYPE:useTypeFloat:value )
    {
        if ( !
targetName] )
        {
            return;
        }

        new 
target FM_NULLENT;
        
        while ( ( 
target engfuncEngFunc_FindEntityByStringtarget"targetname"targetName ) ) )
        {
            if ( 
target && ~pevtargetpev_flags ) & FL_KILLME )
            {
                
ExecuteHamHam_UsetargetactivatorcalleruseTypevalue );
            }
        }
    }
    
    
UTIL_Remove( const entity )
    {
        if ( 
entity )
        {   
            
set_peventitypev_flagspeventitypev_flags ) | FL_KILLME );
            
set_peventitypev_targetname);
        }
    } 

Not much tested, but it should work like your "how yo use". This version can keep the original behavior, master and spawnflags supported, etc.. So, the complete version. Also, since we replace the original Use() functions, we must supercede all the times.

With orpheu, we could call directly the functions, maybe I will do it another day.

AlexALX 08-27-2010 21:08

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Arkshine - very thanks. I tested it tomorrow and try to do with his idea about game_team_set. In orpheu you need intercept function

Quote:

int CGameRules::GetTeamIndex()
{
return -1;
}
This in cs 1.6... So you need to replace it for normal) (info from Developers)

Arkshine 08-28-2010 04:41

Re: game_team_master&game_team_set Fix (CS 1.6)
 
I know it returns -1, why are you talking about that, we don't need this function anyway.

AlexALX 09-15-2010 07:55

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Arkshine - i now tested you code and it do not work (always not activate). something wrong ... right now, try to understand.

Arkshine 09-15-2010 08:10

Re: game_team_master&game_team_set Fix (CS 1.6)
 
When i've said "Not much tested" ; I have still tested enough to post. Otherwise I would not have post a not-working plugin. So far I remember I've tested on both team, all etc.. with a game_player_equip entity and it was working perfectly for all cases.

AlexALX 09-15-2010 09:57

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Quote:

Originally Posted by Arkshine (Post 1299980)
When i've said "Not much tested" ; I have still tested enough to post. Otherwise I would not have post a not-working plugin. So far I remember I've tested on both team, all etc.. with a game_player_equip entity and it was working perfectly for all cases.

Are you sure? And I say that your code wrong. And the mistake here:

Code:

SUB_UseTargets( gameTeamMaster, activator, USE_TYPE:get_pdata_int( triggerType, 4 ), value );
Must be:
Code:

SUB_UseTargets( gameTeamMaster, activator, USE_TYPE:get_pdata_int( gameTeamMaster, triggerType, 4 ), value );
:twisted:

And so - thank you very much. Still, you are mistaken in this... :wink:

And

Code:

    if ( !CanFireForActivator( gameTeamSet, activator ) )
    {
        return HAM_IGNORED;
    }

May be must be:

Code:

    if ( !CanFireForActivator( gameTeamSet, activator ) )
    {
        return HAM_SUPERCEDE;
    }

??? Or not?..

Arkshine 09-15-2010 10:13

Re: game_team_master&game_team_set Fix (CS 1.6)
 
Yes I've tested it faslty like i've said, but you're talking about about a thing there is some time ago and I don't remember well. Maybe I've tested only game_team_set but I remember well i've spent many time on it and I've posted only when it was working fine. Maybe I've done some modifications when I've cleanup the code, because since I was using a game_player_equip entity I remember I could know if it was working or not if I get or not a gun. So, probably a typo when I wanted to release.

Anyway for the first you're right, obviously.

The second, you're wrong. We have changed nothing which need to be supercede, just a check.

AlexALX 09-15-2010 11:53

Re: game_team_master & game_team_set fix (CS 1.6) v0.3 [UPDATE 15/09/10]
 
Released new version (v0.3).

Arkshine 11-01-2010 10:27

Re: game_team_master & game_team_set fix (CS 1.6) v0.3 [UPDATE 15/09/10]
 
The plugin is well done.

If you would like any information regarding possible adjustments you could make or things you could do to make this better, please feel free to post here or PM me.

Approved.

joropito 02-26-2012 21:01

Re: game_team_master & game_team_set fix (CS 1.6) v0.3 [UPDATE 15/09/10]
 
Can anyone confirm that this plugin is correctly working?

I can't make it work and I've found at least 1 error. It's not passing the index of string.

Quote:

engfunc( EngFunc_SzFromIndex, stringMaster, charsmax( stringMaster ) );


All times are GMT -4. The time now is 06:40.

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