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

Freeday menu show all alive terrorists does not work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vaki
Junior Member
Join Date: Nov 2016
Old 12-30-2018 , 12:25   Freeday menu show all alive terrorists does not work
Reply With Quote #1

When i try to open this menu, it wont open when i use for loop. When i comment for loop it does work. So problem is somewhere in for loop but i dont know where.
PHP Code:
        Menu menufd = new Menu(FreedayMenu);
        
menufd.SetTitle("Freeday meni");
        for(new 
0i<32i++)
        {            
            if(
IsPlayerAlive(i) && GetClientTeam(i) == 2)
            {
                new 
String:name[64];
                
char user[3];
                
GetClientName(inamesizeof(name));
                
IntToString(iusersizeof(user));
                
menufd.AddItem(username);
            }
        }
        
menufd.ExitBackButton true;  
        
menufd.Display(client20); 
Vaki is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-30-2018 , 13:22   Re: Freeday menu show all alive terrorists does not work
Reply With Quote #2

Here basic loop all player indexs
PHP Code:
for(int i 1<= MaxClientsi++)
{
    if(!
IsClientInGame(i)) continue; // skip indexs where no client and not connected fully in game

    
if(GetClientTeam(i) != || !IsPlayerAlive(i)) continue; // skip client in any other team than team index 2 and when client is dead

    // Do your stuff
    //
    // PrintToChatAll("Player(%i) name %N", i, i);

__________________
Do not Private Message @me

Last edited by Bacardi; 12-30-2018 at 13:24.
Bacardi is offline
sdz
Senior Member
Join Date: Feb 2012
Old 12-30-2018 , 18:41   Re: Freeday menu show all alive terrorists does not work
Reply With Quote #3

try IsClientConnected or IsClientInGame beforehand

Last edited by sdz; 12-30-2018 at 18:41.
sdz is offline
Vaki
Junior Member
Join Date: Nov 2016
Old 12-30-2018 , 19:46   Re: Freeday menu show all alive terrorists does not work
Reply With Quote #4

Thank you all, @Barcadi it works.
Vaki 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 19:28.


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