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

Question Menu [Ask Menu]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Baws
Veteran Member
Join Date: Oct 2012
Old 05-25-2014 , 10:00   Question Menu [Ask Menu]
Reply With Quote #1

I need a menu where you can select 2 options: Sell 5points and Sell 10points

After that, a menu with all the players in the server to select to whom im selling those points.
When i click on the players name, he will have a menu saying accept or decline that my name
is selling him 5points or 10points.

Then, if he accepts it will add on him 5points and removes from me 5points but i will win for example
5k$.

Thanks.

EDIT: nvm done!
__________________
Like my clean plugins and work?

Last edited by Baws; 05-25-2014 at 11:07.
Baws is offline
killer999
Senior Member
Join Date: Dec 2013
Location: India
Old 06-25-2014 , 04:13   Re: Question Menu [Ask Menu]
Reply With Quote #2

No reply xD heheheh
__________________
killer999 is offline
Send a message via Skype™ to killer999
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-25-2014 , 04:42   Re: Question Menu [Ask Menu]
Reply With Quote #3

Then, you should post here for others peoples that need this too. Anyway, I'll leave here how it should be done ( as I think ).

PHP Code:
#include < amxmodx >

new boolg_Points 33 ] [ ]

new 
g_szName 33 ]

public 
plugin_init ( ) {
    
    
register_plugin "Menu" "0.1" "HamletEagle" )
    
register_clcmd "say /menu" "ClCmdMenu" )
    
}

public 
ClCmdMenu id ) {
    
    new 
menu menu_create("Sell Points""Handler_SellPoints");
    
    
menu_additem(menu"Sell 5  Points"""0)
    
menu_additem(menu"Sell 10 Points"""0)
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_setprop(menuMPROP_NOCOLORS1)
    
    
menu_display(idmenu0)
    
    return 
PLUGIN_HANDLED;
    
}

public 
Handler_SellPoints(idmenuitem) {
    
    if(
item == MENU_EXIT)
    {
        
menu_destroy(id)
        return 
PLUGIN_HANDLED
    
}
    
    new 
command[6], name[64], accesscallback;
    
    
menu_item_getinfo(menuitemaccesscommandsizeof command ) - 1namesizeof name ) - 1callback);
    
    switch ( 
item )
    {
        case 
0: {
            
            
g_Points id ] [ ]  = true
            ChoosePlayer 
id )
        }
        
        case 
1: { 
            
            
g_Points id ] [ ]  = true
            ChoosePlayer 
id )
            
        }
        
    }
    
    
get_user_name id g_szName sizeof g_szName ) -)
    
    
menu_destroy(menu);
    
    return 
PLUGIN_HANDLED;
    
}

public 
ChoosePlayer  id ) {
    
    new 
menu2 menu_create"Choose a  player to transfer points:""Handler_PlayersMenu" );
    
    static 
iPlayers32 ] , iPlayersNumindexi    
    
new szName[32], szUserId[32]
    
    
get_playersiPlayers,iPlayersNum"c" )    
    
    if( !
iPlayersNum 
        return
    
    for( 
0iPlayersNumi++ ) 
    { 
        
index iPlayers]
        
        
get_user_nameindexszNamesizeofszName ) -1  )
        
formatexszUserIdsizeof szUserId ) -"%d"get_user_useridid ) )
        
        
menu_additemmenu2szNameszUserId)
        
    }
    
    
menu_displayidmenu2);
    
}

public 
Handler_PlayersMenu idmenu2item )
{
    
    if ( 
item == MENU_EXIT )
    {
        
menu_destroymenu2 );
        return 
PLUGIN_HANDLED;
    }
    
    new 
szData ] , szName 64 ],item_accessitem_callback;
    
menu_item_getinfomenu2 item item_access szData sizeofszData ) - 1szName sizeof szName ) -item_callback );
    
    new 
UserId str_to_numszData )
    
    
    new 
Target find_player"k"UserId )
    
    
    if ( 
Target )
    {
        
DisplayAcceptMenu Target )
    }
    
    
menu_destroymenu2 );
    return 
PLUGIN_HANDLED;
}

public 
DisplayAcceptMenu id ) {
    
    new 
szMenuTitle 256 ]
    
formatex szMenuTitle sizeof szMenuTitle ) - "Accept %i points from %s"g_Points id ] [ ] ? "5" "10"g_szName 
    
    
    new 
menu3 menu_createszMenuTitle "Handler_AcceptPoints");
    
    
menu_additem(menu3"Accept"""0); 
    
menu_additem(menu3"Refuse"""0); 
    
    
menu_setprop(menu3MPROP_EXITMEXIT_ALL);
    
menu_setprop(menu3MPROP_NOCOLORS1);
    
    
menu_display(idmenu30);
    
    return 
PLUGIN_HANDLED;
    
}

public 
Handler_AcceptPoints(idmenu3item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(id);
        return 
PLUGIN_HANDLED;
    }
    
    new 
command[6], name[64], accesscallback;
    
    
menu_item_getinfo(menu3itemaccesscommandsizeof command 1namesizeof name 1callback);
    
    switch(
item)
    {
        case 
0: {
            
            
//id is the target index    
            //remove x points from first player
            //add x points to target
            //if ( g_Points [ index ][ 0 ] ) Points += 5 if ( g_Points [ index ] [ 1 ] ) Points += 10
            //give money reward to first player
        
}
        
        case 
1: {
            
            
//player refused, tell first player that target refused
            
return 1;
            
        }
    }
    
    
menu_destroy(menu3);
    
    return 
PLUGIN_HANDLED;

Untested, but it should work.

Last edited by HamletEagle; 06-25-2014 at 04:43.
HamletEagle is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-25-2014 , 16:54   Re: Question Menu [Ask Menu]
Reply With Quote #4

Only problem with your code is that global name variable. If more then one person asks opens menu same time that name variable will be set to the last persons name who sent the request.

Code:
new g_szName [ 33 ]
To
Code:
new g_szName [ 33 ][ 32 ]

Then just edit the formating for that name variable.
__________________

Last edited by Blizzard_87; 06-25-2014 at 16:57.
Blizzard_87 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-26-2014 , 03:21   Re: Question Menu [Ask Menu]
Reply With Quote #5

Quote:
Originally Posted by Blizzard_87 View Post
Only problem with your code is that global name variable. If more then one person asks opens menu same time that name variable will be set to the last persons name who sent the request.

Code:
new g_szName [ 33 ]
To
Code:
new g_szName [ 33 ][ 32 ]

Then just edit the formating for that name variable.
Ah, missed that. Will update it.
HamletEagle 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 05:26.


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