Raised This Month: $ Target: $400
 0% 

AMXX Mod begginer problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wnn
New Member
Join Date: Apr 2005
Old 04-07-2005 , 05:32   AMXX Mod begginer problem.
Reply With Quote #1

Hey, I've been learning PASCAL for the last three years, and I decided it's about time I'll made some plugins I've always wanted to see for the HL-Engine.

So, i read almost all of the doc on the site, and started scripting.

I ran into a problem with the menu tutorial, infact not a problem, I just don't understand some of the code there. Let me show you what i mean..

(The link if you want to take a look at the whoel tutorial:
http://www.amxmodx.org/doc/source/sc...nced.htm#menus )

Code:
//The clcmd function will just give us the player id
public showWeaponMenu(id)
{
    new menu[192]
    new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2

    format(menu, 191, "Which Weapon?^n^n1. AK47^n2. M4A1^n3. AWP")
    show_menu(id, keys, menu)
    return PLUGIN_HANDLED
}

//Our menu function will get the player id and the key they pressed
public giveWeapon(id, key)
{
    //key will start at zero
    if (key == 0)
    {
         give_item(id, "weapon_ak47")
    } else if (key == 1) {
         give_item(id, "weapon_m4a1")
    } else if (key == 2) {
         give_item(id, "weapon_awp")
    }
}
Ok, so the tutorial has this bit of code in it, and i just want to clearify some things.

new menu[192]: What does this Variable do ? Why 192 ? It wasn't explained in the tutorial.

format(menu, 191, "Which Weapon?^n^n1. AK47^n2. M4A1^n3. AWP"): menu, and 191, why ? What does menu do here ? Why 191 ?
And I'd be glad if you could explain the whole format function for me, however that's not very important.

show_menu(id, keys, menu): Why does he call that function ? I see it nowhere in the program, if it's a core function (probably is) care to explain what "menu" has to do with it ?

public giveWeapon(id, key): How is it called ? I see it called nowhere.. And if its called and i somehow missed that, how does it get its id and key ?

Thanks alot,

wnn.
wnn is offline
wnn
New Member
Join Date: Apr 2005
Old 04-07-2005 , 05:48  
Reply With Quote #2

I couldn't seem to edit my post, sorry for double posting.

I realised my first two questions (oh boy i feel dumb ;) ):

Quote:
new menu[192]: What does this Variable do ? Why 192 ? It wasn't explained in the tutorial.

format(menu, 191, "Which Weapon?^n^n1. AK47^n2. M4A1^n3. AWP"): menu, and 191, why ? What does menu do here ? Why 191 ?
And I'd be glad if you could explain the whole format function for me, however that's not very important.
About the other two - I'd be glad if you could help.

Edit: I seem to be able to edit now..
wnn is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-07-2005 , 07:00  
Reply With Quote #3

show_menu(id, keys, menu)
Actually shows the menu. id is the id of the player. keys is a bitmask of the keys he can press. menu is the menu body, which the plugin has constructed in the format() line.

I'd bet that in public plugin_init(), the plugin uses a register_menu command and passes
"giveWeapon" as one of the parameter. As the menu body he passes to show_menu contains the other parameter the author gave register_menu, that function will be called when the player presses a key.
__________________
hello, i am pm
PM 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 16:39.


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