Raised This Month: $ Target: $400
 0% 

Help counting of players living


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Toallin
Junior Member
Join Date: Jun 2014
Old 06-21-2014 , 22:21   Help counting of players living
Reply With Quote #1

Best to all.

What happens is that I have a problem with the controls of players

PHP Code:
GetAlive()
{
    new 
iAlive
    
    
for(new i<= g_maxplayers; ++i)
        if(
is_user_connected(i) && is_user_alive(i) && cs_get_user_team(i) == CS_TEAM_T)
            
iAlive++;
        
    return 
iAlive;

to put it into a hud if players live shows
PHP Code:
show_hudmessage(0"Alive %d"GetAlive()) 
But when I try to open a menu does not work

PHP Code:
public ShowMenu(id)
{
        if(
GetAlive() = 1)
        {
                new 
menu menu_create("New Menu""CmdNewMenu")

                
menu_additem("Option 1""1")

                
menu_display(idmenu)
        }
        return 
PLUGIN_HANDLED;       

Someone tell me the error
thanks
Toallin is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-21-2014 , 22:59   Re: Help counting of players living
Reply With Quote #2

Try get_players:

PHP Code:
new iPlayers[32],iNum,iPlayer;
    
get_players(iPlayers,iNum,"ach"); // A = Colect Alive Only, C = Skip Bots and H Skipy HLTV
    
    
for(new i;iNum;i++)
    {
        
iPlayer iPlayers[i];
        
        
user_silentkill(iPlayer);
        
client_print(iPlayer,print_chat,"You Are Alive? Soo Die NOW!");
    } 
AND IF YOU NEED

PHP Code:
    new iPlayers[32],iNum;
    
get_players(iPlayers,iNum,"ach"); // A = Colect Alive Only, C = Skip Bots and H Skipy HLTV
    
    
if(iNum == 1)
    {
        
/* MENU HERE */
    

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-21-2014 at 23:00.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-22-2014 , 08:10   Re: Help counting of players living
Reply With Quote #3

Your GetAlive function looks fine. The only thing is that cs_get_user_team(i) == CS_TEAM_T will ensure that only alive terrorists will be counted.

Quote:
Originally Posted by Toallin View Post
PHP Code:
        if(GetAlive() = 1
This can not work, and probably won't even compile. Either this is your problem or you are not showing us the code you are actually using and we therefore can't help you properly.
__________________
In Flames we trust!
Nextra is offline
Toallin
Junior Member
Join Date: Jun 2014
Old 06-22-2014 , 17:36   Re: Help counting of players living
Reply With Quote #4

Thanks Smiley but I use iNum variable globally?
I just want to restrict certain features and menus depending on the players who are alive.
Toallin is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 06-22-2014 , 17:38   Re: Help counting of players living
Reply With Quote #5

You just need to change

Code:
if (GetAlive() = 1)

to

Code:
if (GetAlive() == 1)

Also you don't need to check for connected if you're checking for alive if I'm not wrong.
__________________

Last edited by georgik57; 06-22-2014 at 17:38.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-22-2014 , 17:38   Re: Help counting of players living
Reply With Quote #6

So you want something to be done for alive players, and other thing to be done for dead players?
If so, the best way you can use is get_players and flag "a" for alive players, and flag "b" for dead players. Loop trough the number of players got, and do the thing.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Toallin
Junior Member
Join Date: Jun 2014
Old 06-22-2014 , 17:45   Re: Help counting of players living
Reply With Quote #7

Thanks I understand.
Toallin 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 21:14.


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