Raised This Month: $ Target: $400
 0% 

[ Solved ] Problèm with a code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-12-2012 , 12:53   [ Solved ] Problèm with a code
Reply With Quote #1

Hello everyone,
I have a question for you about it :

Code:
new data[6], szName[64]; new access, callback; menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);

So ... Hum i dont understand that ... It is important to create a "player menu" ...
I found these lines just here : http://forums.alliedmods.net/showthr...highlight=Menu ( second menu )

I'm a big beginner in the world of coding so please can you help me

Thanks ^^
__________________
Pawn ? Useless
Aooka is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-12-2012 , 12:55   Re: Problèm with a code
Reply With Quote #2

PHP Code:
/**
 * Retrieves info about a menu item.
 *
 * @param menu   Menu resource identifier.
 * @param item   Item identifier.
 * @param access  Variable to store access value.
 * @param info   Buffer to store item info.
 * @param infolen  Item info buffer length.
 * @param name   Buffer to store item display text.
 * @param namelen  Item name buffer length.
 * @param callback  Callback ID.
 * @return    1 on success, 0 on failure.
 * @error    Invalid menu resource.
 */
native menu_item_getinfo(menuitem, &accessinfo[], infolenname[]=""namelen=0, &callback); 
PHP Code:
menu_additem(menu,"This is name","This is info"
__________________
<VeCo> is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-12-2012 , 12:56   Re: Problèm with a code
Reply With Quote #3

So, what is your question? The examples in that tutorial are well documented and show exactly how to make a player menu. If you have a question about why something is the way it is in the tutorial (and it's not already explained in the tutorial) then ask in that thread.
__________________
fysiks is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-12-2012 , 12:58   Re: Problèm with a code
Reply With Quote #4

no ... It is exactly what VecO say

Thanks a lot
__________________
Pawn ? Useless
Aooka is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-12-2012 , 13:12   Re: Problèm with a code
Reply With Quote #5

I dont understand : new data[6], szName[64];

why 6 in data and 64 in szName ?

Thanks
__________________
Pawn ? Useless
Aooka is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-12-2012 , 13:37   Re: Problèm with a code
Reply With Quote #6

It's depending on the size of menu strings, it's good to keep them lowest as you can. In the tutorial they are a little bit higher... it's not really important, but it's good to keep memory low.
If you have something like this:

PHP Code:
menu_additem(menu,"Option","1"
Then it's better to set maximum characters of data to 2, because it contains only 1 character (you don't need more slots..., string "1" is 1 character, but it's lenght is 2 (0 + 1 reserved = 2)) and szName should be 7, because Option is 7 characters long (6 + 1 reserved). So it's good to keep these numbers as the size of the longest option strings. If we have another option that is longer than "Option" then it's better to write it's lenght and if you have a longer string as menu info, like -1, 10, 200, 1000 and so on, you can do the same with the data variable.

But it won't be a big problem if you leave them higher, like in the tutorial.
__________________

Last edited by <VeCo>; 05-12-2012 at 13:39.
<VeCo> is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-12-2012 , 16:38   Re: Problèm with a code
Reply With Quote #7

Thank you very much Veco.
__________________
Pawn ? Useless
Aooka 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 00:24.


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