AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Execute function on selected player (https://forums.alliedmods.net/showthread.php?t=135473)

sombrilla 08-16-2010 15:00

Execute function on selected player
 
I have a menu where all online players are shown, and when i select one instead of executing the function into him, its executed on all players... how do i solve this?

heres the code

PHP Code:

public regalar(id){
    
    new 
temp1[32]
    new 
temp2[2]
    new 
Menu menu_create("XXXX:","regalarhndlr")  
    
    for (new 
1<= get_maxplayers(); i++)
    {
        if (
is_user_connected(i))
        {
            
get_user_name(i,temp1,32);
            
num_to_str(i,temp2,2);
            
menu_additem(Menutemp1,temp2);
        }
    }
    
menu_display(idMenu0);  
}

public 
regalarhndlr(idMenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    static 
name[33]
    
get_user_name(idnamesizeof name -1)
    
menu_item_getinfo(MenuitemiAccessiData5iName63iCallback)
    
    if(
cs_get_user_money(id) >= 5000)
    {
        
cs_set_user_money(idcs_get_user_money(id) - 5000)
        
client_print(id,print_chat,"XXXX %s"iName)  
        for (new 
1<= get_maxplayers(); i++)
        {
            if (
is_user_connected(i))
            {
                
client_print(iprint_chat"%s XXXX",name)  
                
funcion[i]++
            }
        }
    }
    else
        
client_print(idprint_center"No tienes suficiente dinero")
    
    return 
PLUGIN_HANDLED



naven 08-16-2010 18:20

Re: Execute function on selected player
 
1. always show whole code
2. read about register_concmd

sombrilla 08-16-2010 19:02

Re: Execute function on selected player
 
I fixed it, close please...


All times are GMT -4. The time now is 22:00.

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