Raised This Month: $ Target: $400
 0% 

Remove player name when aiming


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 10-03-2008 , 13:47   Remove player name when aiming
Reply With Quote #1

Is there any way to remove the name of the player that shows in the down left corner when someone is aiming at him?
I just need to remove it from one player for some sec and then it can come back again. Is there any code that can do that?
LaineN is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-03-2008 , 14:21   Re: Remove player name when aiming
Reply With Quote #2

no plugin needed

mp_playerid 1 -> show only teamates

0/2 -> All players / deactivated
__________________
xPaw is offline
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 10-03-2008 , 18:42   Re: Remove player name when aiming
Reply With Quote #3

Ok but is there any way to remove it only for one player?
LaineN is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 10-03-2008 , 20:33   Re: Remove player name when aiming
Reply With Quote #4

Hook the StatusValue message and do your checks.
http://wiki.amxmodx.org/Half-Life_1_...ts#StatusValue

EDIT:
This was pretty annoying to figure out since you only want to block 1 player text, but still see everyone elses text. The code below took me about an hour and a half to figure out :S!

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN    "Status Value Blocking"
#define VERSION    "1.0"
#define AUTHOR    "hlstriker"

#define MAX_PLAYERS 32
new g_hStatusValue;
new 
g_iBlockPlayer[MAX_PLAYERS+1];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /test""TestFunc");
    
g_hStatusValue get_user_msgid("StatusValue");
    
register_message(g_hStatusValue"msg_StatusValue");
}

public 
client_authorized(iClient)
    
g_iBlockPlayer[iClient] = 0;

public 
TestFunc(iClient)
{
    if(
g_iBlockPlayer[iClient])
        
g_iBlockPlayer[iClient] = 0;
    else
    {
        static 
iTargetiBody;
        
get_user_aiming(iClientiTargetiBody);
        
        if(
is_user_alive(iTarget))
        {
            
// Set the block variable to the player you want to block
            
g_iBlockPlayer[iClient] = iTarget;
            
            
// Send the ClearStatusValue function when starting the block,
            // This way it removes the text incase you are already looking at someone.
            
ClearStatusValue(iClient);
        }
        else
            
client_print(iClientprint_chat"[Error] Please aim at a player.");
    }
}

public 
msg_StatusValue(iMsgIDiDestiClient)
{
    
// Check to see if player is blocking view of someone
    
if(g_iBlockPlayer[iClient] > 0)
    {
        static 
iFlagiValue;
        
iFlag get_msg_arg_int(1);
        
iValue get_msg_arg_int(2);
        
        
// Check if client ID is equal to the player you are blocking
        
if(iFlag == && iValue == g_iBlockPlayer[iClient])
        {
            
// Call the ClearStatusValue function to remove the text.
            // We can't block it directly here since this message is sent 3 times,
            // it won't fully block the text. And because only flag 2 has the client ID
            // we must resend all 3 messages just to clear the text (stupid, I know).
            
ClearStatusValue(iClient);
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
ClearStatusValue(iClient)
{
    
// All 3 of these messages have to be resent with a value of 0
    
message_begin(MSG_ONE_UNRELIABLEg_hStatusValue_iClient);
    
write_byte(1);
    
write_short(0);
    
message_end();
    
    
message_begin(MSG_ONE_UNRELIABLEg_hStatusValue_iClient);
    
write_byte(2);
    
write_short(0);
    
message_end();
    
    
message_begin(MSG_ONE_UNRELIABLEg_hStatusValue_iClient);
    
write_byte(3);
    
write_short(0);
    
message_end();

Whew!!!! Probably one of the most annoying things I've tried to do with AMXX.

Last edited by hlstriker; 10-03-2008 at 22:17.
hlstriker is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-04-2008 , 02:20   Re: Remove player name when aiming
Reply With Quote #5

hlstriker you disappoint me! ^^
Alka is offline
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 10-04-2008 , 02:24   Re: Remove player name when aiming
Reply With Quote #6

Thanks hlstriker.
Have you tested it and it works? Will test is later.
LaineN is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-04-2008 , 02:29   Re: Remove player name when aiming
Reply With Quote #7

I think this should be easier :
(just miss the function to mark the player...)

This suppose the event (aka POST registered message) will still be fired before StatusText message, if it's not the case, the event will have to be changed into a registered message.

PHP Code:
#include <amxmodx>

#define MAX_PLAYERS    32

new g_iBlockStatusText[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_event("StatusValue""Event_StatusValue""b""1=2")
    
register_messageget_user_msgid("StatusText") , "Message_StatusText")
}

public 
Event_StatusValue(id)
{
    
g_iBlockStatusText[id] = (read_data(2) == g_iDONT_SHOW_MY_NAME)
}

public 
Message_StatusText(iMsgIdMSG_DESTid)
{
    return 
g_iBlockStatusText[id]

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-04-2008 at 02:34.
ConnorMcLeod is offline
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 10-04-2008 , 02:35   Re: Remove player name when aiming
Reply With Quote #8

Quote:
Originally Posted by connorr View Post
I think this should be easier :
(just miss the function to mark the player...)

This suppose the event (aka POST registered message) will still be fired before StatusText message, if it's not the case, the event will have to be changed into a registered message.

PHP Code:
#include <amxmodx>

#define MAX_PLAYERS    32

new g_iBlockStatusText[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_event("StatusValue""Event_StatusValue""b""1=2")
    
register_messageget_user_msgid("StatusText") , "Message_StatusText")
}

public 
Event_StatusValue(id)
{
    
g_iBlockStatusText[id] = (read_data(2) == g_iDONT_SHOW_MY_NAME)
}

public 
Message_StatusText(iMsgIdMSG_DESTid)
{
    return 
g_iBlockStatusText[id]

I don't understand how that will work :S Thre is now code that blocking it?
LaineN is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-04-2008 , 02:45   Re: Remove player name when aiming
Reply With Quote #9

Try this :
amx_dontshow <id/name/authid> <0/1>

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define MAX_PLAYERS    32

new g_iBlockStatusText[MAX_PLAYERS+1]
new 
bool:g_bDontShowMe[MAX_PLAYERS+1]

new 
gmsgStatusValuegmsgStatusText
new g_iStatusValueg_iStatusText
new g_iMaxPlayers

public plugin_init()
{
    
register_plugin("PLUGIN""VERSION""NAME")

    
register_clcmd("amx_dontshow""ClientCommand_DontShow"ADMIN_SLAY"<id/name/authid> <0/1>")

    
gmsgStatusValue get_user_msgid("StatusValue")
    
gmsgStatusText get_user_msgid("StatusText")
    
g_iMaxPlayers get_maxplayers()
}

public 
Message_Status(iMsgIdMSG_DESTid)
{
    if(
iMsgId == gmsgStatusValue)
    {
        if( 
get_msg_arg_int(1) == )
        {
            static 
iPlayer
            iPlayer 
get_msg_arg_int(2)
            
g_iBlockStatusText[id] = (iPlayer <= g_iMaxPlayers && g_bDontShowMe[iPlayer])
        }
    }
    else
    {
        return 
g_iBlockStatusText[id]
    }
    return 
PLUGIN_CONTINUE
}

public 
ClientCommand_DontShow(idlevelcid)
{
    if( !
cmd_access(idlevelcid2) )
        return 
PLUGIN_HANDLED

    
new szPlayer[32]
    
read_argv(1szPlayer31)

    new 
plr cmd_target(idszPlayer)
    if( !
plr )
        return 
PLUGIN_HANDLED

    
new szStatus[2]
    
read_argv(2szStatus1)
    
get_user_name(plrszPlayer31)
    switch( 
szStatus[0] )
    {
        case 
'0':
        {
            if( 
g_bDontShowMe[plr] )
            {
                
Set_Id(plrfalse)
                
client_print(idprint_console"%s's name will be shown again"szPlayer)
            }
            else
            {
                
client_print(idprint_console"%s's name is already being shown"szPlayer)
            }
        }
        case 
'1':
        {
            if( !
g_bDontShowMe[plr] )
            {
                
Set_Id(plrtrue)
                
client_print(idprint_console"%s's name will not be shown"szPlayer)
            }
            else
            {
                
client_print(idprint_console"%s's name is already hidden"szPlayer)
            }
        }
        default :
        {
            
client_print(idprint_console"Usage: amx_dontshow <id/name/authid> <0/1>")
        }
    }

    return 
PLUGIN_HANDLED
}

Set_Id(idbool:bStatus)
{
    if( 
bStatus )
    {
        
g_bDontShowMe[id] = true
        Register_Messages
()
    }
    else
    {
        
g_bDontShowMe[id] = false
        Unregister_Messages
()
    }
}

Register_Messages()
{
    if( !
g_iStatusValue )
        
g_iStatusValue register_messagegmsgStatusValue "Message_Status")

    if( !
g_iStatusText )
        
g_iStatusText register_messagegmsgStatusText "Message_Status")
}

Unregister_Messages()
{
    static 
id
    
for(id 1id<=g_iMaxPlayersid++)
    {
        if(
g_bDontShowMe[id])
            return
    }

    
unregister_messagegmsgStatusValueg_iStatusValue)
    
g_iStatusValue 0
    unregister_message
gmsgStatusTextg_iStatusText)
    
g_iStatusText 0

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-04-2008 at 03:31.
ConnorMcLeod is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-04-2008 , 03:40   Re: Remove player name when aiming
Reply With Quote #10

Quote:
Originally Posted by connorr View Post
amx_dontshow <id/name/authid> <0/1>
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 01:45.


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