a7811311622
我…在工作了…
級別: 版主
版區: CS提問區
x771
x2152
|
分享:
▲
▼
下面是引用 i-c0112 於 2011-01-11 19:29 發表的 : 複製程式
// Fix for the HL engine bug when HP is multiples of 256
public message_health(msg_id, msg_dest, msg_entity)
{
// Get player's health
static health
health = get_msg_arg_int(1)
// 请勿打扰
if (health < 256) return;
// Check if we need to fix it
if (health % 256 == 0)
fm_set_user_health(msg_entity, pev(msg_entity, pev_health) + 1)
// HUD can only show as much as 255 hp
//set_msg_arg_int(1, get_msg_argtype(1), 256) //錯誤在這...256會顯示為0
set_msg_arg_int(1, get_msg_argtype(1), 255)
}
為何我記得256溢位後是變成254呢…? 不是要找類似「set_pev(id, pev_health, 0)」的錯誤用法嗎…? 而且如果真是錯在「pev_health」的話就不只是ZP主插件需要檢查了…
|
|
x0
[4 樓]
From:台灣教育部 | Posted:2011-01-11 23:19 |
|
|
i-c0112
|
分享:
▲
下面是引用 史來姆 於 2011-01-12 16:46 發表的 :
這樣便做成了"假死"狀態了麼? 玩家雖然顯示為死亡 但遊戲卻能繼續 我的計分版竟未顯示死亡!!而且還是可以被敵人攻擊才會死, 光是pev_health設為小於等於0的話(以下稱假死) CS好像不會判斷為死亡 不過高處時摔下不會死亡, 摔下後再把pev_health設為正數後才會死亡...... 可能CS關於死亡的內容跟HL原本定義的不太一樣吧 個人寫了個插件測試...結果發現了不少意外 ex: 假死狀態think會變為觀察者 然後pev_health會變為1.000, is_user_alive(id)回傳true 變回假死再think會變成動彈不得的觀察者 然後重複動作突然發現我的玩者id從1變為2 = =" 還有不知如何正確Execute的TraceAttack 執行結果也蠻奇怪的 我先開槍射破了A窗戶然後執行TraceAttack...窗戶就再破了一次 之後繼續執行就沒用了... 複製程式
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
new cmd_heal, cmd_status, cmd_think, cmd_dmg, cmd_trace_atk;
public plugin_init()
{
register_plugin("^^0", "^^0", "^^0")
cmd_heal = register_concmd("test_heal", "cmd_test", ADMIN_RCON|ADMIN_MENU, "<#id> <Float:amount>")
cmd_status = register_concmd("test_status", "cmd_test", ADMIN_USER, "Display your health and alive flag")
cmd_think = register_concmd("test_think", "cmd_test", ADMIN_USER, "Make your entity ^"player^" think")
cmd_dmg = register_concmd("test_damage", "cmd_test", ADMIN_ADMIN|ADMIN_MENU, "<#id> <Float:amount>")
cmd_trace_atk = register_concmd("test_trace_attack", "cmd_test", ADMIN_ADMIN|ADMIN_MENU, "<#id> <Float:amount>")
}
public cmd_test(id, level, cid)
{
if (cid == cmd_heal || cid == cmd_dmg || cid == cmd_trace_atk)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED;
new arg[32], player = 0;
read_argv(1, arg, charsmax(arg))
player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF)
if (!player) return PLUGIN_HANDLED;
new Float:amount;
read_argv(2, arg, charsmax(arg))
amount = str_to_float(arg)
if (cid == cmd_heal)
{
new Float:health;
pev(player, pev_health, health)
set_pev(player, pev_health, health + amount)
}
else if (cid == cmd_dmg)
ExecuteHam(Ham_TakeDamage, player, id, id, amount, DMG_FALL)
else
{
new trace_handle = create_tr2();
ExecuteHam(Ham_TraceAttack, player, id, amount, {2048, 2048, 2048}, trace_handle, DMG_FALL)
free_tr2(trace_handle);
}
}
else if (cid == cmd_status || cid == cmd_think)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED;
if (cid == cmd_status)
{
new Float:health; pev(id, pev_health, health)
client_print(id, print_center, "ID:%i ;Health: %f; Is_Alive? %i;", id, health, is_user_alive(id))
}
else
//dllfunc(DLLFunc_Think, id)
ExecuteHam(Ham_Think, id)
}
else console_print(id, "Unhandled command ID.")
return PLUGIN_HANDLED;
}
|
|
x1
[9 樓]
From:台灣中華電信 | Posted:2011-01-12 21:11 |
|
|
|