Raised This Month: $ Target: $400
 0% 

Looping on all players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dav3
Senior Member
Join Date: Apr 2006
Location: Dust2
Old 08-01-2007 , 12:15   Looping on all players
Reply With Quote #1

hi
What is the problem?
Code:
	new iPlayers[32],iNum
	for(new i=0;i<iNum;i++) // looping command
	{ 
		if (get_user_flags(iPlayers[i]) & ADMIN_KICK) { // admin flags..
			new CsTeams:userTeam = cs_get_user_team(iPlayers[i])
			if (userTeam == CS_TEAM_T) { // team check
				new randModel = random_num(1,4) // random number for model
				new team = 1 // team check for cases
				select_model(iPlayers[i],team,randModel)  // model change command
				if(get_cvar_num("amx_adminmodels_debug") == 1) log_amx("+1 Terror Admin Model Disabled") // debug info, so it succes - but this don't come to console (if the debug enabled) and the model doesnt change.
			} 

// ...
// ...
//  ...
//  ...

select_model(iPlayers,team, model) {
	switch(team) {
		case 1: {  // case 1 for terror
			switch(model) {  // set the model one of these
				case 1: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_TERROR)
				case 2: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_LEET)
				case 3: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_ARCTIC)
				case 4: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_GUERILLA)
			}
		} // etc..
Can somebody fix it?

I want to change every admin's models to default (random from these) when this command executed.
Dav3 is offline
Send a message via MSN to Dav3 Send a message via Skype™ to Dav3
Minimum
Senior Member
Join Date: Jun 2006
Old 08-01-2007 , 15:55   Re: Looping on all players
Reply With Quote #2

No offense but the code you supplied is really butchered. I tried my best to fix it but it would be more helpful if you supplied the whole function.

Code:
    new iPlayers[32],iNum     for(new i=0;i<iNum;i++) // looping command     {         if (get_user_flags(iPlayers[i]) & ADMIN_KICK) { // admin flags..             new CsTeams:userTeam = cs_get_user_team(iPlayers[i])             if (userTeam == CS_TEAM_T) { // team check                 new randModel = random_num(1,4) // random number for model                 new team = 1 // team check for cases                 select_model(iPlayers[i],team,randModel)  // model change function                 if(get_cvar_num("amx_adminmodels_debug") == 1) log_amx("+1 Terror Admin Model Disabled") // debug info, so it succes - but this don't come to console (if the debug enabled) and the model doesnt change.             } // Start of new func?             public select_model(iPlayers,team, model) {     switch(team) {         case 1: {  // case 1 for terror             switch(model) {  // set the model one of these                 case 1: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_TERROR)                 case 2: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_LEET)                 case 3: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_ARCTIC)                 case 4: cs_set_user_team(iPlayers, CS_TEAM_T, CS_T_GUERILLA)             }         }     }     return PLUGIN_HANDLED }
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Dav3
Senior Member
Join Date: Apr 2006
Location: Dust2
Old 08-03-2007 , 07:56   Re: Looping on all players
Reply With Quote #3

Ok, here's the full function:

PHP Code:
public disable(idlevelcid) {
    if (
get_cvar_num("amx_adminmodels") == 0) {
        if(
is_user_connected(id)) client_print(id,print_chat,"Models Already Disabled")
        if(
get_cvar_num("amx_adminmodels_debug") == 1log_amx("Admin Models Already Disabled")
        return 
PLUGIN_HANDLED
    
}

    
server_cmd("amx_adminmodels 0")


    if(
is_user_connected(id) == 1) {
        new 
name[32],ip[32]
        
get_user_name(id,name,31)
        
get_user_ip(id,ip,31)
        
log_amx("%s (%s) - amx_adminmodels_disable",name,ip)
    } else {
        if(
get_cvar_num("amx_adminmodels_debug") == 1log_amx("Admin Models Enabled By The Server")
    }


    new 
iPlayers[32],iNum
    
for(new i=0;i<iNum;i++) // looping command
    

        if (
get_user_flags(iPlayers[i]) & ADMIN_KICK) { // admin flags..
            
new CsTeams:userTeam cs_get_user_team(iPlayers[i])
            if (
userTeam == CS_TEAM_T) { // team check
                
new randModel random_num(1,4// random number for model
                
new team // team check for cases
                
select_model(iPlayers[i],team,randModel)  // model change command
                
if(get_cvar_num("amx_adminmodels_debug") == 1log_amx("+1 Terror Admin Model Disabled"// debug info, so it succes - but this don't come to console (if the debug enabled) and the model doesnt change.
            
}  else if(userTeam == CS_TEAM_CT) {
                new 
randModel random_num(1,4)
                new 
team 2
                select_model
(iPlayers[i],team,randModel)
                if(
get_cvar_num("amx_adminmodels_debug") == 1log_amx("+1 CT Admin Model Disabled")
            } else {
                
cs_reset_user_model(iPlayers[i])
                if(
get_cvar_num("amx_adminmodels_debug") == 1log_amx("+1 Admin In Spectator - No Disable")
            }
        }
    }
    
client_print(id,print_chat,"Models Disabled")
    return 
PLUGIN_CONTINUE
}


select_model(iPlayers,teammodel) {
    switch(
team) {
        case 
1: {  // case 1 for terror
            
switch(model) {  // set the model one of these
                
case 1cs_set_user_team(iPlayersCS_TEAM_TCS_T_TERROR)
                case 
2cs_set_user_team(iPlayersCS_TEAM_TCS_T_LEET)
                case 
3cs_set_user_team(iPlayersCS_TEAM_TCS_T_ARCTIC)
                case 
4cs_set_user_team(iPlayersCS_TEAM_TCS_T_GUERILLA)
            } 
                          }
                          case 
2: {
            switch(
model) {
                case 
1cs_set_user_team(iPlayersCS_TEAM_CTCS_CT_URBAN)
                case 
2cs_set_user_team(iPlayersCS_TEAM_CTCS_CT_GSG9)
                case 
3cs_set_user_team(iPlayersCS_TEAM_CTCS_CT_SAS)
                case 
4cs_set_user_team(iPlayersCS_TEAM_CTCS_CT_GIGN)
            }
        }
    }

if i tried to compile ur code it gives me some error with teams...


its the full first code.
the problem might be with the iplayers[i] or in the looping command.

Thanks for help

Last edited by Dav3; 08-03-2007 at 08:11.
Dav3 is offline
Send a message via MSN to Dav3 Send a message via Skype™ to Dav3
Dav3
Senior Member
Join Date: Apr 2006
Location: Dust2
Old 08-03-2007 , 08:29   Re: Looping on all players
Reply With Quote #4

] amx_adminmodels_disable
Unknown command: amx_adminmodels_disable
Models Disabled

Why unknown command??
Dav3 is offline
Send a message via MSN to Dav3 Send a message via Skype™ to Dav3
_Master_
Senior Member
Join Date: Dec 2006
Old 08-03-2007 , 09:43   Re: Looping on all players
Reply With Quote #5

PHP Code:
new iPlayers[32],iNum
    
    get_players
(iPlayersiNum)
    
    for(new 
i=0;i<iNum;i++) // looping command 
_Master_ is offline
Dav3
Senior Member
Join Date: Apr 2006
Location: Dust2
Old 08-03-2007 , 14:11   Re: Looping on all players
Reply With Quote #6

eh...
1 line ...
Thx very much
works.
Dav3 is offline
Send a message via MSN to Dav3 Send a message via Skype™ to Dav3
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 10:54.


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