AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invalid player 10 | native "cs_get_user_team" (https://forums.alliedmods.net/showthread.php?t=226075)

MrKiller2010 09-13-2013 09:55

Invalid player 10 | native "cs_get_user_team"
 
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



dark_style 09-13-2013 10:27

Re: Invalid player 10 | native "cs_get_user_team"
 
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

Black Rose 09-13-2013 11:49

Re: Invalid player 10 | native "cs_get_user_team"
 
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...

dark_style 09-13-2013 12:07

Re: Invalid player 10 | native "cs_get_user_team"
 
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. :bee:

fysiks 09-14-2013 12:47

Re: Invalid player 10 | native "cs_get_user_team"
 
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.


All times are GMT -4. The time now is 19:12.

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