AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   whats wrong here? (https://forums.alliedmods.net/showthread.php?t=159564)

liryck 06-18-2011 23:15

whats wrong here?
 
hello there i got this error from this code im not sure why but it was caus the player wasnt in the server?

[CSTRIKE] Player out of range <0>
[AMXX]run time error 10: native error <native "cs_set_user_team">
[AMXX] [0] yap_menu.sma::random choose <line 690>

code in question

PHP Code:

    if(cap_id == ct_cap && is_user_connected(player) && count_ct 5)
    {
        
cs_set_user_team(playerCS_TEAM_CT)
        
get_user_name(player,name,31)
        
client_print(0,print_chat,"--> %s has been picked for CT Randomly",name)
            
        
count_ct++
        
g_team[player] = KEY_CT;
            
        
check_display_team();
        
check_continue();
            
        
team true
            
        menu_destroy
(real_menu)
        
set_task(0.2,"AwesomeMenu",t_cap)
        return 
PLUGIN_HANDLED;
    }
    else if(
count_ct == 5)
    {
            
cs_set_user_team(playerCS_TEAM_T)//line 690
            
count_t++
            
            
g_team[player] = KEY_T;
            
            
get_user_name(player,name,31)
            
client_print(0,print_chat,"--> %s has been picked for Terrorist Randomly",name)
            
            
menu_destroy(real_menu)
            
set_task(0.2,"AwesomeMenu",t_cap)
            return 
PLUGIN_HANDLED;
    } 


DjOptimuS 06-18-2011 23:35

Re: whats wrong here?
 
i think you tried to print the menu to the id 0, wich is the server itself

fysiks 06-19-2011 01:31

Re: whats wrong here?
 
You need to check if the user is connected for both situations (the if and the else if) but should be checked only once before everything else. However, there may be bigger issues because player should, idealy, never be 0. You will get the best solution by posting the whole code.

liryck 06-19-2011 13:49

Re: whats wrong here?
 
k ty fysiks but well my whole code was the one i told you by pm, and post it in this threat

http://forums.alliedmods.net/showthread.php?t=159193

it does what i want but with some problems like this and others sometime in some specific situation

fysiks 06-19-2011 16:10

Re: whats wrong here?
 
The problem is probably caused here (bad code or lack of code):

PHP Code:

    if(iNum 0)
    {
        
ran random(iNum);
        
iPlayers[ran] = iPlayers[--iNum];
        
player iPlayers[ran];    
    } 


However, you should probably rethink how you do the whole random_choose() function.

liryck 06-19-2011 18:12

Re: whats wrong here?
 
tnx , and so if you understand what im trying to do can help me to redone or an idea for helping me?


All times are GMT -4. The time now is 23:25.

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