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

Spectate CT Team Only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpaWn2KiLl
Member
Join Date: Aug 2012
Old 07-08-2014 , 13:39   Spectate CT Team Only
Reply With Quote #1

Hello, I'm searching for a plugin that only allows to spectate the CT team...

Dead CT: Spectate CT players in 1st person view mode only
Dead T: Spectate CT players in 1st person view mode only
Spectatores: Spectate CT players in 1st person view mode only

I searched a lot but i din't find the solution...

Thanks
SpaWn2KiLl is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 07-08-2014 , 18:12   Re: Spectate CT Team Only
Reply With Quote #2

I have been working on this for some time now. Great timing.

Use cvar spec_force_team X where X is the team ( 1 - T, 2 - CT )

Code:
#include <amxmodx> #include <orpheu> #include <fakemeta> #include <engine> #define PLUGIN "Force Spectate" #define VERSION "1.1" #define AUTHOR "SpeeDeeR" #define get_team(%0)    ( get_pdata_int( %0, m_iTeam ) ) #define MAXPLAYERS  32 const m_iTeam = 114; new pcvar_force_team; new OrpheuFunction: Observer_IsValidTarget; public plugin_init() {     register_plugin( PLUGIN, VERSION, AUTHOR );         Observer_IsValidTarget = OrpheuGetFunction( "Observer_IsValidTarget", "CBasePlayer" );         OrpheuRegisterHook( Observer_IsValidTarget, "Observer_IsValidTarget_Pre", OrpheuHookPre  );         pcvar_force_team = register_cvar("spec_force_team", "2"); } public  Observer_IsValidTarget_Pre( const this, const iTarget, const bool:bOnlyTeam ) {     if( is_user_alive( iTarget ) )     {         static ppcvar; ppcvar = get_pcvar_num( pcvar_force_team  );                 if( get_team( iTarget ) != ppcvar )         {             static id; id = iTarget;             while ( ( id = find_ent_by_class( id, "player" ) ) != iTarget )             {                 if(get_team( id ) != ppcvar )                     continue;                                 OrpheuSetParam( 2, id );                                 break;             }         }     } }
Attached Files
File Type: zip force_spectate.zip (4.1 KB, 136 views)

Last edited by SpeeDeeR; 07-08-2014 at 19:01. Reason: formating
SpeeDeeR is offline
SpaWn2KiLl
Member
Join Date: Aug 2012
Old 07-08-2014 , 18:13   Re: Spectate CT Team Only
Reply With Quote #3

I'll test it later, thank you

EDIT: It's working! Thanks very much!!


You can lock this thread
__________________

Last edited by SpaWn2KiLl; 07-08-2014 at 21:36.
SpaWn2KiLl is offline
YoUrEnD
Member
Join Date: Nov 2015
Location: Germany
Old 08-29-2020 , 08:48   Re: Spectate CT Team Only
Reply With Quote #4

Can please someone port this to Sourcemod and add the ability for admins to spec everything?
__________________
Counter-Strike Source Server
https://high-devil-force.de
YoUrEnD is offline
WaLkMaN
Senior Member
Join Date: Oct 2010
Location: Varna, Bulgaria
Old 07-04-2023 , 06:14   Re: Spectate CT Team Only
Reply With Quote #5

I've rewritten the logic with reapi.

Code:
#include <amxmodx> #include <reapi> #define PLUGIN "Force Spectate" #define VERSION "1.1" #define AUTHOR "SpeeDeeR" new pcvar_force_team; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);         RegisterHookChain(RG_CBasePlayer_Observer_IsValidTarget, "Observer_IsValidTarget_Pre", .post = false);         pcvar_force_team = register_cvar("spec_force_team", "2"); } public Observer_IsValidTarget_Pre(const this, const iTarget, const bool:bOnlyTeam) {     if (is_user_alive(iTarget))     {         static ppcvar; ppcvar = get_pcvar_num(pcvar_force_team);                 if (get_member(iTarget, m_iTeam) != ppcvar)         {             static id; id = iTarget;             while ((id = rg_find_ent_by_class(id, "player")) != iTarget)             {                 if (!is_user_alive(id) || get_member(id, m_iTeam) != ppcvar)                     continue;                                 SetHookChainArg(2, ATYPE_INTEGER, id);                                 break;             }         }     } }

Another implementation: https://forums.alliedmods.net/showpo...95&postcount=8
__________________

Last edited by WaLkMaN; 07-04-2023 at 06:23.
WaLkMaN 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 00:32.


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