AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   BothTeams by cvar (https://forums.alliedmods.net/showthread.php?t=134654)

Ex3cuTioN 08-07-2010 14:13

BothTeams by cvar
 
So how can i do to make both teams use the command with the cvar.It works if the cvar is 1 for t and 2 for ct, but not work if it's 3.

PHP Code:

#include <amxmodx>

new cvar;

public 
plugin_init() {
    
cvar register_cvar("amx_show_team","3");
    
/*
        1 - only t
        2 - only ct
        3 - both
    */
    
register_clcmd("say /message","cmdShow");
}

public 
cmdShow(id) {
    new 
team;
    if(
get_pcvar_num(cvar)) {
        
team 1;
    }
    else if(
get_pcvar_num(cvar) == 2) {
        
team 2;
    }
    else if(
get_pcvar_num(cvar) == 3) {
        
team 0;
    }
        
    if(
get_user_team(id) == team) {
        
client_print(id,print_chat,"It worked");
    }
    else {
        switch(
get_pcvar_num(cvar)) {
            case 
1:
            {
                
client_print(id,print_chat,"You must be T");
            }
            case 
2:
            {
                
client_print(id,print_chat,"You must be CT");
            }
        }
    }



nikhilgupta345 08-07-2010 15:01

Re: BothTeams by cvar
 
I don't think that 0 is a team num. 1=t, 2=ct, 3=spec. Also, if the cvar is 2, and u do the first get_pcvar_num, it still returns true because 2 returns true, not only 1. Idk if this is exactly what you wanted but basically what this does is if someone types /message, and the cvar is set to one, it will say to all of the t's that they are t. If cvar is set to two, it will show all of the ct's that they are ct's. If it is 3, it will show everyone "it worked". Clarify if this isn't what u wanted.

Code:

#include <amxmodx>

new cvar;

public plugin_init() {
    cvar = register_cvar("amx_show_team","3");
    /*
        1 - only t
        2 - only ct
        3 - both
    */
    register_clcmd("say /message","cmdShow");
}

public cmdShow(id) {
   
    new team=get_pcvar_num(cvar)
    new players[32], player, num
    get_players(players, num)
   
    if(team==3){
       
        switch(team) {
           
       
        case 1:
    {
        for(new i;i<num;i++)
      {      player=players[i]
          new team3=get_user_team(player)
          if(team3==1)
              client_print(id,print_chat,"You must be T");
      }
    }
           
      case 2:
   
    {
        for(new i;i<num;i++)
      {      player=players[i]
          new team4=get_user_team(player)
          if(team4==2)
              client_print(id,print_chat,"You must be CT");
      }
    }
 
     
     
     
      case 3:
    {

        client_print(0, print_chat, "It worked!")
    }
   
}
}
}



Raddish 08-07-2010 15:22

Re: BothTeams by cvar
 
PHP Code:

public cmdShow(id) { 
    new 
team
    if(
get_pcvar_num(cvar)) { 
        
team 1
    } 
    else if(
get_pcvar_num(cvar) == 2) { 
        
team 2
    } 
    else if(
get_pcvar_num(cvar) == 3) { 
        
team 0
    } 

-->
PHP Code:

public cmdShow(id) {
    
team get_pcvar_num(cvar)
    } 


Devil259 08-07-2010 15:35

Re: BothTeams by cvar
 
I think you have to do this :

PHP Code:

if(get_user_team(id) == team

:arrow:

PHP Code:

if( ( get_user_team(id) ) == team

Not tested.

Raddish 08-07-2010 15:50

Re: BothTeams by cvar
 
Use cs_get_user_team

Ex3cuTioN 08-08-2010 02:37

Re: BothTeams by cvar
 
PHP Code:

public cmdShow(id) { 
    new 
team
    if(
get_pcvar_num(cvar)) { 
        
team 1
    } 
    else if(
get_pcvar_num(cvar) == 2) { 
        
team 2
    } 
    else if(
get_pcvar_num(cvar) == 3) { 
        
team 0
    } 

:arrow:
PHP Code:

new team get_pcvar_num(cvar); 

Thank you for that.

nikhilgupta345:I want that command to be user only for 1(T's) 2(CT's) 3(both team).The message is showed to "id" not to all players from his team.

EDIT:

I think i found the solution :D

PHP Code:

#include <amxmodx>

new cvar;

public 
plugin_init() {
    
cvar register_cvar("amx_show_team","3");
    
/*
        1 - only t
        2 - only ct
        3 - both
    */
    
register_clcmd("say /message","cmdShow");
}

public 
cmdShow(id) {
    new 
team get_pcvar_num(cvar);
    new 
team_c get_user_team(id);
    
    if(
team == 3) {
        
client_print(id,print_chat,"It worked for both teams");
    }
    else if(
team_c == team) {
        
client_print(id,print_chat,"It worked for 1 specified team");
    }
    
    if(
team_c !=team) {
        switch(
team) {
            case 
1:
            {
                if(
team_c == 1) {
                    return 
PLUGIN_HANDLED;
                }
                
client_print(id,print_chat,"You must be T");
            }
            case 
2:
            {
                if(
team_c == 2) {
                    return 
PLUGIN_HANDLED;
                }
                
client_print(id,print_chat,"You must be CT");
            }
        }
    }
    return 
PLUGIN_CONTINUE;


I'm testing now, i'll be back with reply.

EDIT2 : IT worked :D thank you ex3cution :mrgreen:


All times are GMT -4. The time now is 00:10.

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