Raised This Month: $ Target: $400
 0% 

Execute function on selected player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sombrilla
Veteran Member
Join Date: Apr 2009
Location: Buenos Aires
Old 08-16-2010 , 15:00   Execute function on selected player
Reply With Quote #1

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

__________________

sombrilla is offline
Send a message via MSN to sombrilla
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 08-16-2010 , 18:20   Re: Execute function on selected player
Reply With Quote #2

1. always show whole code
2. read about register_concmd
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
sombrilla
Veteran Member
Join Date: Apr 2009
Location: Buenos Aires
Old 08-16-2010 , 19:02   Re: Execute function on selected player
Reply With Quote #3

I fixed it, close please...
__________________

sombrilla is offline
Send a message via MSN to sombrilla
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 21:59.


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