Raised This Month: $ Target: $400
 0% 

Invalid player 10 | native "cs_get_user_team"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MrKiller2010
Senior Member
Join Date: Aug 2012
Old 09-13-2013 , 09:55   Invalid player 10 | native "cs_get_user_team"
Reply With Quote #1

Code:
L 09/12/2013 - 20:34:24: [CSTRIKE] Invalid player 10
L 09/12/2013 - 20:34:24: [AMXX] Run time error 10 (plugin "Admin_menu.amxx") (native "cs_get_user_team") - debug not enabled!
PHP Code:
public HandleTransfer(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], name[64]
    new 
accesscallback
    
    menu_item_getinfo 
(menuitemaccessdata5name63callback)
    new 
tempid str_to_num (data)
    
    
get_user_name(idszName32)
    
get_user_name(tempidszPlayerName32)
    
    
ColorChat(0GREY"%s ^4%s^3 just transfered ^4%s^3!"prefixszNameszPlayerName)
 if(
cs_get_user_team(tempid) == CS_TEAM_T
    { 
        
cs_set_user_team(tempidCS_TEAM_CT
        
ExecuteHamB(Ham_CS_RoundRespawntempid)  
    }
    if(
cs_get_user_team(tempid) == CS_TEAM_CT)
    {
        
cs_set_user_team(tempidCS_TEAM_T)
        
ExecuteHamB(Ham_CS_RoundRespawntempid)
    }
    
CmdAdminMenu(id)
    
    return 
PLUGIN_CONTINUE

__________________
JailBreak & HNS
MrKiller2010 is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-13-2013 , 10:27   Re: Invalid player 10 | native "cs_get_user_team"
Reply With Quote #2

You are doing it wrong. Tempid is the pressed option from the menu, you should use find_player() with flag k to retrieve the index of the player.

https://forums.alliedmods.net/showth...364#PlayerMenu
__________________




Last edited by dark_style; 09-13-2013 at 10:27.
dark_style is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-13-2013 , 11:49   Re: Invalid player 10 | native "cs_get_user_team"
Reply With Quote #3

There's nothing saying he isn't passing the id in that string, that's what I would do but in integer form in the first cell.
The players probably left between the opening of the menu and when the selection was made.
is_user_connected()fysiks solves the problem, like always...
__________________

Last edited by Black Rose; 09-14-2013 at 15:23.
Black Rose is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-13-2013 , 12:07   Re: Invalid player 10 | native "cs_get_user_team"
Reply With Quote #4

Yes, you are right but he needs to retrieve the id before checking if the player is connected. Sorry, it's my fault that I didn't notice there isn't a check for that.
__________________



dark_style is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-14-2013 , 12:47   Re: Invalid player 10 | native "cs_get_user_team"
Reply With Quote #5

I would not recommend using the entity ID, it can cause a race condition.
  • Player 1 has entity id 1
  • Admin opens menu
  • Player 1 leaves
  • Player 2 joins and is assigned entity id 1
  • Admin chooses Player 1 from the menu
  • Action is performed on Player 2

I would use userid.
__________________
fysiks is offline
Old 09-15-2013, 11:07
Shooting King
This message has been deleted by Shooting King.
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 19:12.


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