Raised This Month: $ Target: $400
 0% 

Saving text of item in the menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 03-19-2011 , 14:34   Saving text of item in the menu
Reply With Quote #1

I've made a menu with the new menu system. I want to make a money menu, where you first select the amount of money, example:

Choosable money:

1. 250
2. 500
3. 800
4. 1000
5. 4000
6. 7000
7. 10000
8. 13000
9. 16000


And after the money got pressed, I am showing a menu where the selected players are, how can I save the amount of money then?
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-19-2011 , 17:45   Re: Saving text of item in the menu
Reply With Quote #2

Use a gobal variable . . .
__________________
fysiks is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 03-19-2011 , 19:41   Re: Saving text of item in the menu
Reply With Quote #3

Can you show me how?
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-19-2011 , 23:36   Re: Saving text of item in the menu
Reply With Quote #4

Quote:
Originally Posted by bibu View Post
Can you show me how?
. . . .

Code:
new global_variable[33]

// ...
// menu handler
global_variable[id] = str_to_num(data)
// ...
// Where ever you need to retrieve the value
global_variable[id] // contains the number saved previously
__________________

Last edited by fysiks; 03-19-2011 at 23:38.
fysiks is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 03-20-2011 , 07:20   Re: Saving text of item in the menu
Reply With Quote #5

PHP Code:
public menu_handler_money_menu(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[6], iName[64]
    new 
accesscallback

    menu_item_getinfo
(menuitemaccessdata5iName63callback)

    new 
key str_to_num(data)

    switch(
key)
{
    case 
123456789:
    {
        
g_money[id] = str_to_num(data)
    }
}
    
menu_destroy(menu)
    
MoneyplayerMenu(id)
    return 
PLUGIN_HANDLED

After choosing the player with this:

PHP Code:
cs_set_user_money(targetidg_money[id]) 
It gives weird amount of money.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-20-2011 , 07:36   Re: Saving text of item in the menu
Reply With Quote #6

Code:
    new key = str_to_num(data)     switch(key) {     case 1, 2, 3, 4, 5, 6, 7, 8, 9:     {         g_money[id] = str_to_num(data)     } }

How do you think that str_to_num(data) can one time return 1 to 9 and the other time return some money amount ???

data contains money amount if i'm right, so forget the new menu tutorial and use item value instead of the "key = str_to_num" system, instead of checking item == MENU_EXIT at first, just check if item is <0, then you can retrieve money amount safely.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 03-20-2011 , 07:48   Re: Saving text of item in the menu
Reply With Quote #7

I don't really know much or understand the old menu system. Can you show me how to hold the amount of the money then?
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-20-2011 , 08:00   Re: Saving text of item in the menu
Reply With Quote #8

I don't say you to use old menu, i say to use new menu but forget the way key is retrieved (tutorial is really good and helpfull but that part should never have been put in it i guess).

So just pass money amount in item info like you do, but don't try to get the key with that data because obviously data doesn't contain key but money.
So use item instead of key.

key : 1 to 9 (or more)
item : 0 to 8 (or more)

MENU_EXIT, MENU_NEXT and MENU_BACK (if names are correct) are all negative values.

If you don't understand what was said in that post and in previous posts, than you should stick with more basic plugins.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 03-20-2011 , 09:04   Re: Saving text of item in the menu
Reply With Quote #9

Oh ok. Do you mean something like this:

PHP Code:
g_money[id] = str_to_num(data)

-->
g_money[id] = str_to_num(item
Then check if item is MENU_EXIT, MENU_NEXT and MENU_BACK. I tried to find some plugins which use something like this, but I couldn't find something.
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-20-2011 , 14:55   Re: Saving text of item in the menu
Reply With Quote #10

Quote:
Originally Posted by bibu View Post
Oh ok. Do you mean something like this:

PHP Code:
g_money[id] = str_to_num(data)

-->
g_money[id] = str_to_num(item
Then check if item is MENU_EXIT, MENU_NEXT and MENU_BACK. I tried to find some plugins which use something like this, but I couldn't find something.
Just use

PHP Code:
g_money[id] = str_to_num(iName)  // iName is not an integer!  Don't use "i" prefix or use "sz" or something not misleading. 
__________________
fysiks 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 14:36.


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