AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Not giving weapon! (https://forums.alliedmods.net/showthread.php?t=187544)

CarbonDioxide 06-14-2012 14:49

Not giving weapon!
 
I have this:
PHP Code:

register_clcmd("say /random""cmd_random"

PHP Code:

public cmd_random(player)
{    
    new 
players[32], numplayer;
    
get_playersplayersnum"a" );
    
    for( new 
0numi++ )
    {
        
player players[i];
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_T:
            {
                 
//Do some stuff   
            
}            
            case 
CS_TEAM_CT:
            {
                
//Some stuff
                
give_item(player"weapon_glock18");
            }
        }
    }


When the command is executed the terrorist part of the switch is executed without any problem, but the ct part just won't work for some reason. What am I doing wrong ?

*The function can only be excecuted when there is only one T alive, and only by this one T.

Exolent[jNr] 06-14-2012 15:02

Re: Not giving weapon!
 
You should show the full code. There could be things that you removed which would be causing the problem.

Also, I noticed you create a new "player" variable even though one is already passed to the function.
Rename the one in the function header so they aren't confused.

CarbonDioxide 06-14-2012 15:31

Re: Not giving weapon!
 
PHP Code:

public random(idplayer)
    {
        
formatex(optioncharsmax(option), "%L"LANG_SERVER"UJBM_MENU_LASTREQ_SEL2"dst)
    
        new 
players[32], numplayer;
        
get_playersplayersnum"a" );
        
        for( new 
0numi++ )
        {
            
player players[i];
            
            
server_cmd("jb_block_weapons")
            
player_strip_weapons_all()
                            
            switch(
cs_get_user_team(player))
            {
                case 
CS_TEAM_T:
                {
                    
set_user_health(player1);
                    
give_item(player"weapon_ak47");
                    
cs_set_user_bpammo(playerCSW_AK47200);
                    
set_user_rendering(playerkRenderFxGlowShell000kRenderTransAlpha15);
                }            
                case 
CS_TEAM_CT:
                {
                    
set_user_health(player100);
                    
give_item(player"weapon_glock18");
                    
cs_set_user_bpammo(playerCSW_GLOCK18120)
                }
            }
        }
    } 


Exolent[jNr] 06-14-2012 15:36

Re: Not giving weapon!
 
PHP Code:

public random(idplayer

What are you even doing? Remove player.


PHP Code:

            server_cmd("jb_block_weapons")
            
player_strip_weapons_all() 

Move these to outside the loop.

CarbonDioxide 06-14-2012 15:50

Re: Not giving weapon!
 
That actually worked. Silly of me.. Ty alot !


All times are GMT -4. The time now is 06:13.

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