epic
|
分享:
▼
x0
|
[1.6] 这两天写了个给僵尸加血的插件,遇到一个问题,百思不得其解
插件目的是让受伤的僵尸可以通过买道具(也就是M2菜单里的额外选项)来补回有一定上限的血(目前上限设定的是20000)。目前这个插件能工作,只是不知道为什么补血补得特别的快(从3000HP补到20000HP大概只用10秒),但我在插件里已经设置了每1秒补10血(iHealth += 10)(set_task(1.0, "Task_HealthRegen", id, "b")),不知道问题出在哪,请大家指点我,感谢 SMA如下: #include <amxmodx> #include <fun> #include <fakemeta> #include <zombieplague.inc>
new const g_item_name[] = { "自动补血 Made by epic" } const g_item_cost = 5 new g_itemid_HealthRegen; new PLUGIN_NAME[] = "HPRegen epic" new PLUGIN_AUTHOR[] = "epic" new PLUGIN_VERSION[] = "2.8"
new bool:g_HPRegen[33] public plugin_init() { register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR); g_itemid_HealthRegen = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_ZOMBIE); register_forward(FM_PlayerPreThink, "Task_HealthRegen"); register_event("ResetHUD", "Event_ResetHUD", "be"); register_event("DeathMsg", "Event_DeathMsg", "a"); register_event("HLTV", "EVENT_round_start", "a", "1=0", "2=0"); }
public client_connect(id) { g_HPRegen[id] = false }
public Event_ResetHUD(id) { if(!is_user_connected(id) || !is_user_alive(id)) { return PLUGIN_CONTINUE } if(g_HPRegen[id]) { if(!task_exists(id)) { set_task(1.0, "Task_HealthRegen", id, "b") } } return PLUGIN_CONTINUE }
public Event_DeathMsg() { if(task_exists(read_data(2))) { remove_task(read_data(2)) } }
public Task_HealthRegen(id) { if(!is_user_alive(id) || !is_user_connected(id) || !g_HPRegen[id]) { if(task_exists(id)) { remove_task(id) } return PLUGIN_CONTINUE } new iHealth = get_user_health(id) if(iHealth < 20000) { set_hudmessage(0, 255, 0, -1.0, 0.65, 0, 1.0, 2.0, 0.1, 0.1, 4) show_hudmessage(id,"<< !!Healing!! >>") emit_sound(id,CHAN_VOICE,"items/medshot4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) message_begin(MSG_ONE, get_user_msgid("ScreenFade"), { 0, 0, 0 }, id) write_short(1<<10) write_short(1<<10) write_short(1<<12) write_byte(0) write_byte(0) write_byte(255) write_byte(50) message_end() iHealth += 10 set_user_health(id, iHealth)
if(get_user_health(id) > 20000) { emit_sound(id,CHAN_VOICE, "fvox/medical_repaired.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) set_user_health(id, 20000) } } return PLUGIN_CONTINUE } public zp_extra_item_selected(player, itemid) { if (itemid == g_itemid_HealthRegen){
g_HPRegen[player]++; client_print(player, print_chat, "You have now %d HPRegen", g_HPRegen[player]); } }
public EVENT_round_start() { for (new id; id <= 32; id++) g_HPRegen[id] = false; }
|
|
x0
[楼 主]
From:欧洲 | Posted:2008-11-19 22:10 |
|
|
牙京
|
分享:
▲
▼
很明显的,,问题出在register_forward(FM_PlayerPreThink, "Task_HealthRegen"); 我把 复制程式
register_forward(FM_PlayerPreThink, "Task_HealthRegen"); 删去 然后把 复制程式
public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_HealthRegen){
g_HPRegen[player]++;
client_print(player, print_chat, "You have now %d HPRegen", g_HPRegen[player]);
}
} 改成 复制程式
public zp_extra_item_selected(id, itemid)
{
if (itemid == g_itemid_HealthRegen){
set_task(1.0,"Task_HealthRegen",id)
g_HPRegen[id]++;
client_print(id, print_chat, "You have now %d HPRegen", g_HPRegen[id]);
}
} 最后我回到 复制程式
public Task_HealthRegen(id) 加入 复制程式
set_task(1.0,"Task_HealthRegen",id) 这样就可以了!
|
|
x1
[1 楼]
From:香港网上行 | Posted:2008-11-21 09:05 |
|
|
牙京
|
分享:
▲
▼
下面是引用epic于2008-11-21 13:34(4楼)发表的 :
那太好了,那我晚上等你的SMA吧.... 这个是你的,,可以用的了复制程式
#include <amxmodx>
#include <fun>
#include <zombieplague.inc>
new const g_item_name[] = { "自动补血 Made by epic" }
const g_item_cost = 5
new g_itemid_HealthRegen;
new PLUGIN_NAME[] = "HPRegen epic"
new PLUGIN_AUTHOR[] = "epic"
new PLUGIN_VERSION[] = "2.8"
new bool:g_HPRegen[33]
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
g_itemid_HealthRegen = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_ZOMBIE);
register_event("ResetHUD", "Event_ResetHUD", "be");
register_event("DeathMsg", "Event_DeathMsg", "a");
register_event("HLTV", "EVENT_round_start", "a", "1=0", "2=0");
}
public client_connect(id) {
g_HPRegen[id] = false
}
public Event_ResetHUD(id)
{
if(!is_user_connected(id) || !is_user_alive(id)) {
return PLUGIN_CONTINUE
}
if(g_HPRegen[id])
{
if(!task_exists(id)) {
set_task(1.0, "Task_HealthRegen", id, "b")
}
}
return PLUGIN_CONTINUE
}
public Event_DeathMsg() {
if(task_exists(read_data(2))) {
remove_task(read_data(2))
}
}
public Task_HealthRegen(id)
{
if(!is_user_alive(id) || !is_user_connected(id) || !g_HPRegen[id])
{
if(task_exists(id)) {
remove_task(id)
}
return PLUGIN_CONTINUE
}
new iHealth = get_user_health(id)
if(iHealth < 20000)
{
set_hudmessage(0, 255, 0, -1.0, 0.65, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"<< !!Healing!! >>")
emit_sound(id,CHAN_VOICE,"items/medshot4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), { 0, 0, 0 }, id)
write_short(1<<10)
write_short(1<<10)
write_short(1<<12)
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(50)
message_end()
iHealth += 10
set_user_health(id, iHealth)
set_task(1.0,"Task_HealthRegen",id)
if(get_user_health(id) > 20000)
{
emit_sound(id,CHAN_VOICE, "fvox/medical_repaired.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
set_user_health(id, 20000)
}
}
return PLUGIN_CONTINUE
}
public zp_extra_item_selected(id, itemid)
{
if (itemid == g_itemid_HealthRegen){
set_task(1.0,"Task_HealthRegen",id)
g_HPRegen[id]++;
client_print(id, print_chat, "You have now %d HPRegen", g_HPRegen[id]);
}
}
public EVENT_round_start()
{
for (new id; id <= 32; id++) g_HPRegen[id] = false;
} 这是我的做法,,交流一下吧@_@复制程式
#include <amxmodx>
#include <fun>
#include <zombieplague>
new g_itemid999
new cvar_hp[] = "kevin_hp"
public plugin_init()
{
register_plugin("[ZP] Additional Extra Items", "0.1", "Example")
register_cvar(cvar_hp, "10");
// Register the new items and store their IDs for reference
g_itemid999 = zp_register_extra_item("My Extra Item 1", 5, ZP_TEAM_ZOMBIE)
}
// Item Selected forward
public zp_extra_item_selected(id, itemid)
{
// check if the selected item matches any of our registered ones
if (itemid == g_itemid999)
client_print(id, print_chat, "你购买了自我复原!");
set_task(1.0,"extra_hpppp",id)
}
public extra_hpppp(id) {
new extra_hp = get_cvar_num(cvar_hp)
new maxhp = 20000
new hp = get_user_health(id)
if (is_user_alive(id) && (hp < maxhp) && zp_get_user_zombie(id)) {
set_user_health(id, hp + extra_hp)
set_task(1.0,"extra_hpppp",id)
}
else {
if (is_user_alive(id) && (hp > maxhp))
remove_task(id)
}
}
|
|
x0
[5 楼]
From:香港网上行 | Posted:2008-11-21 17:45 |
|
|
|