Raised This Month: $ Target: $400
 0% 

Shows weird name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 01-02-2011 , 14:57   Shows weird name
Reply With Quote #1

Is it right like that, cause I get weird names, the print is a string.

PHP Code:
new szName[32];

get_user_name(attackerszNamecharsmax(szName)) 
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2011 , 15:21   Re: Shows weird name
Reply With Quote #2

What is the value of attacker?
__________________
fysiks is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-02-2011 , 16:36   Re: Shows weird name
Reply With Quote #3

What do you mean with value?
bibu is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 01-02-2011 , 16:39   Re: Shows weird name
Reply With Quote #4

He means it won't give proper name if the attacker's value isnt id.
SpeeDeeR is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-02-2011 , 16:44   Re: Shows weird name
Reply With Quote #5

Oh nono, there you go:

PHP Code:
in init:

register_event"Damage""eventDamage""b" );

public 
eventDamage( )
{
    if( 
g_bKnifeHit )
    {
        
g_bKnifeHit false;
        
        static 
victim;
        
victim g_HitData[iVictim];
        
        if( !( 
<= victim <= 32 ) )
        {
            return 
PLUGIN_CONTINUE;
        }
        
        static 
attacker;
        
attacker g_HitData[iAttacker];
        
        static 
Float:distance;
        
distance g_HitData[flDistance];
        
        static 
Float:health;
        
pevvictimpev_healthhealth );
        
        static 
rgb;
        
GetHudColorrg);
        
        static 
Float:xFloat:y;
        
GetHudCoordsx);
        
        
set_hudmessagergbxy00.0get_pcvar_floatg_pCVarHudHoldtime ), 0.00.0);
        
        new 
szName[32];
        
        if( 
g_HitData[iAttack] == STAB )
        {
            
show_hudmessageattacker"Stab Stats (%s)^nDistance: %f (max: 32.0)^nHit: %s (%s)^nDamage: %i"\
                , 
g_szTraceType[TraceType:!g_HitData[iHitgroup]],\
                
distanceget_user_name(victimszNamecharsmax(szName))  ,\
                
g_szHitgroup[g_HitData[iHitgroup]], pevvictimpev_dmg_take ) );
        
            if( 
health 0.0 )
            {
                
ColorChatvictimBLUE"[Knife Distance] %s stabbed you within %f units (%s)!",\
                    
get_user_name(attackerszNamecharsmax(szName))  ,\
                    
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                
                if( 
distance >= get_pcvar_floatg_pCVarSoundGodlikeStab ) )
                {
                    
ColorChat0RED"[Knife Distance] %s stabbed %s within %f units (%s)!",\
                        
get_user_name(attackerszNamecharsmax(szName))  , get_user_name(victimszNamecharsmax(szName))  ,\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[GODLIKE] );
                        
                }
                else if( 
distance >= get_pcvar_floatg_pCVarSoundWickedSickStab ) )
                {
                    
ColorChat0GREEN"[Knife Distance] %s stabbed %s within %f units (%s)!",\
                        
get_user_name(attackerszNamecharsmax(szName))  , get_user_name(victimszNamecharsmax(szName))  ,\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[WICKEDSICK] );
                }
            }
        }
        else
        {
            
show_hudmessageattacker"Slash Stats (%s)^nDistance: %f (max: 48.0)^nHit: %s (%s)^nDamage: %i"\
                , 
g_szTraceType[TraceType:!g_HitData[iHitgroup]],\
                
distanceget_user_name(victimszNamecharsmax(szName))  ,\
                
g_szHitgroup[g_HitData[iHitgroup]], pevvictimpev_dmg_take ) );
            
            if( 
health 0.0 )
            {
                
ColorChatvictimBLUE"[Knife Distance] %s slashed you within %f units (%s)!",\
                    
get_user_name(attackerszNamecharsmax(szName))  ,\
                    
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                
                if( 
distance >= get_pcvar_floatg_pCVarSoundGodlikeSlash ) )
                {
                    
ColorChat0RED"[Knife Distance] %s slashed %s within %f units (%s)!",\
                        
get_user_name(attackerszNamecharsmax(szName))  , get_user_name(victimszNamecharsmax(szName))  ,\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[GODLIKE] );
                }
                else if( 
distance >= get_pcvar_floatg_pCVarSoundWickedSickSlash ) )
                {
                    
ColorChat0GREEN"[Knife Distance] %s slashed %s within %f units (%s)!",\
                        
get_user_name(attackerszNamecharsmax(szName))  , get_user_name(victimszNamecharsmax(szName))  ,\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[WICKEDSICK] );
                }
            }
        }
    }
    
    return 
PLUGIN_CONTINUE;

bibu is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-02-2011 , 19:32   Re: Shows weird name
Reply With Quote #6

Code:
ColorChat( victim, BLUE, "[Knife Distance] %s stabbed you within %f units (%s)!",     get_user_name(attacker, szName, charsmax(szName))  ,     distance, g_szHitgroup[g_HitData[iHitgroup]] );
There is your problem.
You have to use that in a different line and then use the variable as the print argument.
Code:
get_user_name(attacker, szName, charsmax(szName)); ColorChat( victim, BLUE, "[Knife Distance] %s stabbed you within %f units (%s)!",     szName  ,     distance, g_szHitgroup[g_HitData[iHitgroup]] );
That occurs more than once in the code, so be sure to correct them all.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-03-2011 , 12:04   Re: Shows weird name
Reply With Quote #7

I didn't really understand what you mean, do I need to use 2 new szName[32]; ?
bibu is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-03-2011 , 12:16   Re: Shows weird name
Reply With Quote #8

No, you've to get name before printing it, like you can't print that, what you didn't get yet...

get name
send name...

not -
send name
get name...
reinert is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-03-2011 , 13:30   Re: Shows weird name
Reply With Quote #9

Quote:
Originally Posted by reinert View Post
No, you've to get name before printing it, like you can't print that, what you didn't get yet...

get name
send name...

not -
send name
get name...
It's everytime like that print %s(variable, ...)
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-03-2011 , 13:53   Re: Shows weird name
Reply With Quote #10

Yes, but string variable array has to be filled first.

PHP Code:
get_user_name(idnamecharsmax(name))
client_print(idprint_chat"Hello %s"name

Also, if you do :

PHP Code:
client_print(idprint_chat"Hello %s"get_user_name(idnamecharsmax(name))) 
then what is passed is not the index of the string, but the result of get_user_name, and get_user_name result is the length of the name.
So amxx try to format %s with a wrong index you obtain weird names wuch as sound/weapons/xbow.wav
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-03-2011 at 13:56.
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

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 02:07.


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