求教
这是花钱回血插件求教如何让他只用于OP和VIP,或者只用于OP或VIP?/*
* Title: Repair Damage
* Author: v3x & FoX Rider
* Created:March 11th, 2005
*
* Desc: Allows you to "repair" lost damage
* by taking a certain amount of cash
* out depending on your condition
*
*
*
* Cvars:
* repair_active <1|0> (default 1)
* _Activate the plugin
* -------------------------------
* repair_armor <1|0> (default 1)
* _Repair armor also
* -------------------------------
* repair_msg <1|0> (default 1)
* _Show the message
* -------------------------------
* repair_msg_time <10-180> (default 180)
* _Show the message every 180 seconds
Commands: say repair
* say_team repair
*
*
*
* To do:
* Add a limit for repairs
*
*
* Credits: Fox Rider for the idea
*
*
*/
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
public plugin_init() {
register_plugin("Repair Damage","0.1","v3x & FoX Rider")
register_concmd("say repair","doRepair")
register_concmd("say_team repair","doRepair")
register_clcmd("repair","doRepair")
register_cvar("repair_active","1")
register_cvar("repair_armor","1")
register_cvar("repair_msg","1")
register_cvar("repair_msg_time","180")
register_logevent("sayMsg",2,"0=World triggered","1=Round_Start")
}
public client_putinserver(id) {
if(is_user_bot(id))
return PLUGIN_HANDLED
set_task(20.0, "sayMsg", id)
return PLUGIN_CONTINUE
}
public doRepair(id) {
if(get_cvar_num("repair_active") == 0) {
return PLUGIN_HANDLED
}
if(!is_user_alive(id))
{
client_print(id,print_chat," 浣犲凡缁忛樀浜?鍥犳鏃犳硶涔拌浜?")
return PLUGIN_HANDLED;
}
new hp = get_user_health(id)
new cost
// If there's a better way to do this, please tell me!
if(hp <= 10) {
cost = 5000
}
else if(hp <= 20) {
cost = 4500
}
else if(hp <= 30) {
cost = 4000
}
else if(hp <= 40) {
cost = 3500
}
else if(hp <= 50) {
cost = 3000
}
else if(hp <= 60) {
cost = 2500
}
else if(hp <= 70) {
cost = 2000
}
else if(hp <= 80) {
cost = 1500
}
else if(hp <= 90) {
cost = 1000
}
else if(hp <= 99) {
cost = 250
}
else if(hp == 100) {
client_print(id,print_chat," 浣犲苟娌℃湁鍙椾激,鍥犳鏃犻』涔拌.")
return PLUGIN_HANDLED
}
new Money = cs_get_user_money(id)
if(Money < cost) {
client_print(id,print_chat," 浣犳病鏈夎冻澶熺殑璧勯噾鏉ヤ拱琛€.")
return PLUGIN_HANDLED
}
if(Money >= cost) {
if(get_cvar_num("repair_armor") == 1) {
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
}
new newMoney = cs_get_user_money(id) - cost
cs_set_user_money(id,newMoney,1)
set_user_health(id,100)
client_print(id,print_chat," 浣犲洜涓轰拱琛€鑰岃姳璐逛簡 $%d.",cost)
emit_sound(id,CHAN_VOICE,"items/ammopickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public sayMsg(id) {
if (!get_cvar_num("repair_active") || !get_cvar_num("repair_msg"))
return PLUGIN_HANDLED
if(get_cvar_num("repair_msg_time") < 10)
{
server_cmd ("repair_msg_time 10")
return PLUGIN_CONTINUE
}
if(is_user_connected(id)) client_print(id, print_chat, " 浣犲彲浠ラ€氳繃say 'repair'鏉ヤ拱琛€.")
set_task(get_cvar_float("repair_msg_time"), "sayMsg", id)
return PLUGIN_HANDLED
} 还有如何让回hp和回ap分开 我不知道...這裡不是詢問的~你去詢問的地方問吧~ 我倒想去可咱潜力选手只能在这混啊 LZ我想这个应该不是很难,把你的代码整理一下吧,看得我头晕!你用整理一下! 还是建议LZ弄一个专业的文字编辑工具 /*
* Title: Repair Damage
* Author: v3x & FoX Rider
* Created:March 11th, 2005
*
* Desc: Allows you to "repair" lost damage
* by taking a certain amount of cash
* out depending on your condition
*
*
*
* Cvars:
* repair_active <1|0> (default 1)
* _Activate the plugin
* -------------------------------
* repair_armor <1|0> (default 1)
* _Repair armor also
* -------------------------------
* repair_msg <1|0> (default 1)
* _Show the message
* -------------------------------
* repair_msg_time <10-180> (default 180)
* _Show the message every 180 seconds
Commands: say repair
* say_team repair
*
*
*
* To do:
* Add a limit for repairs
*
*
* Credits: Fox Rider for the idea
*
*
*/
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
public plugin_init() {
register_plugin("Repair Damage","0.1","v3x & FoX Rider")
register_concmd("say repair","doRepair",ADMIN_RESERVATION,"- vip damage") // ADMIN_RESERVATION为玩家权限
register_concmd("say_team repair","doRepair",ADMIN_RESERVATION,"- vip damage") // ADMIN_RESERVATION为玩家权限
register_clcmd("repair","doRepair")
register_cvar("repair_active","1")
register_cvar("repair_armor","1")
register_cvar("repair_msg","1")
register_cvar("repair_msg_time","180")
register_logevent("sayMsg",2,"0=World triggered","1=Round_Start")
}
public client_putinserver(id) {
if(is_user_bot(id))
return PLUGIN_HANDLED
set_task(20.0, "sayMsg", id)
return PLUGIN_CONTINUE
}
public doRepair(id,level) {
if(get_cvar_num("repair_active") == 0) {
return PLUGIN_HANDLED
}
if (!access(id,level)){
client_print(id,print_chat," 你不是会员无法购买HP。")
return PLUGIN_HANDLED;
}
if(!is_user_alive(id))
{
client_print(id,print_chat," 你已经死亡、不能购买HP。")
return PLUGIN_HANDLED;
}
new hp = get_user_health(id)
new cost
// If there's a better way to do this, please tell me!
if(hp <= 10) {
cost = 5000
}
else if(hp <= 20) {
cost = 4500
}
else if(hp <= 30) {
cost = 4000
}
else if(hp <= 40) {
cost = 3500
}
else if(hp <= 50) {
cost = 3000
}
else if(hp <= 60) {
cost = 2500
}
else if(hp <= 70) {
cost = 2000
}
else if(hp <= 80) {
cost = 1500
}
else if(hp <= 90) {
cost = 1000
}
else if(hp <= 99) {
cost = 250
}
else if(hp == 100) {
client_print(id,print_chat," 你不需要购买HP。")
return PLUGIN_HANDLED
}
new Money = cs_get_user_money(id)
if(Money < cost) {
client_print(id,print_chat," 你的金钱不足以你购买HP。")
return PLUGIN_HANDLED
}
if(Money >= cost) {
if(get_cvar_num("repair_armor") == 1) {
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
}
new newMoney = cs_get_user_money(id) - cost
cs_set_user_money(id,newMoney,1)
set_user_health(id,100)
client_print(id,print_chat," 购买成功、花掉你 $%d.",cost)
emit_sound(id,CHAN_VOICE,"items/ammopickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public sayMsg(id) {
if (!get_cvar_num("repair_active") || !get_cvar_num("repair_msg"))
return PLUGIN_HANDLED
if(get_cvar_num("repair_msg_time") < 10)
{
server_cmd ("repair_msg_time 10")
return PLUGIN_CONTINUE
}
if(is_user_connected(id)) client_print(id, print_chat, " 会员可使用 say 'repair' 购买HP。")
set_task(get_cvar_float("repair_msg_time"), "sayMsg", id)
return PLUGIN_HANDLED
}
页:
[1]