AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ Solved ] Problèm with a code (https://forums.alliedmods.net/showthread.php?t=185076)

Aooka 05-12-2012 12:53

[ Solved ] Problèm with a code
 
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 ^^

<VeCo> 05-12-2012 12:55

Re: Problèm with a code
 
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"


fysiks 05-12-2012 12:56

Re: Problèm with a code
 
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.

Aooka 05-12-2012 12:58

Re: Problèm with a code
 
no ... :D It is exactly what VecO say :)

Thanks a lot :D

Aooka 05-12-2012 13:12

Re: Problèm with a code
 
I dont understand : new data[6], szName[64];

why 6 in data and 64 in szName ?

Thanks

<VeCo> 05-12-2012 13:37

Re: Problèm with a code
 
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.

Aooka 05-12-2012 16:38

Re: Problèm with a code
 
Thank you very much Veco. :D


All times are GMT -4. The time now is 00:24.

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