引用:
原帖由 apple321s 於 2011-4-4 23:52 發表
amxx名稱:tr剩係可以用kf
要唔要幫你改野:不用了,唔該
未test ^^
複製內容到剪貼板
代碼:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|
(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|
(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
public plugin_init()
{
register_plugin("TR Use KF", "1.0", "HsK")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
}
public fw_TouchWeapon(weapon, id)
{
if (fm_cs_get_user_team(id) == 1)
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED;
if (fm_cs_get_user_team(id) != 1)
return FMRES_IGNORED;
if (has_custom_weapons(id, PRIMARY_WEAPONS_BIT_SUM) || has_custom_weapons(id, SECONDARY_WEAPONS_BIT_SUM))
{
fm_strip_user_weapons(id)
fm_give_item(id, "weapon_knife")
}
return FMRES_IGNORED;
}
stock fm_cs_get_user_team(id)
{
return get_pdata_int(id, 114, 5);
}
stock bool:has_custom_weapons(id, const bitsum)
{
// Get user weapons
static weapons[32], num, i, weaponid
num = 0 // reset passed weapons count (bugfix)
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if ((1<<weaponid) & bitsum)
return true;
}
return false;
}
stock fm_create_entity(const classname[])
{
return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))
}
stock fm_strip_user_weapons(index)
{
new ent = fm_create_entity("player_weaponstrip");
if (!pev_valid(ent))
return 0;
dllfunc(DLLFunc_Spawn, ent);
dllfunc(DLLFunc_Use, ent, index);
engfunc(EngFunc_RemoveEntity, ent);
return 1;
}
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 = fm_create_entity(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;
}