VIP拥有多把武器
本帖最后由 xing9634 于 2012-9-8 18:34 编辑该插件由David Peng(点通ID:xing9634)个人在AMXMOX官网下载并
修改,插件版权归原作者GHW_Chronic所有。
权限依然是自定义权限F( r - custom level F)
目前已知的BUG(应该都是原版BUG):
1.买两把微型冲锋枪会买不了,要捡一遍在丢一遍就可以了
2.第2个BUG已经修复,原来是作者打命令的时候手抖了一下,打错了单词,OK,现在已经修复。
cvars以下内容复制到amxx.cfg的最底部!
cvars:
//VIP拥有多把主武器
max_primary 2
max_secondary 1
附件:
源码,你懂的,还有VIP武器加子弹的那个。- - 源码加我QQ+997044136,发源码给我- - 楼主能不能把源码发一下,或者把权限改成自定义权限H( t - custom level H),麻烦楼主了。小弟水平有限,官网的源码找到了,但是不会改。膜拜.. 【【【【【官网的源码】】】】】】
/*
* _______ _ ___ __
*| _____/ | | | | \ \ __ / /
*| | | | | || | /\ | |
*| | | |____| || |/ __ \| |
*| | ___ | ______ || /\ |
*| ||_|| | | ||/ \|
*| | | || | | || | | |
*| |____| || | | || | | |
*|_______/ |_| |_|\_/ \_/
*
*
*
*Last Edited: 01-05-08
*
*============
* Changelog:
*============
*
*v1.0
* -Initial Release
*
*/
#define VERSION "2.0"
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <fakemeta>
new blah
new blah2
new const menu1_weapon_names_T =
{
"weapon_glock18", "400",
"weapon_usp", "500",
"weapon_p228", "600",
"weapon_deagle", "650",
"weapon_elite", "800"
}
new const menu1_weapon_names_CT =
{
"weapon_glock18", "400",
"weapon_usp", "500",
"weapon_p228", "600",
"weapon_deagle", "650",
"weapon_fiveseven", "750"
}
new const menu2_weapon_names_T =
{
"weapon_m3", "1700",
"weapon_xm1014", "3000"
}
new const menu2_weapon_names_CT =
{
"weapon_m3", "1700",
"weapon_xm1014", "3000"
}
new const menu3_weapon_names_T =
{
"weapon_mac10", "1400",
"weapon_mp5navy", "1500",
"weapon_ump45", "1700",
"weapon_p90", "2350"
}
new const menu3_weapon_names_CT =
{
"weapon_tmp", "1250",
"weapon_mp5navy", "1500",
"weapon_ump45", "1700",
"weapon_p90", "2350"
}
new const menu4_weapon_names_T =
{
"weapon_galil", "2000",
"weapon_ak47", "2500",
"weapon_scout", "2750",
"weapon_sg552", "3500",
"weapon_awp", "4750",
"weapon_g3sg1", "5000"
}
new const menu4_weapon_names_CT =
{
"weapon_famas", "2250",
"weapon_scout", "2750",
"weapon_m4a1", "3100",
"weapon_aug", "3500",
"weapon_sg550", "4200",
"weapon_awp", "4750"
}
new const menu5_weapon_names_T =
{
"weapon_m249", "5750"
}
new const menu5_weapon_names_CT =
{
"weapon_m249", "5750"
}
new const keys = 511
new maxplayers
new bool:justdropped
new primcvar, seccvar
public plugin_init()
{
register_plugin("CS Pickup Multiple Weapons",VERSION,"GHW_Chronic")
//Old Style Menus
register_menucmd(register_menuid("BuyPistol",1),keys,"hook_menu1")
register_menucmd(register_menuid("BuyShotgun",1),keys,"hook_menu2")
register_menucmd(register_menuid("BuySub",1),keys,"hook_menu3")
register_menucmd(register_menuid("BuyRifle",1),keys,"hook_menu4")
register_menucmd(register_menuid("BuyMachine",1),keys,"hook_menu5")
//VGUI Menus
register_menucmd(-29,keys,"hook_menu1")
register_menucmd(-30,keys,"hook_menu2")
register_menucmd(-32,keys,"hook_menu3")
register_menucmd(-31,keys,"hook_menu4")
register_menucmd(-33,keys,"hook_menu5")
register_forward(FM_Touch,"FM_Touch_hook")
register_clcmd("drop","dropped")
maxplayers = get_maxplayers()
primcvar = register_cvar("max_primary","3")
seccvar = register_cvar("max_secnodary","3")
}
public dropped(id)
{
justdropped=true
set_task(0.5,"notdropped",id)
}
public notdropped(id) justdropped=false
public hook_menu1(id,key) return hook_menus(1,id,key)
public hook_menu2(id,key) return hook_menus(2,id,key)
public hook_menu3(id,key) return hook_menus(3,id,key)
public hook_menu4(id,key) return hook_menus(4,id,key)
public hook_menu5(id,key) return hook_menus(5,id,key)
public hook_menus(menu,id,key)
{
//Send Info to the weapon handler function.
static weapon
new CsTeams:team = cs_get_user_team(id)
switch(menu)
{
case 1:
{
switch(team)
{
case CS_TEAM_T: format(weapon,31,menu1_weapon_names_T)
case CS_TEAM_CT: format(weapon,31,menu1_weapon_names_CT)
}
}
case 2:
{
switch(team)
{
case CS_TEAM_T: format(weapon,31,menu2_weapon_names_T)
case CS_TEAM_CT: format(weapon,31,menu2_weapon_names_CT)
}
}
case 3:
{
switch(team)
{
case CS_TEAM_T: format(weapon,31,menu3_weapon_names_T)
case CS_TEAM_CT: format(weapon,31,menu3_weapon_names_CT)
}
}
case 4:
{
switch(team)
{
case CS_TEAM_T: format(weapon,31,menu4_weapon_names_T)
case CS_TEAM_CT: format(weapon,31,menu4_weapon_names_CT)
}
}
case 5:
{
switch(team)
{
case CS_TEAM_T: format(weapon,31,menu5_weapon_names_T)
case CS_TEAM_CT: format(weapon,31,menu5_weapon_names_CT)
}
}
}
new price
switch(menu)
{
case 1:
{
switch(team)
{
case CS_TEAM_T: price = str_to_num(menu1_weapon_names_T)
case CS_TEAM_CT: price = str_to_num(menu1_weapon_names_CT)
}
}
case 2:
{
switch(team)
{
case CS_TEAM_T: price = str_to_num(menu2_weapon_names_T)
case CS_TEAM_CT: price = str_to_num(menu2_weapon_names_CT)
}
}
case 3:
{
switch(team)
{
case CS_TEAM_T: price = str_to_num(menu3_weapon_names_T)
case CS_TEAM_CT: price = str_to_num(menu3_weapon_names_CT)
}
}
case 4:
{
switch(team)
{
case CS_TEAM_T: price = str_to_num(menu4_weapon_names_T)
case CS_TEAM_CT: price = str_to_num(menu4_weapon_names_CT)
}
}
case 5:
{
switch(team)
{
case CS_TEAM_T: price = str_to_num(menu5_weapon_names_T)
case CS_TEAM_CT: price = str_to_num(menu5_weapon_names_CT)
}
}
}
return handle_weapon(id,weapon,price)
}
public handle_weapon(id,weapon,price)
{
//Check for if they already have it & if they have the cash.
if(cs_user_has_weapon(id,get_weaponid(weapon)))
{
client_print(id,print_center,"You already own that weapon.")
engclient_cmd(id,"menuselect","10")
return PLUGIN_HANDLED
}
if(cs_get_user_money(id)<price)
{
client_print(id,print_center,"You have insufficient funds!")
engclient_cmd(id,"menuselect","10")
return PLUGIN_HANDLED
}
new weaptype = weapon_type(get_weaponid(weapon))
if(weaptype==1 && count_weaps(id,1)>=get_pcvar_num(primcvar) || weaptype==2 【【【【【源码】】】】】
&& count_weaps(id,2)>=get_pcvar_num(seccvar))
{
client_print(id,print_center,"You cannot carry anymore of that type!")
engclient_cmd(id,"menuselect","10")
return PLUGIN_HANDLED
}
//Give them their weapon and take their money.
give_item(id,weapon)
cs_set_user_money(id,cs_get_user_money(id) - price)
//Close Menu so CS doesn't handle weapon buy.
engclient_cmd(id,"menuselect","10")
return PLUGIN_HANDLED
}
public FM_Touch_hook(weaponbox,id)
{
if(id && id<=maxplayers && !justdropped && is_user_alive(id) && !is_user_bot(id) && weaponbox>maxplayers && pev_valid(weaponbox))
{
static classname, trash
pev(weaponbox,pev_classname,classname,63)
if(equali(classname,"weaponbox"))
{
//Support for most custom models.
pev(weaponbox,pev_model,classname,63)
replace(classname,63,"w_"," ")
replace(classname,63,".mdl","")
strbreak(classname,trash,3,classname,63)
format(classname,63,"weapon_%s",classname)
new ent = engfunc(EngFunc_FindEntityByString,maxplayers,"classname",classname)
while(ent && pev_valid(ent))
{
if(pev(ent,pev_owner)==weaponbox)
{
static weaponid
weaponid = get_weaponid(classname)
if(!cs_user_has_weapon(id,weaponid))
{
new weaptype = weapon_type(weaponid)
if(weaptype==1 && count_weaps(id,1)>=get_pcvar_num(primcvar) || weaptype==2 && count_weaps(id,2)>=get_pcvar_num(seccvar))
{
break;
}
justdropped=true
set_task(0.5,"notdropped",id)
give_item(id,classname)
}
static classname2
pev(ent,pev_classname,classname2,31)
blah2=cs_get_weapon_ammo(ent)
if(pev_valid(weaponbox)) engfunc(EngFunc_RemoveEntity,weaponbox)
if(pev_valid(ent)) engfunc(EngFunc_RemoveEntity,ent)
set_task(0.1,"give_ammo",id,classname2,31)
break;
}
ent = engfunc(EngFunc_FindEntityByString,ent,"classname",classname)
}
}
}
}
public give_ammo(classname2,id)
{
if(is_user_alive(id))
{
static Float:origin
pev(id,pev_origin,origin)
new ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,origin,20.0)
while(ent && pev_valid(ent))
{
static classname
pev(ent,pev_classname,classname,31)
if(equali(classname,classname2) && pev(ent,pev_owner)==id)
{
cs_set_weapon_ammo(ent,blah2)
break;
}
ent = engfunc(EngFunc_FindEntityInSphere,ent,origin,20.0)
}
}
blah=0
}
/*
* Types:
* 1 = primary weps
* 2 = secondary weps
*/
public count_weaps(id,type)
{
if(!is_user_alive(id))
{
return PLUGIN_HANDLED
}
new num, num2, weapons
cs_get_user_weapons(id,weapons,num2)
switch(type)
{
case 2:
{
for(new i=0;i<num2;i++)
{
if(weapons==1 || weapons==10 || weapons==11 || weapons==16 || weapons==26 || weapons==17) num++
}
}
default:
{
for(new i=0;i<num2;i++)
{
if(weapons==30 || weapons==8 || weapons==12 || weapons==13 || weapons==14 || weapons==15 || weapons==18 || weapons==19 || weapons==20 || weapons==21 || weapons==22 || weapons==23 || weapons==24 || weapons==27 || weapons==28 || weapons==3 || weapons==5 || weapons==7) num++
}
}
}
return num;
}
public cs_get_user_weapons(id,weapons,& num)
{
num=0
new ent, origin, classname, owner
pev(id,pev_origin,origin)
ent = engfunc(EngFunc_FindEntityInSphere,get_maxplayers(),origin,1.0)
while(ent)
{
owner = pev(ent,pev_owner)
if(owner==id)
{
pev(ent,pev_classname,classname,31)
if(containi(classname,"weapon_")==0)
{
weapons = get_weaponid(classname)
num++
}
}
ent = engfunc(EngFunc_FindEntityInSphere,ent,origin,1.0)
}
return 1;
}
/*
* Returns 1 for primary weapon
* and 2 for secondary weapon
*/
public weapon_type(weapid)
{
if(weapid==1 || weapid==10 || weapid==11 || weapid==16 || weapid==26 || weapid==17) return 2;
return 1;
}
/*
*
*/
public cs_user_has_weapon(id,weapid)
{
new ent, origin, classname, owner, weapname
get_weaponname(weapid,weapname,31)
pev(id,pev_origin,origin)
ent = engfunc(EngFunc_FindEntityInSphere,get_maxplayers(),origin,1.0)
while(ent)
{
owner = pev(ent,pev_owner)
if(owner==id)
{
pev(ent,pev_classname,classname,31)
if(equali(classname,weapname))
{
return 1;
}
}
ent = engfunc(EngFunc_FindEntityInSphere,ent,origin,1.0)
}
return 0;
}
/*
*Code for giving BPAmmo
public give_ammo2(params,id)
{
if(pev_valid(params))
{
new bpammo
switch(params)
{
//case 16: bpammo = get_pdata_int(params,43591)
//case 17: bpammo = get_pdata_int(params,5189)
default: bpammo = 0
}
engfunc(EngFunc_RemoveEntity,params)
cs_set_user_bpammo(id,params,cs_get_user_bpammo(id,params) + bpammo)
}
blah=0
}
*Code for finding offsets. Will need for later.
for(new i=0;i<=50000;i++) if(get_pdata_int(param,i)==24) client_print(0,print_chat,"%d",i)
client_print(0,print_chat,"%d. %d",5189,get_pdata_int(param,5189))
*/ 插件有问题呀 运行一会服务器就挂机 愁.... bzj5959 发表于 2012-12-13 19:38 static/image/common/back.gif
插件有问题呀 运行一会服务器就挂机 愁....
不是吧 ,可能是跟某些插件冲突 bzj5959 发表于 2012-12-13 19:38 static/image/common/back.gif
插件有问题呀 运行一会服务器就挂机 愁....
早就知道的, 哈哈,小白鼠 支持支持支持
TA的每日心情
怒
2016-8-28 07:23
签到天数:7天
偶尔看看II
3
主题
85
帖子
7
积分
注册会员
等级:2
积分7金币0点经验10点点通币93点
发消息
9 #
发表于2016-8-22 12:56:45 来自手机 | 只看该作者
支持支持支持
页:
[1]