AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   percent & fix the hitboxs (https://forums.alliedmods.net/showthread.php?t=99897)

One 08-10-2009 14:11

percent & fix the hitboxs
 
1 Attachment(s)
i need help to make an if more then 40% of all users are dead , do just a print.

somthing like this :D im not good in mathematics :D

& how can i edit the hitboxs. my problem is my model is bigger the players hitboxs & when i please is realy near to a wall, he can watch the other site of map.

xPaw 08-10-2009 15:01

Re: percent & fix the hitboxs
 
PHP Code:

new iPlayers32 ], iNumiDead;
get_playersiPlayersiNum"h" );

for( new 
iiNumi++ )
    if( !
is_user_aliveiPlayers] ) )
        
iDead++;

if( ( ( 
iDead iNum ) * 100 ) >= 40 ) {
    
// blubb


Mhh even kids knows how to get percents

One 08-10-2009 15:02

Re: percent & fix the hitboxs
 
ty

:D

Quote:

im not good in mathematics :D

ConnorMcLeod 08-11-2009 00:17

Re: percent & fix the hitboxs
 
Replace

( ( iDead / iNum ) * 100 )

with

( ( iDead * 100 ) / iNum )

One 08-11-2009 02:24

Re: percent & fix the hitboxs
 
Quote:

Originally Posted by ConnorMcLeod (Post 896012)
Replace

( ( iDead / iNum ) * 100 )

with

( ( iDead * 100 ) / iNum )

ty connor

Quote:

Mhh even kids knows how to get percents
http://www.helpbytes.co.uk/images/mess6/smileys/24.gifhttp://www.helpbytes.co.uk/images/smileys/104.gif

[ --<-@ ] Black Rose 08-11-2009 07:38

Re: percent & fix the hitboxs
 
Quote:

Originally Posted by xPaw (Post 895502)
PHP Code:

new iPlayers32 ], iNumiDead;
get_playersiPlayersiNum"h" );

for( new 
iiNumi++ )
    if( !
is_user_aliveiPlayers] ) )
        
iDead++;

if( ( ( 
iDead iNum ) * 100 ) >= 40 ) {
    
// blubb


Mhh even kids knows how to get percents

They also know how to make a simple player loop.

If you really need to use get_players(), you should use this.
Quote:

Originally Posted by Function defenition of get_players()
"b" - Don't return alive players


Either way works. I would use the first option. The second looks better though. If it weren't for that useless Players array I would've used that.
PHP Code:

// in plugin_init().
g_MaxPlayers get_maxplayers();

// ...

new iDead;
for ( new 
<= g_MaxPlayers i++ ) {
   if ( 
is_user_connected(i) && ! is_user_alive(i) )
      
iDead++;
}

if ( ( 
iDead 100 ) /  get_playersnum() >= 40 )
   
// 40% or more is dead. 

PHP Code:

new iPlayers[32], iNum;
get_players(iPlayersiNum"bh");

if ( ( 
iNum 100 ) /  get_playersnum() >= 40 )
    
// 40% or more is dead. 


LaineN 08-11-2009 11:15

Re: percent & fix the hitboxs
 
Quote:

Originally Posted by Superiority (Post 896219)
Code:
if ( is_user_connected(i) || ! is_user_alive(i) )

Wrong.
Should be:
Code:
if ( is_user_connected(i) && !is_user_alive(i) )

[ --<-@ ] Black Rose 08-11-2009 13:21

Re: percent & fix the hitboxs
 
My bad, originally the code was like this:

if ( ! is_user_connected(i) || is_user_alive(i) )
continue;

I forgot to edit that.

ConnorMcLeod 08-11-2009 17:01

Re: percent & fix the hitboxs
 
I think get_playersnum returns HLTVs.
xPaw's way then is better than yours.

[ --<-@ ] Black Rose 08-11-2009 18:52

Re: percent & fix the hitboxs
 
Quote:

Originally Posted by ConnorMcLeod (Post 896690)
I think get_playersnum returns HLTVs.
xPaw's way then is better than yours.

No. A better way would be to use the first version and add a HLTV count.


All times are GMT -4. The time now is 18:29.

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