PDA

View Full Version : Weapon script


zirualas
06-23-2010, 03:48
Well i don't know where can i find tut or script about weopon giving on menu.
I'm trying to do self vipmenu but i can't give guns or items.
By the way i need to know how add more HP to vip.
And i want how you show me how add admin flag :}

RedRobster
06-23-2010, 06:01
Use give_item() to give weapons.

Use set_user_health() and set_user_armor() from the fun module to set armor and health.

zirualas
06-23-2010, 07:09
One more question then you type Use give_item() in () write usp or something esle?
I try to add script and I dont don't understand how add him. Who can show me how add. Here my all plugin. Emp` tutorial :D
#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
vip meniu = menu_create("\rVip meniu:", "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, "\wMaza gravitacija", "1", 0);
menu_additem(menu, "\wSsss", "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(menu, MPROP_EXIT, MEXIT_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(id, menu, 0);
//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(id, menu, item)
{
//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], iName[64];
new access, callback;
//heres the function that will give us that information (since it doesnt magicaly appear)
menu_item_getinfo(menu, item, access, data,5, iName, 63, 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:
{
set_user_health(150)
}
case 2:
{
client_print(id, print_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(id, print_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;
}

RedRobster
06-23-2010, 08:30
#include <amxmodx>
#include <fun>

new vip_menu

public plugin_init()
{
register_clcmd( "say /vipmenu","VIPMenu");
}

public VIPMenu(id)
{
vip_menu = menu_create("\rVip meniu:", "menu_handler");
menu_additem(vip_menu, "\wMaza gravitacija", "1", 0);
menu_additem(vip_menu, "\wGive USP", "2", 0);
menu_setprop(vip_menu, MPROP_EXIT, MEXIT_ALL);
}

public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;

menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
switch(key)
{
case 1:
{
set_user_health(id, 150); //Sets health of id to 150
set_user_armor(id, 200); //Sets armor of id to 200
}

case 2:
{
give_item(id, "weapon_usp"); //Gives id a USP
give_item(id, "ammo_45acp"); //Gives id USP ammo
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}

Item names for give_item() - http://forums.alliedmods.net/showthread.php?t=35512

One
06-23-2010, 08:40
just use the fucking search

zirualas
06-24-2010, 03:27
Why when I compiling my vipmenu i have error.
//AMXXPC compile.exe
//by the AMX Mod X Dev Team


////bandymas.sma
// D:\Program Files\Valve\cstrike\addons\amxmodx\scripting\ bandymas.sma<72>:error 017: undefined symbol "set_user_healt"

why? plz help me

RedRobster
06-24-2010, 07:44
Why when I compiling my vipmenu i have error.
//AMXXPC compile.exe
//by the AMX Mod X Dev Team


////bandymas.sma
// D:\Program Files\Valve\cstrike\addons\amxmodx\scripting\ bandymas.sma<72>:error 017: undefined symbol "set_user_healt"

why? plz help me

Add a "h" to "healt". It should be "set_user_health".

zirualas
06-24-2010, 10:41
I type like you said but error is same. I don't understond
You give me this code.
PHP Code:
#include <amxmodx>
#include <fun>

new vip_menu

public plugin_init()
{
register_clcmd( "say /vipmenu","VIPMenu");
}

public VIPMenu(id)
{
vip_menu = menu_create("\rVip meniu:", "menu_handler");
menu_additem(vip_menu, "\wMaza gravitacija", "1", 0);
menu_additem(vip_menu, "\wGive USP", "2", 0);
menu_setprop(vip_menu, MPROP_EXIT, MEXIT_ALL);
}

public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;

menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
switch(key)
{
case 1:
{
set_user_health(id, 150); //Sets health of id to 150
set_user_armor(id, 200); //Sets armor of id to 200
}

case 2:
{
give_item(id, "weapon_usp"); //Gives id a USP
give_item(id, "ammo_45acp"); //Gives id USP ammo
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}


Item names for give_item() - http://forums.alliedmods.net/showthread.php?t=35512

I type it. Not found errors. When i add to plugins.ini my vipmenu.amxx I type to server console amx_plugins and me suggest that's plugin don't exist. Well what i can do? Plz HELP!

GXLZPGX
06-24-2010, 11:48
Add a "h" to "healt". It should be "set_user_health".

http://www.threadbombing.com/data/media/20/17-I-lol.jpg

zirualas
06-24-2010, 11:58
Plz help me, don't lougt :nono:

One
06-24-2010, 12:03
:)

#include <amxmodx>
#include <fun>

new vip_menu

public plugin_init()
{
register_clcmd( "say /vipmenu","VIPMenu");
}

public VIPMenu(id)
{
vip_menu = menu_create("\rVip meniu:", "menu_handler");
menu_additem(vip_menu, "\wMaza gravitacija", "1", 0);
menu_additem(vip_menu, "\wGive USP", "2", 0);
menu_setprop(vip_menu, MPROP_EXIT, MEXIT_ALL);
}

public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;

menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
switch(key)
{
case 1:
{
if(is_user_alive(id))
{
set_user_health(id, 150); //Sets health of id to 150
set_user_armor(id, 200); //Sets armor of id to 200
}
}

case 2:
{
if(is_user_alive(id))
{
give_item(id, "weapon_usp"); //Gives id a USP
give_item(id, "ammo_45acp"); //Gives id USP ammo
}
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
} Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Header size: 376 bytes
Code size: 992 bytes
Data size: 420 bytes
Stack/heap size: 16384 bytes; estimated max. usage=87 cells (348 bytes)
Total requirements: 18172 bytes
Done.
Whats your problem?

GXLZPGX
06-24-2010, 12:04
Plz help me, don't lougt :nono:

Typing amx_plugins will only show a certain amount of plugins. Type amx_plugins 11, if you don't see it there, type amx_plugins 21. Keep going up by ten like:

amx_plugins 11
amx_plugins 21
amx_plugins 31

Until you get to a page with no plugins listed. If you don't see your plugin, or you DO see it and it says "BAD LOAD" tell me.

#include <amxmodx>
#include <fun>

public plugin_init()
{
register_clcmd( "say /vipmenu", "VIPMenu" );
register_clcmd( "say_team /vipmenu", "VIPMenu" );
}

public VIPMenu( id )
{
new vip_menu = menu_create( "\rVip meniu:", "menu_handler" );
menu_additem( vip_menu, "\wMaza gravitacija", "1", 0 );
menu_additem( vip_menu, "\wGive USP", "2", 0 );

menu_setprop( vip_menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, vip_menu, 0 );
}

public menu_handler( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;

menu_item_getinfo( menu, item, access, data,5, iName, 63, callback );
new key = str_to_num( data );
switch( key )
{
case 1:
{
if( is_user_alive( id ) )
{
set_user_health( id, 150 ); //Sets health of id to 150
set_user_armor( id, 200 ); //Sets armor of id to 200
}
}
case 2:
{
if( is_user_alive( id ) )
{
give_item( id, "weapon_usp" ); //Gives id a USP
give_item( id, "ammo_45acp" ); //Gives id USP ammo
}
}
}

menu_destroy( menu );
return PLUGIN_HANDLED;
}

Tested this code in my server. Worked fine.

zirualas
06-24-2010, 12:50
Wow. Now it's working. I don't understond. It must be magic :) Thx you guys :up:
Last question, how add admin flag?
And i want how you show me how add admin flag :}

GXLZPGX
06-25-2010, 00:49
Wow. Now it's working. I don't understond. It must be magic :) Thx you guys :up:
Last question, how add admin flag?

Go into your server, and open up console. Type in:

rcon_password yourpassword

Of course change "yourpassword" to your rcon password. After that, type:

rcon amx_addadmin yourname

or:

rcon amx_addadmin yoursteamid

zirualas
06-25-2010, 02:08
I know how add flag but i don't know how add flag in plugin.
Eg another vipmenu require only "bit" flags.

wrecked_
06-25-2010, 02:31
if( !( get_user_flags( id ) & ADMIN_LEVEL_A ) )
{
return;
}

zirualas
06-25-2010, 03:01
Where i need to type it|?
#include <amxmodx>
#include <fun>

public plugin_init()
{
register_clcmd( "say /vipmenu", "VIPMenu" );
register_clcmd( "say_team /vipmenu", "VIPMenu" );
}

public VIPMenu( id )
{
new vip_menu = menu_create( "\rVip meniu:", "menu_handler" );
menu_additem( vip_menu, "\w+55 hp +200Armour", "1", 0 );
menu_additem( vip_menu, "\wMachine gun", "2", 0 );
menu_additem( vip_menu, "\wGravity", "3", 0 );

menu_setprop( vip_menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, vip_menu, 0 );
}

public menu_handler( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;

menu_item_getinfo( menu, item, access, data,5, iName, 63, callback );
new key = str_to_num( data );
switch( key )
{
case 1:
{
if( is_user_alive( id ) )
{
set_user_health( id, 165 ); //Sets health of id to 150
set_user_armor( id, 200 ); //Sets armor of id to 200
client_print(id, print_chat, "\bTavo givybes buvo pripildytos iki 150 ir gavai 200 sarvu.");
}
}
case 2:
{
if( is_user_alive( id ) )
{
give_item( id, "weapon_m249" ); //Gives id a machine gun
give_item( id, "ammo_556natobox" ); //Gives id machine gun ammo
client_print(id, print_chat, "\gTu gavai machinegun'a!");
}
}
case 3:
{
if( is_user_alive( id ) )
{
set_user_gravity(id, 0.68)
client_print(id, print_chat, "\rTavo gravitacija sumazinta, dabar tu supermenas :)");
}
}
}

menu_destroy( menu );
return PLUGIN_HANDLED;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/

GXLZPGX
06-25-2010, 04:02
Where i need to type it?
Try this

public VIPMenu( id )
{
if( get_user_flags( id ) & ADMIN_MENU )
{
new vip_menu = menu_create( "\rVip meniu:", "menu_handler" );
menu_additem( vip_menu, "\w+55 hp +200Armour", "1", 0 );
menu_additem( vip_menu, "\wMachine gun", "2", 0 );
menu_additem( vip_menu, "\wGravity", "3", 0 );

menu_setprop( vip_menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, vip_menu, 0 );
}
}

zirualas
06-25-2010, 04:11
Again, question :D
I can type and type /vipmenu.
How i can do when i type /vipmenu select item and him disapear and when i type /vipmenu show "You have vipmenu privilege, try next round".

---Edited---

Wha's was happened.
http://img696.**************/img696/3919/amadre.th.jpg (http://img696.**************/i/amadre.jpg/)

GXLZPGX
06-25-2010, 05:03
Again, question :D
I can type and type /vipmenu.
How i can do when i type /vipmenu select item and him disapear and when i type /vipmenu show "You have vipmenu privilege, try next round".

---Edited---

Wha's was happened.
http://img696.**************/img696/3919/amadre.th.jpg (http://img696.**************/i/amadre.jpg/)


Try this:

ublic VIPMenu( id )
{
if( get_user_flags( id ) & ADMIN_MENU )
{
new vip_menu = menu_create( "\rVip meniu:", "menu_handler" );
menu_additem( vip_menu, "\w+55 hp +200Armour", "1", 0 );
menu_additem( vip_menu, "\wMachine gun", "2", 0 );
menu_additem( vip_menu, "\wGravity", "3", 0 );

menu_setprop( vip_menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, vip_menu, 0 );
}
else
{
client_print( id, "You don't have access to this menu!" )
}
}

zirualas
06-25-2010, 05:14
So what will this flag?
By the way .
I can type and type /vipmenu.
How i can do when i type /vipmenu select item and him disapear and when i type /vipmenu show "You have vipmenu privilege, try next round

GXLZPGX
06-25-2010, 05:18
So what will this flag?
By the way .

I dont know what your saying.. just use what I gave you.

zirualas
06-25-2010, 05:45
I need use /vipmenu peoples who have flag J.
I find bug. I type /vipmenu and i select +55 hp and +200 armour. I get +55 hp and +200 armours but i write again /vipmenu and i select machinegun. I get it but my +55 hp and +200 armours dpn't disapear.

zirualas
06-25-2010, 13:40
Someone, help me :cry:

One
06-26-2010, 09:48
I need use /vipmenu peoples who have flag J.
I find bug. I type /vipmenu and i select +55 hp and +200 armour. I get +55 hp and +200 armours but i write again /vipmenu and i select machinegun. I get it but my +55 hp and +200 armours dpn't disapear.

Someone, help me :cry:
Dont BUMP

write your request here : Suggestions / Requests (http://forums.alliedmods.net/forumdisplay.php?f=12)