廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 5319 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
神人3
個人文章 個人相簿 個人日記 個人地圖
路人甲
級別: 路人甲 該用戶目前不上站
推文 x0 鮮花 x0
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[1.6][插件] 請問可告訴我這有啥問題ㄇ
我自己寫的==











/*
制作by : HKCDC:森之千手
版本號 : 4.0版
*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>
#include <xs>


#define SUPPORT_CZBOT


#if defined SUPPORT_CZBOT
new cvar_botquota
new bool:BotHasDebug = false
#endif


#define TASK_RESET_WEAPON 12345


const OFFSET_FlNextPrimaryAttack = 46
const OFFSET_LINUX_WEAPONS = 4


const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_M4A1)


new const hk416_V_Model[] = { "models/v_HK416.mdl" }
new const hk416_P_Model[] = { "models/p_HK461.mdl" }
new const hk416_W_Model[] = { "models/w_HK416.mdl" }


new const g_item_name[] = { "人類道具:魔神HK461" }
new g_itemid_hk416


new cvar_hk416_cost, cvar_dmg_multiplier, cvar_knock_power, cvar_fire_rate, cvar_bullet_tracer
new g_beamSpr


new g_maxplayers
new bool:has_hk416[33] = { false, ... }
new user_clip[33] = { 0, ... }, user_bpammo[33] = { 0, ... }
new user_drop[33] = { -1, ... }, Float:drop_time[33] = { 0.0, ... }
new bool:user_shoot[33] = { false, ... }


public plugin_init()
{
register_plugin("Make your own weapon", "4.0", "FOT")

cvar_hk416_cost = register_cvar("zp_lahumshi_cost", "60")
cvar_dmg_multiplier = register_cvar("zp_lahumshi_dmgmultiplier", "50")
cvar_knock_power = register_cvar("zp_lahumshi_knockpower", "25")
cvar_fire_rate = register_cvar("zp_lahumshi_firerate", "0.05")

g_itemid_hk416 = zp_register_extra_item(g_item_name, get_pcvar_num(cvar_hk416_cost), ZP_TEAM_HUMAN)

RegisterHam(Ham_TakeDamage, "player", "fw_Player_TakeDamage")
RegisterHam(Ham_TraceAttack, "player", "fw_Player_TraceAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m4a1", "fw_m4a1_PriAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m4a1", "fw_m4a1_PriAttack_Post", 1)

register_forward(FM_SetModel, "fw_SetModel")
register_forward(FM_Touch, "fw_Touch")

register_event("CurWeapon", "event_cur_weapon", "be", "1=1")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")

g_maxplayers = get_maxplayers()

#if defined SUPPORT_CZBOT
cvar_botquota = get_cvar_pointer("bot_quota")
#endif
}


public plugin_precache()
{
precache_model(hk416_V_Model)
precache_model(hk416_P_Model)
precache_model(hk416_W_Model)

g_beamSpr = precache_model("sprites/zbeam4.spr")
}


public zp_extra_item_selected (id, itemid)
{
if (itemid == g_itemid_hk416)
{
if (has_hk416[id] && user_has_weapon(id, CSW_M4A1))
{
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_hk416_cost))
client_print(id, print_chat, "[ZP] 你已經擁有魔神HK416了.")
return PLUGIN_CONTINUE;
}

user_drop_m4a1(id)
has_hk416[id] = true
fm_give_item(id, "weapon_m4a1")
cs_set_user_bpammo(id, CSW_M4A1, (最大225))
engclient_cmd(id, "weapon_m4a1")

client_print(id, print_chat, "[ZP] 你購買了魔神HK416!!!!");
}

return PLUGIN_CONTINUE;
}


user_drop_m4a1(id)
{
if (user_has_weapon(id, CSW_M4A1))
{
engclient_cmd(id, "drop", "weapon_m4a1")
}
}


public fw_Player_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
static Float:damage_multiplier
damage_multiplier = get_pcvar_float(cvar_dmg_multiplier)
if (damage_multiplier <= 0.0)
return HAM_IGNORED;

if (victim == attacker || !is_user_connected(attacker))
return HAM_IGNORED;

if (zp_get_user_zombie(victim) == zp_get_user_zombie(attacker))
return HAM_IGNORED;

if (!(damage_type & DMG_BULLET))
return HAM_IGNORED;

if (!has_hk416[attacker] || (get_user_weapon(attacker) != CSW_M4A1))
return HAM_IGNORED;

SetHamParamFloat(4, damage * damage_multiplier)

return HAM_IGNORED;
}


public fw_Player_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
{
static Float:knockpower
knockpower = get_pcvar_float(cvar_knock_power)
if (knockpower <= 0.0)
return HAM_IGNORED;

if (victim == attacker || !is_user_connected(attacker))
return HAM_IGNORED;

if (zp_get_user_zombie(attacker) == zp_get_user_zombie(victim))
return HAM_IGNORED;

if (!zp_get_user_zombie(victim) || zp_get_user_nemesis(victim))
return HAM_IGNORED;

if (!(damage_type & DMG_BULLET) || !get_cvar_num("zp_knockback"))
return HAM_IGNORED;

if (!has_hk416[attacker] || (get_user_weapon(attacker) != CSW_M4A1))
return HAM_IGNORED;

static victimflags, Float:knockduck
victimflags = pev(victim, pev_flags)
knockduck = get_cvar_float("zp_knockback_ducking")

if (knockduck == 0.0 && (victimflags & FL_DUCKING) && (victimflags & FL_ONGROUND))
return HAM_IGNORED;

static Float:origin1F[3], Float:origin2F[3]
pev(victim, pev_origin, origin1F)
pev(attacker, pev_origin, origin2F)

if (get_distance_f(origin1F, origin2F) > get_cvar_float("zp_knockback_distance"))
return HAM_IGNORED;

static Float:velocity[3]
pev(victim, pev_velocity, velocity)

if (get_cvar_num("zp_knockback_damage"))
xs_vec_mul_scalar(direction, damage, direction)

if (knockpower > 0.0 && get_cvar_num("zp_knockback_power"))
xs_vec_mul_scalar(direction, knockpower, direction)

if ((victimflags & FL_DUCKING) && (victimflags & FL_ONGROUND))
xs_vec_mul_scalar(direction, knockduck, direction)

xs_vec_add(velocity, direction, direction)

if (!get_cvar_num("zp_knockback_zvel"))
direction[2] = velocity[2]

set_pev(victim, pev_velocity, direction)

SetHamParamVector(4, Float:{0.0, 0.0, 0.0})

return HAM_IGNORED;
}


public fw_m4a1_PriAttack(weapon)
{
if (!pev_valid(weapon))
return HAM_IGNORED;

static owner
owner = pev(weapon, pev_owner)

if (has_hk416[owner])
{
if (cs_get_weapon_ammo(weapon) > 0)
{
user_shoot[owner] = true
}
}

return HAM_IGNORED;
}


public fw_m4a1_PriAttack_Post(weapon)
{
if (!pev_valid(weapon))
return HAM_IGNORED;

static owner
owner = pev(weapon, pev_owner)

if (has_hk416[owner])
{
if (user_shoot[owner])
{
static Float:fire_rate
fire_rate = get_pcvar_float(cvar_fire_rate)
if (fire_rate > 0.0)
{
static Float:next_pri_attack_time
next_pri_attack_time = get_weapon_next_pri_attack(weapon) * fire_rate
set_weapon_next_pri_attack(weapon, next_pri_attack_time)
}

if (get_pcvar_num(cvar_bullet_tracer))
{
static Float:origin1[3], Float:origin2[3] //, iOrigin[3]
fm_get_aim_vector(owner, 40, origin1, origin2)
origin1[2] += (pev(owner, pev_flags) & FL_DUCKING) ? 3.0 : -7.0
show_tracer_effect(origin1, origin2)
}

user_shoot[owner] = false
}
}

return HAM_IGNORED;
}


show_tracer_effect(const Float:start_point[3], const Float:end_point[3])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS) // TE id: 0
engfunc(EngFunc_WriteCoord, start_point[0]) // x
engfunc(EngFunc_WriteCoord, start_point[1]) // y
engfunc(EngFunc_WriteCoord, start_point[2]) // z
engfunc(EngFunc_WriteCoord, end_point[0]) // x
engfunc(EngFunc_WriteCoord, end_point[1]) // y
engfunc(EngFunc_WriteCoord, end_point[2]) // z
write_short(g_beamSpr) // sprite index
write_byte(0) // starting frame
write_byte(1) // frame rate in 0.1's
write_byte(1) // life in 0.1's
write_byte(30) // line width in 0.1's
write_byte(0) // noise amplitude in 0.01's
write_byte(0) // red (R.G.B)
write_byte(245) // green (R.G.B)
write_byte(255) // blue (R.G.B)
write_byte(255) // brightness
write_byte(0) // scroll speed in 0.1's
message_end()
}


public fw_SetModel(entity, const model[])
{
if (!pev_valid(entity))
return FMRES_IGNORED;

new owner
owner = pev(entity, pev_owner)

if (equal(model[7], "w_weaponbox.mdl"))
{
user_drop[owner] = entity;
return FMRES_IGNORED;
}

if (user_drop[owner] == entity)
{
if (has_hk416[owner] && equal(model[7], "w_m4a1.mdl"))
{
fm_kill_entity(entity)

if (!is_user_alive(owner) || zp_get_user_zombie(owner))
drop_hk416(owner, 1, 0)
else
drop_hk416(owner, 0, 1)

drop_time[owner] = get_gametime()
has_hk416[owner] = false
}
}

user_drop[owner] = -1

return FMRES_IGNORED;
}


public fw_Touch(ptr, ptd)
{
if (!pev_valid(ptr) || !pev_valid(ptd))
return FMRES_IGNORED;

new classname[32]
pev(ptr, pev_classname, classname, charsmax(classname))

if (!equal(classname, "ZP_hk416"))
return FMRES_IGNORED;

if (!(1 <= ptd <= 32) || !is_user_alive(ptd) || zp_get_user_zombie(ptd) || zp_get_user_survivor(ptd))
return FMRES_IGNORED;

if (has_custom_weapons(ptd, PRIMARY_WEAPONS_BIT_SUM))
return FMRES_IGNORED;

if (get_gametime() - drop_time[ptd] < 0.5)
return FMRES_IGNORED;

has_hk416[ptd] = true
fm_give_item(ptd, "weapon_m4a1")

static weap_clip, user_bpammo, weap_ent
weap_clip = pev(ptr, pev_iuser3)
user_bpammo = min(cs_get_user_bpammo(ptd, CSW_M4A1) + pev(ptr, pev_iuser4), 30)
weap_ent = fm_find_ent_by_owner(-1, "weapon_m4a1", ptd)

cs_set_weapon_ammo(weap_ent, weap_clip)
cs_set_user_bpammo(ptd, CSW_M4A1, user_bpammo)

engfunc(EngFunc_RemoveEntity, ptr)

client_print(ptd, print_chat, "[ZP] 你撿到了一把魔神HK416.")

return FMRES_IGNORED;
}


public event_cur_weapon(id)
{
if (!has_hk416[id])
return;

new weap_id, weap_clip, weap_bpammo
weap_id = get_user_weapon(id, weap_clip, weap_bpammo)

if (weap_id != CSW_M4A1)
return;

set_hk416_model(id)
user_clip[id] = weap_clip
user_bpammo[id] = weap_bpammo
user_shoot[id] = false
}


public set_hk416_model(id)
{
set_pev(id, pev_viewmodel2, hk416_V_Model)
set_pev(id, pev_weaponmodel2, hk416_P_Model)
}


public drop_hk416(id, store_bpammo, drop_type)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))

if (!pev_valid(ent))return 0;

set_pev(ent, pev_classname, "ZP_hk416")
set_pev(ent, pev_iuser1, 0) // hasn't bounced yet
set_pev(ent, pev_solid, SOLID_TRIGGER)
set_pev(ent, pev_movetype, MOVETYPE_TOSS)

new Float:mins[3] = { -16.0, -16.0, -16.0 }
new Float:maxs[3] = { 16.0, 16.0, 16.0 }
engfunc(EngFunc_SetSize, ent, mins, maxs)

set_pev(ent, pev_iuser3, user_clip[id])

if (store_bpammo)
{
set_pev(ent, pev_iuser4, user_bpammo[id])
cs_set_user_bpammo(id, CSW_M4A1, 0)
}
else
{
set_pev(ent, pev_iuser4, 0)
}

new Float:angles[3]
pev(id, pev_angles, angles)
angles[0] = angles[2] = 0.0
set_pev(ent, pev_angles, angles)

engfunc(EngFunc_SetModel, ent, hk416_W_Model)

new Float:origin[3]
pev(id, pev_origin, origin)

if (drop_type)
{
new Float:velocity[3]
velocity_by_aim(id, 15, velocity)
origin[0] += velocity[0]
origin[1] += velocity[1]
origin[2] += velocity[2]
set_pev(ent, pev_origin, origin)
velocity_by_aim(id, 400, velocity)
set_pev(ent, pev_velocity, velocity)
}
else
{
new Float:drop_angle = random_float(0.0, 360.0)
origin[0] += 15.0 * floatcos(drop_angle, degrees)
origin[1] += 15.0 * floatsin(drop_angle, degrees)
set_pev(ent, pev_origin, origin)
}

return 1;
}


public client_connect(id)
{
has_hk416[id] = false
}


public client_disconnect(id)
{
has_hk416[id] = false
}


public reset_hk416()
{
for (new id = 1; id <= g_maxplayers; id++)
{
if (is_user_connected(id) && is_user_alive(id) && has_hk416[id] && !user_has_weapon(id, CSW_M4A1))
{
has_hk416[id] = false
}
}
}


stock drop_primary_weapons(id)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)

for (i = 0; i < num; i++)
{
weaponid = weapons

if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
{
static wname[32]
get_weaponname(weaponid, wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}


stock fm_give_item(index, const item[]) 
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0

new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent))
return 0

new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
dllfunc(DLLFunc_Spawn, ent)

new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent

engfunc(EngFunc_RemoveEntity, ent)

return -1
}


stock bool:has_custom_weapons(id, const bitsum)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)

for (i = 0; i < num; i++)
{
weaponid = weapons

if ((1<<weaponid) & bitsum)
return true;
}

return false;
}


stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && (pev(entity, pev_owner) != owner)) {}

return entity;
}


stock fm_find_ent_by_class(index, const classname[])
{
return engfunc(EngFunc_FindEntityByString, index, "classname", classname) 
}


stock fm_kill_entity(index)
{
set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME);

return 1;
}


stock Float:get_weapon_next_pri_attack(entity)
{
return get_pdata_float(entity, OFFSET_FlNextPrimaryAttack, OFFSET_LINUX_WEAPONS)
}


stock set_weapon_next_pri_attack(entity, Float:time)
{
set_pdata_float(entity, OFFSET_FlNextPrimaryAttack, time, OFFSET_LINUX_WEAPONS)
}


stock fm_get_aim_vector(index, forward_distance, Float:forward_origin[3], Float:view_end_origin[3])
{
new Float:start[3], Float:view_ofs[3]
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);

new Float:vector[3], Float:temp[3];
pev(index, pev_v_angle, vector);
engfunc(EngFunc_MakeVectors, vector);
global_get(glb_v_forward, vector);
xs_vec_mul_scalar(vector, float(forward_distance), temp);
xs_vec_add(start, temp, forward_origin);

new Float:dest[3]
xs_vec_mul_scalar(vector, 9999.0, temp);
xs_vec_add(start, temp, dest);
engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
get_tr2(0, TR_vecEndPos, view_end_origin);

return 1;
}


#if defined SUPPORT_CZBOT
// CZBot support
public client_putinserver(id)
{
if (!cvar_botquota || !is_user_bot(id) || BotHasDebug)
return;

new classname[32]
pev(id, pev_classname, classname, 31)

if (!equal(classname, "player"))
set_task(0.1, "_Debug", id)
}
public _Debug(id)
{
// Make sure it's a CZ bot and it's still connected
if (!get_pcvar_num(cvar_botquota) || !is_user_connected(id))
return;

BotHasDebug = true
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_Player_TakeDamage")
RegisterHamFromEntity(Ham_TraceAttack, id, "fw_Player_TraceAttack")
}
#endif



獻花 x0 回到頂端 [樓 主] From:台灣固網股份有限公司 | Posted:2013-09-13 18:42 |
Nailaz 手機
個人頭像
個人文章 個人相簿 個人日記 個人地圖
特殊貢獻獎 社區建設獎 創作大師獎
小有名氣
級別: 小有名氣 該用戶目前不上站
推文 x77 鮮花 x254
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

是不能給檔案嗎= =?
這樣還要編排然後轉檔查錯誤..

還有

你說你寫的

制作by : HKCDC:森之千手
我有看錯嗎..還是你是森之千手?


web front-end and software engineer.
獻花 x0 回到頂端 [1 樓] From:臺灣中華電信股份有限公司 | Posted:2013-09-13 20:21 |
a7811311622 手機
個人頭像
個人文章 個人相簿 個人日記 個人地圖
特殊貢獻獎 優秀管理員勳章 社區建設獎
頭銜:我…在工作了…我…在工作了…
版主
級別: 版主 該用戶目前不上站
版區: CS提問區
推文 x771 鮮花 x2152
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

下面是引用 Nailaz 於 2013-09-13 20:21 發表的 : 到引言文
是不能給檔案嗎= =?
這樣還要編排然後轉檔查錯誤..

還有

你說你寫的

制作by : HKCDC:森之千手
我有看錯嗎..還是你是森之千手?
不是…那是個比史萊姆插件製作器更早期的插件製作器…


尚無簽名,歡迎 [新增個性化簽名]
獻花 x0 回到頂端 [2 樓] From:臺灣中華電信股份有限公司 | Posted:2013-09-14 00:38 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.081844 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言