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

whats wrong here?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 06-18-2011 , 23:15   whats wrong here?
Reply With Quote #1

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;
    } 
liryck is offline
Send a message via MSN to liryck
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 06-18-2011 , 23:35   Re: whats wrong here?
Reply With Quote #2

i think you tried to print the menu to the id 0, wich is the server itself
DjOptimuS is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-19-2011 , 01:31   Re: whats wrong here?
Reply With Quote #3

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.
__________________
fysiks is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 06-19-2011 , 13:49   Re: whats wrong here?
Reply With Quote #4

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
liryck is offline
Send a message via MSN to liryck
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-19-2011 , 16:10   Re: whats wrong here?
Reply With Quote #5

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.
__________________
fysiks is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 06-19-2011 , 18:12   Re: whats wrong here?
Reply With Quote #6

tnx , and so if you understand what im trying to do can help me to redone or an idea for helping me?
liryck is offline
Send a message via MSN to liryck
Old 06-22-2011, 22:46
liryck
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
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 23:58.


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