可转档了
复制程式
#include <amxmodx>
#include <zombieplague>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
new g_itemid1,g_itemid2
new cvar_cost1,cvar_cost2
new bool:item1[33], bool:item2[33]
new const g_item_name1[] = { "道具1" }
new const g_item_name2[] = { "道具2" }
public plugin_init(){
register_plugin("1.0", "1.0", "1.0")
cvar_cost1= register_cvar("zp_item1_cost", "2")//道具1价格
cvar_cost2= register_cvar("zp_item2_cost", "4")//道具2价格
g_itemid1= zp_register_extra_item(g_item_name1, get_pcvar_num(cvar_cost1), ZP_TEAM_HUMAN)
g_itemid2= zp_register_extra_item(g_item_name2, get_pcvar_num(cvar_cost2), ZP_TEAM_HUMAN)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
}
public zp_extra_item_selected (id, itemid) {
if (itemid == g_itemid1){
item1[id] = true
client_print(id, print_chat, "[ZP] 你购买了道具1.")
cs_set_user_armor(id ,150 ,CS_ARMOR_KEVLAR)
}
if (itemid == g_itemid2){
item2[id] = true
client_print(id, print_chat, "[ZP] 你购买了道具2.")
cs_set_user_armor(id ,300 ,CS_ARMOR_KEVLAR)
}
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
if (victim != attacker || is_user_connected(attacker)) {
if (item1[victim] || item2[victim]){
new armor = get_user_armor(victim)
new damage_armor = floatround(damage)
if (damage_armor > 0 && armor > 0) {
if (armor > damage_armor) {
damage -= damage_armor
fm_set_user_armor(victim, armor - damage_armor)
} else {
damage -= armor
fm_set_user_armor(victim, 0)
}
damage = (damage * 0)
SetHamParamFloat(4, damage)
}
}
}
}
public fw_PlayerPreThink(id)
{
if (is_user_alive(id) || item1[id] || item2[id]) {
new armor = get_user_armor(id)
if (armor <= 0){
item1[id] = false
item2[id] = false
}
}
if (zp_get_user_zombie(id)) {
item1[id] = false
item2[id] = false
}
if (!is_user_alive(id)) {
item1[id] = false
item2[id] = false
}
}
stock fm_set_user_armor(index, armor){
set_pev(index, pev_armorvalue, float(armor));
return 1;
}