搜索
查看: 1388|回复: 2

请教大家一个代码问题

[复制链接]
发表于 2006-8-24 07:50:53 | 显示全部楼层 |阅读模式 来自 中国–广西–崇左–凭祥市
下面的代码是一个手雷插件,可以购买到伤害更高的手雷.
我想问一下哪个地方可以修改这个手雷的伤害倍数?????


谢谢!!






/********************************************************************************
* Super HE Grenades
* By pcboy
* Version 1.1
*
* For Counter-Strike 1.6 ONLY
* Category: Fun Stuff
*
* E-mail: chiho3212@gmail.com (DO NOT SPAM)
* MSN: chiho3212@hotmail.com
* ICQ: 145-143-474 (Need to be authorized)
*
*********************************************************************************
* This plugin was created under the encouragements by Charming and Mini_Midget. *
*               Without you, I won't script plugins anymore.                    *
*      People who discourage me please get away and don't use this plugin.      *
*********************************************************************************
*
************************************ Credits ************************************
* T(+)rget
* Helped me, with the extra damage in he grenades
*********************************************************************************
*
******************************* What does this do *******************************
   This plugin lets you to buy super HE grenades. Super HE grenades are with
   higher damage.
*********************************************************************************
*
************************************* CVARs *************************************
* amx_supnades
* Values avaliable: 0 or 1 only
* Default: 1
*
* amx_suphecost
* Values avaliable: Any integers
* Default: 600
* The cost of a super HE grenade.
*********************************************************************************
*
******************************** Client Commands ********************************
* say /showprices
* Flags needed: User (Anyone)
* Show the prices of a super HE grenade and a super flashbang.
*
* say /buyhe
* Flags needed: User (Anyone)
* Buy a super HE grenade
*********************************************************************************
*
*********************************** Changelog ***********************************
* 1.0.2
* Minor update. Just added suphe_version cvar for finding server easily.
*
* 1.0.1
* Fixed buy time bug
*
* 1.0
* Initial Release
********************************************************************************/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <engine>
new bool:hasHE[33]
new price
new bool:buy_allow[33]
new bool:buying
// new gmsgDeathMsg // For 1.1 use
public plugin_init() {
register_plugin("Super HE Grenades", "1.0.2", "pcboy")

// gmsgDeathMsg = get_user_msgid("DeathMsg") // For 1.1 use

register_cvar("suphe_version", "1.0.2")
register_cvar("amx_supnades", "1")
register_cvar("amx_suphecost", "600")

register_clcmd("say /showprices", "showPrices")
register_clcmd("say /buyhe", "buyHe")

register_event("ResetHUD", "advertiseSupHE", "b")
register_event("Damage", "Damage_event", "b", "2>0")
set_task(1.0, "checkCost")

register_event("StatusIcon", "buyzone_icon", "be", "2=buyzone")
register_event("RoundTime", "RoundTime_event", "bc")
}
public client_connect(id) {
hasHE[id] = false
}
public client_disconnect(id) {
hasHE[id] = false
}
public checkCost() {
price = get_cvar_num("amx_suphecost")
if (price <= 0) {
  set_cvar_num("amx_suphecost", 600)
  server_print("[Super HE Grenades] The cost of a super HE grenade has been changed to $600 due to the value is too low.")
}
if (price > 16000) {
  set_cvar_num("amx_suphecost", 600)
  server_print("[Super HE Grenades] The cost of a super HE grenade has been changed to $600 due to the value is too high.")
}

set_task(1.0, "checkCost")
}
public advertiseSupHE(id) {
price = get_cvar_num("amx_suphecost")

if(!get_cvar_num("amx_supnades")) return PLUGIN_HANDLED

client_print(id, print_chat, " Super HE Grenades is enabled on this server.")
client_print(id, print_chat, " 1 Super HE Grenade costs $%i.", price)
client_print(id, print_chat, " Say ^"/buyhe^" to buy one.")

return PLUGIN_HANDLED
}
public showPrices(id) {
price = get_cvar_num("amx_suphecost")

if (!get_cvar_num("amx_supnades")) {
  client_print(id, print_chat, "[X] The plugin is disabled!")
  return PLUGIN_HANDLED
}

client_print(id, print_chat, " A super HE Grenade costs $%i.", price)
client_print(id, print_chat, " Say ^"/buyhe^" to buy one.")

return PLUGIN_HANDLED
}
public buyHe(id) {
price = get_cvar_num("amx_suphecost")

if (!get_cvar_num("amx_supnades")) {
  client_print(id, print_chat, "[X] The plugin is disabled!")
  return PLUGIN_HANDLED
}

if(!is_user_alive(id)) {
  client_print(id, print_chat, "[X] Dead men buy nothing.")
  return PLUGIN_HANDLED
}
new myMoney = cs_get_user_money(id)
new myMoneyleft = myMoney-price

if (price > myMoney) {
  client_print(id , print_center , "You have insufficient funds!")
  client_print(id, print_chat, "[X] You can't buy a super HE Grenade because you don't have enough money.")
  client_print(id, print_chat, " A super HE Grenade costs $%i.", price)
  
  return PLUGIN_HANDLED
}

if (cs_get_user_bpammo(id, CSW_HEGRENADE) == 1) {
  client_print(id, print_center, "You cannot carry anymore!")
  
  return PLUGIN_HANDLED
}

if(buying && buy_allow[id])
{
  cs_set_user_money(id, myMoneyleft)
  hasHE[id] = true

  client_print(id, print_chat, " You have just bought a super HE grenade for $%i.", price)

  give_item(id, "weapon_hegrenade")
}
else if(!buying) engclient_print(id, engprint_center, "%i seconds have passed.^nYou can't buy anything now!", floatround(get_cvar_float("mp_buytime") * 60))
return PLUGIN_HANDLED
}

public Damage_event(id) {
new wpn, body, attacker = get_user_attacker(id, wpn, body)
// Its a Grenade
if(wpn == 4 && hasHE[attacker])
{
  new Float:hp = float(get_user_health(id))
  new Float:dmg = float(read_data(2))
  dmg *= 0.5
  new damage = floatround(hp - dmg)
  set_user_health(id, damage)
}
}

public buyzone_icon(id)
{
if(read_data(1))
{
  if(!buying) buy_allow[id] = false
  else buy_allow[id] = true
}
else buy_allow[id] = false
}
public RoundTime_event()
{
new Float:roundtime = get_cvar_float("mp_roundtime") * 60.0
new rtime = read_data(1)
if(get_cvar_num("mp_freezetime") == rtime)
{
  if(task_exists(5681)) remove_task(5681)
     }
buying = true
if(roundtime == rtime)
{
  new Float:buy_time = get_cvar_float("mp_buytime") * 60
  set_task(buy_time, "buy_task", 5681)
}
}
public buy_task()
{
buying = false
}
发表于 2006-8-24 08:19:16 | 显示全部楼层 来自 中国–江苏–南京

回复: 请教大家一个代码问题

public Damage_event(id) {
new wpn, body, attacker = get_user_attacker(id, wpn, body)
// Its a Grenade
if(wpn == 4 && hasHE[attacker])
{
new Float:hp = float(get_user_health(id))
new Float:dmg = float(read_data(2))
dmg *= 0.5
new damage = floatround(hp - dmg)
set_user_health(id, damage)
}
}

上面这段代码中的0.5
回复

使用道具 举报

 楼主| 发表于 2006-8-26 13:50:42 | 显示全部楼层 来自 中国–广西–崇左–凭祥市

回复: 请教大家一个代码问题

谢谢楼上朋友的回答.
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表