Raised This Month: $ Target: $400
 0% 

Replacing Name Showing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-27-2007 , 14:57   Replacing Name Showing
Reply With Quote #1

What I'm trying to do is replace the default name-showing when you look at a player, to a custom one that show a hud message.

Code:
new gHudSyncObj;

public plugin_init()
{
    register_event("StatusValue", "eventStatusValue", "be", "1=2", "2!0");
    gHudSyncObj = CreateHudSyncObj();
}

public eventStatusValue(id)
{
    new pid = read_data(2), red, green, blue, team = get_user_team(pid);
    
    switch(team)
    {
        case 1:
        {
            red = 255;
            green = 50;
            blue = 50;
        }
        case 2:
        {
            red = 50;
            green = 100;
            blue = 255;
        }
        default:
        {
            red = 100;
            green = 100;
            blue = 100;
        }
    }
    
    new szName[32];
    get_user_name(pid, szName, 31);
    
    ClearSyncHud(id, gHudSyncObj);
    set_hudmessage(red, green, blue, -1.0, -1.0, 0, 0.0, 0.25, 0.0, 0.0, 4);
    ShowSyncHudMsg(id, gHudSyncObj, szName);
    return PLUGIN_HANDLED;
}
It shows the message, but it only lasts for the hud time, and I expected it to last until I looked away from the player.

Also, it doesn't block the message in the bottom-left corner of the screen.

Does anyone have a different/better way to do this?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-27-2007 , 23:08   Re: Replacing Name Showing
Reply With Quote #2

With the "StatusValue" message I think there is an argument that is set to 1 when you are looking at them, then it sends another message that sets the argument to 0 (I THINK!!! It's been awhile since I've used StatusValue).

If I am correct in the above then you can set a task to keep the hud message up until the argument is 0.

Also, the reason it's not blocking the message is because you can't block using register_event. You will need to use register_message.
hlstriker is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-28-2007 , 00:18   Re: Replacing Name Showing
Reply With Quote #3

heres a diff variation that i came up with after i read your post

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

new g_HudSyncObj;
new g_MaxPlayers;

public plugin_init()
{
    register_forward(FM_PlayerPreThink, "fwd_PlayerPreThink", 0);
    g_HudSyncObj = CreateHudSyncObj();
    g_MaxPlayers = get_maxplayers();
    set_msg_block(get_user_msgid("StatusValue"), BLOCK_SET);
}

public fwd_PlayerPreThink(id)
{
    static pid, body;
    get_user_aiming(id, pid, body, 9999);
    if(pev_valid(pid) && (0 < pid <= g_MaxPlayers) && is_user_connected(pid))
    {
        static red, green, blue, team, szName[42];
        
        team = get_user_team(pid, "", 0);
        get_user_name(pid, szName, 31);
        format(szName, 41, "%s^n(%s)", szName, (team == get_user_team(id, "", 0)) ? "Friend" : "Enemy");
        
        switch(team)
        {
            case 1:
            {
                red = 255;
                green = 50;
                blue = 50;
            }
            case 2:
            {
                red = 50;
                green = 150;
                blue = 255;
            }
            default:
            {
                red = 100;
                green = 100;
                blue = 100;
            }
        }
        
        ClearSyncHud(id, g_HudSyncObj);
        set_hudmessage(red, green, blue, -1.0, -1.0, 0, 0.0, 0.25, 0.0, 0.5, 4);
        ShowSyncHudMsg(id, szName);
    }
    return FMRES_IGNORED;
}
i dont have time to test, but how does that look?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-28-2007 , 02:01   Re: Replacing Name Showing
Reply With Quote #4

This will display the players name and health you are looking at. Just add your team checks and whatever else to it that you had.

PHP Code:
new g_lookingHud;
new 
g_lookingAt[33];
new 
Float:g_nextHudMsg[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink");
    
register_message(get_user_msgid("StatusValue"), "msg_StatusValue");
    
g_lookingHud CreateHudSyncObj();
}

public 
msg_StatusValue(msgIddestid)
{
    new 
flag get_msg_arg_int(1);
    new 
value get_msg_arg_int(2);
    
    if(
flag == 2)
    {
        if(
value 0)
            
g_lookingAt[id] = value;
        else
            
g_lookingAt[id] = 0;
    }
    
    return 
PLUGIN_HANDLED;
}

public 
fwd_PlayerPreThink(id)
{
    new 
Float:gametime get_gametime();
    
    if(
g_lookingAt[id] != && g_nextHudMsg[id] < gametime)
    {
        static 
szName[33], health;
        
health pev(g_lookingAt[id], pev_health);
        
get_user_name(g_lookingAt[id], szName32);
        
        
set_hudmessage(25500, -1.0, -1.000.00.250.00.54);
        
ShowSyncHudMsg(idg_lookingHud"%s (%i)"szNamehealth);
        
        
g_nextHudMsg[id] = gametime 0.7;
    }

hlstriker is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-28-2007 , 11:28   Re: Replacing Name Showing
Reply With Quote #5

Shouldn't you block StatusText message instead ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-28-2007 , 17:04   Re: Replacing Name Showing
Reply With Quote #6

I think that's the command I was thinking of at first when I saw this thread. I didn't even try StatusText because I saw StatusValue in X-olents code and just used that. The code I posted still works though

Edit:
Since StatusValue is the one that get's all of the information needed it is best to use it like we did. By blocking the StatusValue and it working there would be no need to block StatusText since it doesn't show up anyhow.

Last edited by hlstriker; 12-28-2007 at 17:07.
hlstriker is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-29-2007 , 01:40   Re: Replacing Name Showing
Reply With Quote #7

thanks hlstriker
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 11:03.


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