Raised This Month: $51 Target: $400
 12% 

Solved get player spectating name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ayman Khaled
Senior Member
Join Date: Mar 2017
Location: Palestine
Old 08-05-2017 , 08:57   get player spectating name
Reply With Quote #1

Hello.
I searched but didn't found something like i want
is there a function to get player name you spectating while you are dead ? for example
PHP Code:
public test(spectating)
{
    new 
name[32]
    
get_user_name(spectatingnamecharsmax(name))

i mean Player 1 spectating player 2 , then it will print in the hud of Player 1's screen for example Name: Player 2 | HP: 67 ( Player 2 hp )
__________________

Last edited by Ayman Khaled; 08-05-2017 at 16:38.
Ayman Khaled is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 08-05-2017 , 14:17   Re: get player spectating name
Reply With Quote #2

Zombie Plague has the answer for that. Look how endless HUD message which shows your/or your spectating target stats, is handled there.
__________________


Last edited by NiHiLaNTh; 08-05-2017 at 14:17.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Ayman Khaled
Senior Member
Join Date: Mar 2017
Location: Palestine
Old 08-05-2017 , 15:42   Re: get player spectating name
Reply With Quote #3

which one because there are 100 million zombie plague
+ i found this code
PHP Code:
new iSpecPlayer entity_get_int(idEV_INT_iuser2); 
but when i tried it , when you spectate someone it's works without any problem
but if you don't spec anyone, it will print server name with 0 xp, level
code
PHP Code:
public ShowUserInfo() 

    static 
id
    for ( 
id 1id <= get_maxplayers ( ); id++ ) 
    { 
        new 
iSpecPlayer entity_get_int(idEV_INT_iuser2);  
        new 
SpecName[32]
    
        
get_user_name(iSpecPlayerSpecNamecharsmax(SpecName))
    
        if( 
is_user_alive id ) )
        {
            
set_dhudmessage 1061208, -1.00.206.00.5 ); 
            
show_dhudmessage id"[HP: %d | Level %d: %s | XP: %d/%d]"get_user_health id ), iLevel [id], RANKNAMES[iLevel[id]], iExp [id], LEVELS[iLevel[id]]); 
        }
        else
        {
            
set_dhudmessage 1061208, -1.00.206.00.5 ); 
            
show_dhudmessage id"[Name: %s | Level %d: %s | XP: %d/%d]"SpecNameiLevel [iSpecPlayer], RANKNAMES[iLevel[iSpecPlayer]], iExp [iSpecPlayer], LEVELS[iLevel[iSpecPlayer]]); 
        }
    }

__________________

Last edited by Ayman Khaled; 08-05-2017 at 15:54.
Ayman Khaled is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2017 , 15:51   Re: get player spectating name
Reply With Quote #4

Check if iSpecPlayer is actually a player(between 1 and maxplayers).
__________________
HamletEagle is offline
Ayman Khaled
Senior Member
Join Date: Mar 2017
Location: Palestine
Old 08-05-2017 , 16:18   Re: get player spectating name
Reply With Quote #5

Thanks, now it's good
PHP Code:
#define is_user_player(%1) 1 <= %1 <= g_MaxClients
new g_MaxClients
plugin_init
PHP Code:
g_MaxClients get_maxplayers(); 
ShowUserInfo
PHP Code:
public ShowUserInfo() 

    static 
id
    for ( 
id 1id <= g_MaxClientsid++ ) 
    { 
        new 
iSpecPlayer entity_get_int(idEV_INT_iuser2);  
        new 
SpecName[32]
    
        
get_user_name(iSpecPlayerSpecNamecharsmax(SpecName))
    
        if( 
is_user_alive id ) )
        {
            
set_dhudmessage 1061208, -1.00.206.00.5 ); 
            
show_dhudmessage id"[HP: %d | Level %d: %s | XP: %d/%d]"get_user_health id ), iLevel [id], RANKNAMES[iLevel[id]], iExp [id], LEVELS[iLevel[id]]); 
        }
        else
        {
            if( 
is_user_playeriSpecPlayer ) )
            {
                
set_dhudmessage 1061208, -1.00.206.00.5 ); 
                
show_dhudmessage id"[Name: %s | Level %d: %s | XP: %d/%d]"SpecNameiLevel [iSpecPlayer], RANKNAMES[iLevel[iSpecPlayer]], iExp [iSpecPlayer], LEVELS[iLevel[iSpecPlayer]]); 
            }
        }
    }

__________________
Ayman Khaled 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:07.


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