Raised This Month: $32 Target: $400
 8% 

Show message to dead people


Post New Thread Reply   
 
Thread Tools Display Modes
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-16-2007 , 19:04   Re: Show message to dead people
Reply With Quote #11

Quote:
Originally Posted by Alka View Post
why to loop trough 32 slots ? o.O pointless... you can make also :
Code:
static Players[32], Num;
get_players(Players, Num);
 
for(new i = 0 ; i < Num ; i++)
{
    if(is_user_alive)
        continue;
 
    //blah blah...your dead.
}
What do you think get_players() do?
If Lee would've added is_user_connected() ( if that ain't allready checked by is_user_alive() (?) ) it would've been better too.
You won't notice the differance anyway.
[ --<-@ ] Black Rose is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 11-16-2007 , 20:47   Re: Show message to dead people
Reply With Quote #12

is_user_alive() does indeed check whether or not they're connected - why I purposely omitted it when talking about readability is a mystery.

Code:
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);

Last edited by Lee; 11-18-2007 at 06:14.
Lee is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2007 , 02:23   Re: Show message to dead people
Reply With Quote #13

Quote:
Originally Posted by Lee View Post
is_user_alive() does indeed check whether or not they're connected - why I purposely omitted it when talking about readability is a mystery.

Code:
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);
In this case, we want to show messages to dead players, so we have to check if players are connected since is_user_alive will return 0 for deads and for non-players.
So what's better ? use is_user_alive and is_user_connected natives or just get_players ?
ConnorMcLeod is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 11-17-2007 , 15:11   Re: Show message to dead people
Reply With Quote #14

Personally, the issue is not which is more efficient - it's about which doesn't degrade readability. Too many people around here (including me at times) are obsessed with pseudo-optimisations.

You're right - in that my usage of is_user_alive() isn't filtering dead players. I negated the following (which would never need is_user_connected()) without thinking.

Code:
if(is_user_alive()) {     doUsefulStuffRatherThanBailing() }
In any case, like many natives, show_hudmessage() checks whether or not they're connected before displaying the message anyway. Because of this a lot of is_user_connected() calls are redundant.

Maybe I should just shut up and stop arguing on both sides of the readability fence.

I think we may have overwhelmed Mrrr somewhat.

Last edited by Lee; 11-18-2007 at 06:25.
Lee is offline
Mrrr
Member
Join Date: Jun 2007
Old 11-27-2007 , 04:04   Re: Show message to dead people
Reply With Quote #15

Thank you for all help.

You are the best !
Mrrr 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 20:59.


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