Raised This Month: $ Target: $400
 0% 

Disable spectating for certain players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-08-2018 , 21:15   Re: Disable spectating for certain players
Reply With Quote #1

It worked based on what requirements? He wants it so players with the admin flag (VIP [ADMIN_KICK]?) cannot be spectated by players who do not have the flag (ADMIN_KICK).

"For example, I want for VIP's to have an ability that they can not be spectated by other players without admin kick flag."

I made the suggestion to switch the spectated to someone else instead of showing a black screen and he asked for the code. Even if he did not request it, making a player see a black screen is a bad experience, most will probably end up leaving. Better to set spectate to another player on the server so he is not bored, like my code does.
__________________
Bugsy is offline
fvRate
Junior Member
Join Date: May 2018
Old 05-08-2018 , 21:20   Re: Disable spectating for certain players
Reply With Quote #2

"Can it be done with solid black ScreenFade?" Well I just did that. I've already said I'm just following his idea, and it's not that bad.

And ofc your solution is better.

Edit: alright I didn't see the part of the flag, I will update the plugin.

Last edited by fvRate; 05-08-2018 at 21:25.
fvRate is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-08-2018 , 22:12   Re: Disable spectating for certain players
Reply With Quote #3

Here's another version using that event which I didn't realize existed:
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

new const Version[] = "0.1";

const 
No_Spectate_Flag ADMIN_KICK;

new 
g_MsgFade;

public 
plugin_init() 
{
    
register_plugin"No Spec Player" Version "bugsy" );
    
    
register_event"SpecHealth2" "Event_SpecHealth2" "bd" );
    
    
g_MsgFade get_user_msgid"ScreenFade" ); 
}

public 
Event_SpecHealth2id )
{
    new 
iPlayers32 ] , iNum iPlayer szName32 ] , iSpectated;
    new 
iCanBeSpectated32 ] , iCanBeSpectatedCount taskData];
    
    
iSpectated read_data);
    
    if ( ( 
get_user_flagsiSpectated ) & No_Spectate_Flag ) && !( get_user_flagsid ) & No_Spectate_Flag ) )
    {    
        
get_playersiPlayers iNum "a" );
        
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
            if ( !( 
get_user_flagsiPlayer ) & No_Spectate_Flag ) )
            {
                
iCanBeSpectatediCanBeSpectatedCount++ ] = iPlayer;
            }
        }    
    
        if ( 
iCanBeSpectatedCount )
        {    
            
get_user_nameiSpectated szName charsmaxszName ) );
            
client_printid print_chat "* %s cannot be spectated!" szName );
            
            
taskData] = id;
            
taskData] = iCanBeSpectatedrandomiCanBeSpectatedCount ) ];
            
set_task0.1 "SetSpec" 123456 taskData sizeoftaskData ) );
            
        }
        else
        {
            
BlackScreenid );
        }
    }
}

public 
SetSpectaskData[] )
{
    
set_pevtaskData] , pev_iuser2 taskData] );
}

BlackScreenid 

    
message_beginMSG_ONE g_MsgFade , {0,0,0} , id ); 
    
write_short4096 ); 
    
write_short4096 ); 
    
write_short4096 ); 
    
write_byte); 
    
write_byte); 
    
write_byte); 
    
write_byte255 ); 
    
message_end(); 

__________________
Bugsy is offline
Ludak
Member
Join Date: Oct 2014
Old 05-12-2018 , 16:47   Re: Disable spectating for certain players
Reply With Quote #4

Thank you very much.
You are the best
Ludak 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 04:40.


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