|
发表于 2009-9-3 13:45:17
|
显示全部楼层
来自 中国–四川–遂宁
- /*
- * 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,"[Repair Health] 你不是会员无法购买HP。")
- return PLUGIN_HANDLED;
- }
- if(!is_user_alive(id))
- {
- client_print(id,print_chat,"[Repair Health] 你已经死亡、不能购买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,"[Repair Health] 你不需要购买HP。")
- return PLUGIN_HANDLED
- }
- new Money = cs_get_user_money(id)
- if(Money < cost) {
- client_print(id,print_chat,"[Repair Health] 你的金钱不足以你购买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,"[Repair Health] 购买成功、花掉你 $%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, "[Repair Health] 会员可使用 say 'repair' 购买HP。")
- set_task(get_cvar_float("repair_msg_time"), "sayMsg", id)
- return PLUGIN_HANDLED
- }
复制代码 |
|