Raised This Month: $ Target: $400
 0% 

[Solved] Hud Msg Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stylaa
Senior Member
Join Date: Oct 2009
Location: Flensburg, Germany
Old 10-18-2010 , 16:58   [Solved] Hud Msg Problem
Reply With Quote #1

im running this funcktion to show the players healt on my server

and what did i wrong?

it displays

tylaa HP: 10000
ter HP: 10000

Must be
Stylaa HP: 10000
Peter HP: 10000

i realy dont know what i did Wrong

PHP Code:
public zombie_hud()
{
    
set_task(1.0"zombie_hud"// set a task to Zombie Hud

            
new szText[2560]
            
szText ""
            
for(new 0g_max_clientsi++)
            {
                if(
g_connected[i] == true && cs_get_user_team(i) == CS_TEAM_CT )
                {
                    new 
PlayerName[33]
                    new 
PlayerHealt[33]
                    
                    
get_user_name(iPlayerName64)
                    
PlayerHealt[i] = get_user_health(i)
                    
                    
formatex(szTextcharsmax(szText), "%s %s HP: %d ^n"szText,PlayerName[i], PlayerHealt[i])
                }
            }
            
set_hudmessage(255000.700.02)
            
ShowSyncHudMsg(0g_MsgSyncZombie,"%s"szText)

    

__________________

Some People brings Happynes by Coming
Some by Going

Last edited by Stylaa; 10-18-2010 at 17:30.
Stylaa is offline
Send a message via ICQ to Stylaa
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-18-2010 , 17:23   Re: Hud Msg Problem
Reply With Quote #2

formatex() -> format() because you are using szText as a formatting variable.
Read about that here: http://www.amxmodx.org/funcwiki.php?...atex&go=search

Also, you don't need an array for health.

Finally, don't index PlayerName in the format statement. Just put the variable name.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Stylaa
Senior Member
Join Date: Oct 2009
Location: Flensburg, Germany
Old 10-18-2010 , 17:30   Re: Hud Msg Problem
Reply With Quote #3

Thanks it works great now
__________________

Some People brings Happynes by Coming
Some by Going
Stylaa is offline
Send a message via ICQ to Stylaa
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-18-2010 , 21:36   Re: [Solved] Hud Msg Problem
Reply With Quote #4

And don't create the variables inside the loop (that'll make a variable for each literation), place them before the loop!

Also, I see that you create playername using 33 cells and you're using get_user_name() with 64... make up your mind, but better use charsmax() like so:
Code:
new name[32]

get_user_name(id, name, charsmax(name))
__________________
Hunter-Digital 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 10:26.


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