mbw
|
分享:
▼
x0
|
[1.6] 【請求高手解決BUG】關於銀色子彈內部BUG
報錯信息: [AMXX] Displaying debug trace (plugin "zp_extra_silver_bullets.amxx") [AMXX] Run time error 4: index out of bounds [AMXX] [0] zp_extra_silver_bullets.sma::Damage (line 114)
源碼: #include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <zombieplague> #define PLUGIN "[ZP] 道具:銀色子彈" #define VERSION "1.0" #define AUTHOR "Fry! & SnoW" new m_spriteTexture new damage_factor new fov_value, shake_value new has_bullets[33], last_bullet[33] new g_item_name[] = "銀色子彈" new g_itemid_silverb, g_silver_bullets_cost
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_cvar("zp_extra_silver_bullets",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY) fov_value = get_user_msgid("SetFOV") shake_value = get_user_msgid ("ScreenShake") damage_factor = register_cvar("zp_silver_bullets_damage_factor", "1.5") g_silver_bullets_cost = register_cvar("zp_silver_bullets_cost", "3") g_itemid_silverb = zp_register_extra_item(g_item_name, get_pcvar_num(g_silver_bullets_cost), ZP_TEAM_HUMAN) register_forward(FM_PlayerPreThink, "PreThink") RegisterHam(Ham_TakeDamage, "player", "Damage") RegisterHam(Ham_Spawn, "player", "Spawn", 1) } public plugin_precache() m_spriteTexture = precache_model("sprites/dot.spr") public PreThink(id) { if(!has_bullets[id]) return PLUGIN_HANDLED new weapon, clip, ammo weapon = get_user_weapon(id,clip,ammo) if(~pev(id, pev_button) & IN_ATTACK || weapon == 13 || clip == 0 || clip == last_bullet[id]) return PLUGIN_HANDLED last_bullet[id] = clip bullet_effect(id) return PLUGIN_HANDLED } public zp_extra_item_selected(player, itemid) { if(itemid == g_itemid_silverb) { has_bullets[player] = 1 client_print(player, print_chat, "[ZP] 你購買了銀色子彈,它可以給僵尸更高傷害!") } } public Damage(id, inflictor, attacker, Float:damage, Damage) { if(!has_bullets[attacker] || ~Damage & DMG_BULLET) return HAM_HANDLED SetHamParamFloat(4, damage * get_pcvar_float(damage_factor)) fov_shake(id) return HAM_HANDLED } public Spawn(id) { if(!is_user_alive(id)) return HAM_HANDLED has_bullets[id] = 0 return HAM_HANDLED } public bullet_effect(id) { new k_origin[3] new v_origin[3] get_user_origin(id,k_origin, 1) get_user_origin(id,v_origin, 4) message_begin(MSG_ONE, SVC_TEMPENTITY,{0,0,0}, id); write_byte(0) write_coord(k_origin[0]) write_coord(k_origin[1]) write_coord(k_origin[2]) //origins -> write_coord(v_origin[0]) write_coord(v_origin[1]) write_coord(v_origin[2]) //origins <- write_short( m_spriteTexture ) write_byte(1) // framestart write_byte(1) // framerate write_byte(1) // life in 0.1's write_byte(5) // width write_byte(0) // noise write_byte(255) // r, g, b write_byte(255) // r, g, b write_byte(255) // r, g, b write_byte(100) // brightness write_byte(0) // speed message_end() } public fov_shake(id) { message_begin(MSG_ONE, fov_value, {0,0,0}, id) write_byte(fov_value + 4) message_end() message_begin( MSG_ONE, shake_value, { 0, 0, 0 }, id) write_short(1<<14) write_short(1<<12) write_short(1<<14) message_end() set_task(0.4, "un_fov", id) } public un_fov(id) { message_begin(MSG_ONE, fov_value, {0,0,0}, id) write_byte(fov_value) message_end() } stock get_money(id) return get_pdata_int(id, 115, 5) stock set_money(id, amount, flash=1) { set_pdata_int(id, 115, amount, 5) message_begin(MSG_ONE,get_user_msgid("Money"),{0,0,0},id) write_long(amount) write_byte(flash) message_end() }
此文章被評分,最近評分記錄財富:10 (by 惡魔之槍) | 理由: 我在繁化某些插件時都有差不多的問題 只好等高手解答 | |
|
|
|