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

Optimize Code


Post New Thread Reply   
 
Thread Tools Display Modes
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-25-2020 , 06:49   Re: Optimize Code
Reply With Quote #11

Done, updated my code. Thanks for the feedback, thought i was doing it wrong but after all i was right.

Just one question, if get players using the "b" flag, it will only get the dead players, but since iSpecPlayer should be alive, will this work correctly?
__________________

Last edited by Napoleon_be; 01-25-2020 at 07:26.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-25-2020 , 11:52   Re: Optimize Code
Reply With Quote #12

There are 2 types of players involved with this, the dead human who is spectating (retrieved with get_players() using "bch" flags) and the alive player being spectated (not retrieved with get_players()). So the "bch" flags have no bearing on the alive player being spectated.

Maybe this will make it make more sense:
PHP Code:
public ShowSpecInfo()
{
    new 
iPlayers[32], iNumiSpectatoriSpectatedPlayerszName[33], iRankiMaxRankiStats[8], iBodyhits[8];
    
get_players(iPlayersiNum"bch");
    
    
iMaxRank get_statsnum();
    
    for( new 
iNum i++ )
    {
        
iSpectator iPlayers];
        
iSpectatedPlayer peviSpectator pev_iuser2 );
        
        
get_user_nameiSpectatedPlayer szName charsmaxszName ) );
        
iRank get_user_statsiSpectatedPlayer iStats iBodyhits );
        
        
set_hudmessage(180180180, -1.00.006.01.10.0,0.0, -1);
        
show_hudmessageiSpectator "Spectating [%s] | [Rank: %i / %i]" szName iRank iMaxRank );
    }

__________________

Last edited by Bugsy; 01-25-2020 at 14:25.
Bugsy is online now
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-25-2020 , 18:23   Re: Optimize Code
Reply With Quote #13

So if u use pev(user, pev_iuser2), it automaticly detects the alive player you're spectating?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-25-2020 , 18:49   Re: Optimize Code
Reply With Quote #14

Quote:
Originally Posted by Napoleon_be View Post
So if u use pev(user, pev_iuser2), it automaticly detects the alive player you're spectating?
Yes, if there is such a player, he is stored in the "pev_iuser2" field for each player.
__________________

Last edited by OciXCrom; 01-25-2020 at 18:49.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-26-2020 , 07:57   Re: Optimize Code
Reply With Quote #15

Aight thanks
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 06:24.


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