buym4ak修改版 附源码
本帖最后由 kilng 于 2009-12-10 22:23 编辑加入famas,galil两种枪的购买,还加了个admin不花钱买枪函数,不受地点时间限制,amx_buy ak & m4 & awp等,使用unlimited_money。/* UTF-8 func by www.DT-Club.net */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <unlimited_money>
new bool:buyswitch
public plugin_init() {
register_plugin("buyweapon","1.0","bruto")
register_concmd("amx_buy", "adminbuy", ADMIN_SLAY, " - AMXX ADMIN BUY WEAPON SCRIPT")
register_clcmd("say /m4","M4")
register_clcmd("say /fa","FA")
register_clcmd("say /ak","AK")
register_clcmd("say /ga","GA")
register_cvar("m4cost","3100")
register_cvar("facost","2250")
register_cvar("akcost","2500")
register_cvar("gacost","2000")
register_logevent("round_start",2,"0=World triggered","1=Round_Start")
register_event("HLTV","eResetHUD","a","a=0","2=0")
}
public adminbuy(id, level, cid){
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Arg1
read_argv(1, Arg1, 3)
if(equali(Arg1,"m4")){
give_item(id, "weapon_m4a1")
cs_set_user_bpammo(id,CSW_M4A1,90)
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
console_print(id,"bruto:give me the m4!")
return PLUGIN_CONTINUE
}
if(equali(Arg1,"ak")){
give_item(id, "weapon_ak47")
cs_set_user_bpammo(id,CSW_AK47,90)
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
console_print(id,"bruto:give me the ak!")
return PLUGIN_CONTINUE
}
if(equali(Arg1,"fa")){
give_item(id, "weapon_famas")
cs_set_user_bpammo(id,CSW_FAMAS,90)
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
console_print(id,"bruto:give me the fa!")
return PLUGIN_CONTINUE
}
if(equali(Arg1,"ga")){
give_item(id, "weapon_galil")
cs_set_user_bpammo(id,CSW_GALIL,90)
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
console_print(id,"bruto:give me the ga!")
return PLUGIN_CONTINUE
}
if(equali(Arg1,"awp")){
give_item(id, "weapon_awp")
cs_set_user_bpammo(id,CSW_AWP,30)
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
console_print(id,"bruto:give me the awp!")
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public round_start(id) {
client_print(id, print_chat, "警察可以购买AK,GA匪徒可以购买M4,FA 输入")
}
public M4(id) {
new m4cost = get_cvar_num("m4cost")
new moneyy = cs_get_user_money2(id)
if(!is_user_alive(id)) {
client_print(id,print_chat,"你已经死亡,不能购买")
return PLUGIN_CONTINUE
}
if(moneyy < m4cost) {
client_print(id,print_chat,"你的金钱不够")
return PLUGIN_CONTINUE
}
if (cs_get_user_hasprim(id)) {
client_print(id,print_chat,"你已经拥有一个主武器了")
return PLUGIN_CONTINUE
}
if(!cs_get_user_buyzone(id)){
client_print(id,print_chat,"你只能在购买区内购买武器")
return PLUGIN_CONTINUE
}
if(!buyswitch){
client_print(id,print_chat,"购买时间已过")
return PLUGIN_CONTINUE
}
else {
cs_set_user_money2(id,moneyy-m4cost)
give_item(id, "weapon_m4a1")
}
return PLUGIN_CONTINUE
}
public FA(id) {
new facost = get_cvar_num("facost")
new moneyy = cs_get_user_money2(id)
if(!is_user_alive(id)) {
client_print(id,print_chat,"你已经死亡,不能购买")
return PLUGIN_CONTINUE
}
if(moneyy < facost) {
client_print(id,print_chat,"你的金钱不够")
return PLUGIN_CONTINUE
}
if (cs_get_user_hasprim(id)) {
client_print(id,print_chat,"你已经拥有一个主武器了")
return PLUGIN_CONTINUE
}
if(!cs_get_user_buyzone(id)){
client_print(id,print_chat,"你只能在购买区内购买武器")
return PLUGIN_CONTINUE
}
if(!buyswitch){
client_print(id,print_chat,"购买时间已过")
return PLUGIN_CONTINUE
}
else {
cs_set_user_money2(id,moneyy-facost)
give_item(id, "weapon_famas")
}
return PLUGIN_CONTINUE
}
public AK(id) {
new akcost = get_cvar_num("akcost")
new moneyy = cs_get_user_money2(id)
if(!is_user_alive(id)) {
client_print(id,print_chat,"你已经死亡,不能购买")
return PLUGIN_CONTINUE
}
if(moneyy < akcost) {
client_print(id,print_chat,"你的金钱不够")
return PLUGIN_CONTINUE
}
if (cs_get_user_hasprim(id)) {
client_print(id,print_chat,"你已经拥有一个主武器了")
return PLUGIN_CONTINUE
}
if(!cs_get_user_buyzone(id)){
client_print(id,print_chat,"你只能在购买区内购买武器")
return PLUGIN_CONTINUE
}
if(!buyswitch){
client_print(id,print_chat,"购买时间已过")
return PLUGIN_CONTINUE
}
else {
cs_set_user_money2(id,moneyy-akcost)
give_item(id, "weapon_ak47")
}
return PLUGIN_CONTINUE
}
public GA(id) {
new gacost = get_cvar_num("gacost")
new moneyy = cs_get_user_money2(id)
if(!is_user_alive(id)) {
client_print(id,print_chat,"你已经死亡,不能购买")
return PLUGIN_CONTINUE
}
if(moneyy < gacost) {
client_print(id,print_chat,"你的金钱不够")
return PLUGIN_CONTINUE
}
if (cs_get_user_hasprim(id)) {
client_print(id,print_chat,"你已经拥有一个主武器了")
return PLUGIN_CONTINUE
}
if(!cs_get_user_buyzone(id)){
client_print(id,print_chat,"你只能在购买区内购买武器")
return PLUGIN_CONTINUE
}
if(!buyswitch){
client_print(id,print_chat,"购买时间已过")
return PLUGIN_CONTINUE
}
else {
cs_set_user_money2(id,moneyy-gacost)
give_item(id, "weapon_galil")
}
return PLUGIN_CONTINUE
}
public eResetHUD(){
new Float:buytime=get_cvar_float("mp_buytime")*60
buyswitch=true
set_task(buytime,"buy")
}
public buy()
{
buyswitch=false
}
想把雷买全和当警察时买拆包器就改成, if(equali(Arg1,"m4")){
give_item(id, "weapon_m4a1")
give_item(id, "weapon_hegrenade")
give_item(id, "weapon_flashbang")
give_item(id, "weapon_flashbang")
give_item(id, "weapon_smokegrenade")
cs_set_user_bpammo(id,CSW_M4A1,90)
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
if (get_user_team(id)==2){
cs_set_user_defuse(id)
}
console_print(id,"bruto:give me the m4!")
return PLUGIN_CONTINUE
} 其它的自己改吧。 能否改成users.in里的会员才可以买??? 能否改成users.in里的会员才可以买???
zlove84 发表于 2009-12-7 20:07 http://www.dt-club.net/forum/images/common/back.gif
对,要有amx_slay这个权限,别的权限也可以自己在源码里更改。 本帖最后由 kilng 于 2009-12-8 09:39 编辑
如果是/say m4,这个的话,
这里改成以下这样就应该可以了吧,
register_clcmd("say /m4","M4",ADMIN_SLAY,"")
public M4(id,level,cid) {
if (!cmd_access(id, level, cid, 1)) {
return PLUGIN_HANDLED
}
new m4cost = get_cvar_num("m4cost")
new moneyy = cs_get_user_money2(id)
}
DT强手真多~ 很好,很强大....新意 amx_slay这个权限 即是怎么判断权限分配?比方我要指定users.ini里有h权限的会员才可以同时买二把枪,
那怎么添加这个判断函数? 本帖最后由 kilng 于 2009-12-10 22:09 编辑
7# zlove84
看这句
register_concmd("amx_buy", "adminbuy", ADMIN_SLAY, " - AMXX ADMIN BUY WEAPON SCRIPT")
users.ini
; h - amx_cfg command (可以加载某个AMX cfg 设置文件权限)
h权限就改成
register_concmd("amx_buy", "adminbuy", ADMIN_CFG, " - AMXX ADMIN BUY WEAPON SCRIPT") 感谢楼主无私教导,在下感激不尽,有空来佛山玩,我请你喝茶~~ 9# zlove84
小事情,问题解决就好,