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

Menu, Give 2 flashbangs.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shirospyro
Junior Member
Join Date: Dec 2011
Location: Brunei
Old 12-25-2011 , 23:12   Menu, Give 2 flashbangs.
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "Commands"
#define AUTHOR "shiro"
#define VERSION "1.0"
#define PREFIX "[Y-Peace Brunei Gaming Clan]"

// Public Function
public plugin_init()
{
    
register_clcmd"say /help""Help" ) ;
    
register_clcmd"say /special""Special" ) ;
    
register_clcmd"say /noclip""NoClip" ) ;
}

public 
Help(id)
{
    if(
is_user_alive(id))
    {
        
client_print(idprint_chat,"%s Type /special or /noclip"PREFIX ) ;
    }
}

public 
Special(id)
{
    if(
is_user_alive(id))
    {
        
client_print(idprint_chat,"%s You just got your special package!"PREFIX ) ;
        
set_user_health(id200) ;
        
set_user_armor(id200) ;
        
give_item(id"weapon_awp") ;
        
give_item(id"weapon_ak47") ;
        
give_item(id"weapon_deagle") ;
        
give_item(id"weapon_m4a1") ;
        
cs_set_user_bpammo(idCSW_AWP90) ;
        
cs_set_user_bpammo(idCSW_AK4790) ;
        
cs_set_user_bpammo(idCSW_DEAGLE35) ;
        
cs_set_user_bpammo(idCSW_M4A190) ;
        
give_item(id"weapon_hegrenade") ;
        
give_item(id"weapon_smokegrenade") ;
        
give_item(id"weapon_flashbang") ;
        
    }
}

public 
NoClip(id)
{
    if(
get_user_noclip(id))
    {
        
client_print(idprint_chat,"%s You disabled NoClip!"PREFIX );
        
set_user_noclip(id0) ;
    }
    else
    {
        
client_print(idprint_chat,"%s You enabled NoClip!"PREFIX );
        
set_user_noclip(id1) ;
    }

How do I give the user 2 flashbangs?

Do I have to make two lines for it like this,
PHP Code:
give_item(id"weapon_flashbang") ;
give_item(id"weapon_flashbang") ; 
or is it possible to do this,
PHP Code:
give_item(id"weapon_flashbang""2"
And can you please teach me how to make a simple menu where all players can access to it. Sorry I'm new to Pawn studio. Hope you guys could make it simple.

Last edited by shirospyro; 12-25-2011 at 23:25.
shirospyro is offline
Send a message via MSN to shirospyro Send a message via Skype™ to shirospyro
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 12-25-2011 , 23:39   Re: Menu, Give 2 flashbangs.
Reply With Quote #2

Use the first method.

Simple menu:
PHP Code:
#include <amxmodx>

 
public plugin_init()
 {
    
//..stuff for your plugin

    
register_clcmd"my_awesome_menu","AwesomeMenu");
    
//note that we do not need to register the menu anymore, but just a way to get to it
 
}
 
//lets make the function that will make the menu
 
public AwesomeMenu(id)
 {
    
//first we need to make a variable that will hold the menu
    
new menu menu_create("\rLook at this awesome Menu!:""menu_handler");
    
//Note - menu_create
    //The first parameter  is what the menu will be titled (what is at the very top)
    //The second parameter is the function that will deal/handle with the menu (which key was pressed, and what to do)

    //Now lets add some things to select from the menu
    
menu_additem(menu"\wI'm Selection #1""1"0);
    
menu_additem(menu"\wI'm Selection #2""2"0);
    
menu_additem(menu"\wI'm Secret Selection #3""3"ADMIN_ADMIN);
    
//Note - menu_additem
    //The first parameter is which menu we will be adding this item/selection to
    //The second parameter is what text will appear on the menu (Note that it is preceeded with a number of which item it is)
    //The third parameter is data that we want to send with this item
    //The fourth parameter is which admin flag we want to be able to access this item (I have had no experience with this, so I am just assuming this is how it works. It uses the admin flags from the amxconst.inc)

    //Set a property on the menu
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
//Note - menu_setprop
    //The first parameter is the menu to modify
    //The second parameter is what to modify (found in amxconst.inc)
    //The third parameter is what to modify it to (in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option)

    //Lets display the menu
    
menu_display(idmenu0);
    
//Note - menu_display
    //The first parameter is which index to show it to (you cannot show this to everyone at once)
    //The second parameter is which menu to show them (in this case, the one we just made)
    //The third parameter is which page to start them on
 
}
 
//okay, we showed them the menu, now lets handle it (looking back at menu_create, we are going to use that function)
 
public menu_handler(idmenuitem)
 {
    
//we don't want to deal with them if they exited a menu
    
if( item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
//Note that you will want to destroy the menu after they do something
        
return PLUGIN_HANDLED;
    }

    
//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
    
new data[6], szName[64];
    new 
accesscallback;
    
//heres the function that will give us that information (since it doesnt magicaly appear)
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    
//Note - that you can do this next step how you want, this is just the way I prefer

    //looking back to menu_additem, we sent data with every item we added, this is where it gets a little fishy for us (where you can do your own method)
    
new key str_to_num(data);
    
//note that all my datas were numbers (you can do it with whatever type of string you want)

    //now lets find which item was pressed
    
switch(key)
    {
        case 
1:
        {
            
client_print(idprint_chat"Hooray! You selected the Awesome 1st Selection");
            
//note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
2:
        {
            
client_print(idprint_chat"OH NO! You selected the Awesome 2nd Selection! BEWARE!");
        }
        case 
3//again i don't have experience with the admin limitations, so i don't know if you need to have a check before this (im assuming you don't though ^_^)
        
{
            
client_print(idprint_chat"You have selected the Awesome Admin Selection! Hail Teh Bail!");
        }
    }

    
//lets finish up this function with a menu_destroy, and a return
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 } 
__________________
kramesa is offline
keyblade
Member
Join Date: Nov 2010
Location: China
Old 12-26-2011 , 00:49   Re: Menu, Give 2 flashbangs.
Reply With Quote #3

try this

PHP Code:
give_item(id"weapon_flashbang")
cs_set_user_bpammo(idCSW_FLASHBANG2
keyblade is offline
shirospyro
Junior Member
Join Date: Dec 2011
Location: Brunei
Old 12-26-2011 , 02:16   Re: Menu, Give 2 flashbangs.
Reply With Quote #4

I appreciate your reply, anyway, Kramesa,

What does the \r do in
PHP Code:
new menu menu_create("\rLook at this awesome Menu!:""menu_handler"); 
... and also the \w in
PHP Code:
menu_additem(menu"\wI'm Selection #1""1"0); 
And thanks for your guide in creating the menu.
shirospyro is offline
Send a message via MSN to shirospyro Send a message via Skype™ to shirospyro
shirospyro
Junior Member
Join Date: Dec 2011
Location: Brunei
Old 12-26-2011 , 02:20   Re: Menu, Give 2 flashbangs.
Reply With Quote #5

Quote:
Originally Posted by keyblade View Post
try this

PHP Code:
give_item(id"weapon_flashbang")
cs_set_user_bpammo(idCSW_FLASHBANG2
Ah, it works! thanks.
shirospyro is offline
Send a message via MSN to shirospyro Send a message via Skype™ to shirospyro
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 12-26-2011 , 02:50   Re: Menu, Give 2 flashbangs.
Reply With Quote #6

Quote:
Originally Posted by shirospyro View Post
I appreciate your reply, anyway, Kramesa,

What does the \r do in
PHP Code:
new menu menu_create("\rLook at this awesome Menu!:""menu_handler"); 
... and also the \w in
PHP Code:
menu_additem(menu"\wI'm Selection #1""1"0); 
And thanks for your guide in creating the menu.
The \r means red, the \w means white.
Would've been better if he simply posted you the whole tutorial.
http://forums.alliedmods.net/showthread.php?t=46364
Erox902 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 09:28.


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