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

online players menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arrow123
Member
Join Date: Apr 2014
Location: India
Old 06-12-2014 , 13:44   online players menu
Reply With Quote #1

hello i m making a shop system in which i need a code when a player type /players he get the list of online players[dead and alive] in menu. also when the number against player is hit then function must be executed . like giving xp to that player.
__________________
There is nothing to see here..

Last edited by Arrow123; 06-12-2014 at 14:08.
Arrow123 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-12-2014 , 16:42   Re: online players menu
Reply With Quote #2

Here is the code to loop trough all connected players and use the index of the chosen one.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "x"

new target[33]


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("test""cmdtest")
}

public 
cmdtest(id)
{
    new 
menu menu_create("All Players On Server""handler")
    
    new 
playerplayers32 ], numname[32]
    
get_playersplayersnum"ch" )
    for ( new 
0numi++ )
    {
        
player players[i]
        
get_user_name(playernamecharsmax(name))
        
menu_additem(menuname""0)
    }
    
menu_display(idmenu0)
    
//That's the way you loop through the connected players and make the menu with them
}

public 
handler(idmenuitem)
{
    if(
item == MENU_EXIT || !is_user_connected(id))
        return
        
    new 
key item 1
    
    target
[id] = key
}

public 
otherfunction(id)
{
    
//Here you can use the id's target chosen above. 
    //Like just your index is target[id] and that's all
    //You can assign it to a new variable in the current function if you want

Really didn't test, because didn't have server to do it, and my podbots bugged... There could be some mistakes, but I think that's the way to get target index from menu. You may reply with the results from the tests.
__________________

Last edited by Flick3rR; 06-13-2014 at 03:00.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2014 , 16:48   Re: online players menu
Reply With Quote #3

You can find an example of a players menu in the "AMXX New Menus" tutorial.
__________________
fysiks is offline
Arrow123
Member
Join Date: Apr 2014
Location: India
Old 06-12-2014 , 23:10   Re: online players menu
Reply With Quote #4

replace
PHP Code:
    for ( new 0pnumi++ ) 
with
PHP Code:
    for ( new 0numi++ ) 
and the menu works perfectly.

but how to assign function to it.
here is the example:
type test menu opens

1.player
2.player2
3.player3

when i press 3

i should be printed in my chat [only mine] that

player3 has 500 xp.
__________________
There is nothing to see here..
Arrow123 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-13-2014 , 03:01   Re: online players menu
Reply With Quote #5

Use the target[id] index. Taht's why we got it from the menu, so we can use it in other function as it is saved in a global variable. I don't know which plugin do you use for that XP mod and what natives do you have with it, but this is the index needed.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-13-2014 , 05:19   Re: online players menu
Reply With Quote #6

Quote:
Originally Posted by Flick3rR View Post
Use the target[id] index. Taht's why we got it from the menu, so we can use it in other function as it is saved in a global variable. I don't know which plugin do you use for that XP mod and what natives do you have with it, but this is the index needed.
Players index can change when players leave and connect in server it's always best to use userid instead.
__________________
Blizzard_87 is offline
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 07:17.


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