|
发表于 2007-12-19 04:38:54
|
显示全部楼层
来自 中国–广东
回复: 关于购买武器的限制~
随便改了下,没测试,自己试下.
[php]
#include <amxmodx>
#include <cstrike>
#include <fun>
#define DEBUG
new bool:buyswitch
public plugin_init() {
register_plugin("buy m4&ak","2.3","kid741010")
register_clcmd("say /m4","M4")
register_clcmd("say /ak","AK")
register_cvar("m4cost","3100")
register_cvar("akcost","2500")
new Float:maptime = get_cvar_float("mp_timelimit")
if (maptime == 0.0)
maptime = 15.0
new Float:anntime = 60.0 * 5.0 // 5 minutes
if (maptime < 5.0)
anntime = maptime / 3.0
set_task(anntime, "Announcement", 0, "", 0, "b")
register_event("ResetHUD", "eResetHUD", "a")
}
public client_putinserver(id) {
set_task(25.0, "Announcement", id)
return PLUGIN_CONTINUE
}
public Announcement(id) {
client_print(id, id, "CT可以買 AK & TS可以買 M4a1 say/m4 & say/ak")
}
public M4(id) {
new m4cost = get_cvar_num("m4cost")
new money = cs_get_user_money(id)
if(!is_user_alive(id)) {
client_print(id,print_chat,"活著才能買^n")
}
if(money < m4cost) {
client_print(id,print_chat,"金額不足^n")
}
if (cs_get_user_hasprim(id)){ //增加行
client_print(id,print_chat,"你已经有主武器了,不能再购买^n") //增加行
}
if(!cs_get_user_buyzone(id)){
client_print(id,print_chat,"只能在购买区购买武器")
}
if(!buyswitch){
client_print(id,print_chat,"购买武器时间已过")
}else {
cs_set_user_money(id,money-m4cost)
give_item(id, "weapon_m4a1")
cs_set_user_bpammo(id,CSW_M4A1,90)
}
}
public AK(id) {
new akcost = get_cvar_num("akcost")
new moneyy = cs_get_user_money(id)
if(!is_user_alive(id)) {
client_print(id,print_chat,"活著才能買^n")
}
if(moneyy < akcost) {
client_print(id,print_chat,"金額不足^n")
}
if (cs_get_user_hasprim(id)) //增加行
client_print(id,print_chat,"你已经有主武器了,不能再购买^n") //增加行
if(!cs_get_user_buyzone(id)){
client_print(id,print_chat,"只能在购买区购买武器")
}
if(!buyswitch){
client_print(id,print_chat,"购买武器时间已过")
}else {
cs_set_user_money(id,moneyy-akcost)
give_item(id, "weapon_ak47")
cs_set_user_bpammo(id,CSW_AK47,90)
}
}
public eResetHUD()
{
new Float:buytime=get_cvar_float("mp_buytime")*60
buyswitch=true
set_task(buytime,"buy")
}
public buy()
{
buyswitch=false
}
[/php] |
|