Hồi trước tôi cũng ném 1 đống model CSO vào server sau đó chán 
@SONTUNG:
Trong CSO_NST của bạn chia tay NAM và NỮ rất hay. Bạn chỉ mình đoạn code đó được không? Mình có dự định với các Skinner của CSCF cho 1 skin 5 group hand. Rất cần dùng thuật toán đó. Nếu không bạn chỉ mình hàm nào set group cũng ok ! Đa tạ trước!
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <nst_player>
#define PLUGIN "NST Wpn Hand"
#define VERSION "1.0"
#define AUTHOR "NST"
new cvar_run
new g_wpn[33], g_silen[33][CSW_P90+1], g_attack[33], g_anim[33], g_glock[33], g_change[33]
const SILENT_BS = ((1<<CSW_USP)|(1<<CSW_M4A1))
const PISTOLS_BS = ((1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE))
const m_iId = 43
const m_fSilent = 74
enum
{
ANIM_DRAW = 1,
ANIM_SHOOT,
ANIM_SHOOT2,
ANIM_SHOOT_EMPTY
}
new const V_KNIFE[2][] = {"models/v_knife.mdl", "models/nst_wpn/v_knife_w.mdl"}
new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
"weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
"weapon_ak47", "weapon_knife", "weapon_p90" }
new g_fwWeaponDraw, g_fwDummyResult
const NOSHOOT2_BS = ((1<<CSW_KNIFE)|(1<<CSW_GLOCK18)|(1<<CSW_ELITE))
// ########################## MAIN PLUGINS ##########################
public plugin_natives()
{
register_native("nst_wpn_send_weapon_anim", "natives_send_weapon_anim", 1)
}
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, V_KNIFE[0])
engfunc(EngFunc_PrecacheModel, V_KNIFE[1])
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
cvar_run = register_cvar("nst_wpn_hand", "1")
for (new i=1; i<=CSW_P90; i++)
{
if (strlen(WEAPONENTNAMES[i]))
{
RegisterHam(Ham_Weapon_SendWeaponAnim, WEAPONENTNAMES[i], "fw_Weapon_SendWeaponAnim")
RegisterHam(Ham_Weapon_PrimaryAttack, WEAPONENTNAMES[i], "fw_primary_attack_post",1)
RegisterHam(Ham_Item_PostFrame, WEAPONENTNAMES[i], "fw_Item_PostFrame")
}
}
register_event("CurWeapon","checkWeapon","be","1=1")
register_forward(FM_CmdStart, "fw_CmdStart")
//register_concmd("qq", "qq")
// Custom Forwards
g_fwWeaponDraw = CreateMultiForward("nst_wpn_weapon_draw", ET_IGNORE, FP_CELL)
}
// ########################## MAIN PUBLIC ##########################
public fw_Item_PostFrame(ent)
{
new id = pev(ent, pev_owner)
if (!is_user_connected(id)) return HAM_IGNORED
// check silent
static iId ; iId = get_pdata_int(ent, m_iId, 4)
if (SILENT_BS & (1<<iId))
{
if (get_pdata_int(ent, m_fSilent, 4)) g_silen[id][iId] = 1
else g_silen[id][iId] = 0
}
return HAM_IGNORED
}
public fw_Weapon_SendWeaponAnim(ent, iAnim, skiplocal, body)
{
new id = pev(ent, pev_owner)
if (!is_user_connected(id)) return HAM_IGNORED
g_attack[id] = 0
playanim(id, iAnim)
// Fix Anim Glock18
new classname[64]
pev(ent, pev_classname, classname, charsmax(classname))
new idwpn = cs_weapon_name_to_id(classname)
if (iAnim == get_num_anim(id, idwpn, ANIM_DRAW) && g_wpn[id] == idwpn)
{
g_change[id] = 1
ExecuteForward(g_fwWeaponDraw, g_fwDummyResult, id)
//client_print(0, print_chat, "[%s][%s]", g_weapon_models[id][0], g_weapon_models[id][1])
return HAM_SUPERCEDE
}
if (idwpn == CSW_GLOCK18)
{
if (iAnim == 8 || iAnim == 11) g_anim[id] = iAnim
else if (iAnim == 0 || iAnim == 1 || iAnim == 2)
{
g_glock[id] = 1
g_anim[id] = iAnim
}
else g_anim[id] = 0
}
//client_print(0, print_chat, "[%i][%i][%i][%i]", id, iAnim, skiplocal, body)
return HAM_IGNORED
}
public fw_primary_attack_post(ent)
{
new id = pev(ent, pev_owner)
if (!is_user_connected(id)) return HAM_IGNORED
new plrClip, plrAmmo
get_user_weapon(id, plrClip , plrAmmo)
if (plrClip)
{
g_attack[id] = 1
}
return HAM_IGNORED
}
public checkWeapon(id)
{
new plrClip, plrAmmo, plrWeapId
plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
if (g_attack[id])
{
new ani
if (!plrClip) ani = get_num_anim(id, plrWeapId, ANIM_SHOOT_EMPTY)
else if (!ani) ani = get_num_anim(id, plrWeapId, ANIM_SHOOT)
playanim(id, ani)
g_attack[id] = 0
}
if (plrWeapId == CSW_KNIFE)
{
new model_v[64]
pev(id, pev_viewmodel2, model_v, charsmax(model_v))
if (equal(model_v, V_KNIFE[0]))
{
if (nst_get_user_sex(id) == 2) set_pev(id, pev_viewmodel2, V_KNIFE[1])
else set_pev(id, pev_viewmodel2, V_KNIFE[0])
}
}
//client_print(id, print_chat, "2[%i]", plrClip)
}
public fw_CmdStart(id, uc_handle, seed)
{
//new num = pev(id, pev_weaponanim)
//client_print(id, print_chat, "AT[%i]", g_silen[id])
if (!is_user_alive(id)) return;
new plrClip, plrAmmo, plrWeapId
plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
if (g_wpn[id] != plrWeapId || g_change[id])
{
new anim = get_num_anim(id, plrWeapId, ANIM_DRAW)
if (plrWeapId == CSW_GLOCK18)
{
anim = max(anim, g_anim[id])
g_anim[id] = 0
}
playanim(id, anim)
g_wpn[id] = plrWeapId
g_attack[id] = 0
g_change[id] = 0
}
else if (!g_attack[id])
{
if (plrWeapId == CSW_GLOCK18 && g_glock[id])
{
playanim(id, g_anim[id])
g_glock[id] = 0
g_anim[id] = 0
}
}
}
public qq(id)
{
}
// ########################## FUNCTION ##########################
playanim(player, anim)
{
if (!is_user_alive(player) || !get_pcvar_num(cvar_run)) return;
if (g_wpn[player] == CSW_ELITE && g_attack[player]) return;
new hand = nst_get_user_hand(player)
if (!hand) return;
//set_pev(player, pev_weaponanim, anim)
message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
write_byte(anim)
write_byte(hand)
message_end()
}
playanim2(player, anim)
{
new hand = nst_get_user_hand(player)
//set_pev(player, pev_weaponanim, anim)
message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
write_byte(anim)
write_byte(hand)
message_end()
}
cs_weapon_name_to_id(const weapon[])
{
static i
for (i = 0; i < sizeof WEAPONENTNAMES; i++)
{
if (equal(weapon, WEAPONENTNAMES[i]))
return i;
}
return 0;
}
get_num_anim(id, wpn, type)
{
// type = 1 : draw - type = 2 : shoot
new draw, shoot, shoot_empty
switch(wpn)
{
case CSW_AK47:
{
draw = 2
shoot = 3
}
case CSW_AUG:
{
draw = 2
shoot = 3
}
case CSW_AWP:
{
draw = 5
shoot = 1
}
case CSW_DEAGLE:
{
draw = 5
shoot = 1
shoot_empty = 3
}
case CSW_ELITE:
{
draw = 15
shoot = 6
shoot_empty = 7
}
case CSW_FAMAS:
{
draw = 2
shoot = 3
}
case CSW_FIVESEVEN:
{
draw = 5
shoot = 1
shoot_empty = 3
}
case CSW_G3SG1:
{
draw = 4
shoot = 1
}
case CSW_GALIL:
{
draw = 2
shoot = 3
}
case CSW_GLOCK18:
{
draw = 8
shoot = 5
shoot_empty = 6
}
case CSW_KNIFE:
{
draw = 3
shoot = 1
}
case CSW_M3:
{
draw = 6
shoot = 1
}
case CSW_M4A1:
{
draw = 12
shoot = 8
}
case CSW_M249:
{
draw = 4
shoot = 1
}
case CSW_MAC10:
{
draw = 2
shoot = 3
}
case CSW_MP5NAVY:
{
draw = 2
shoot = 3
}
case CSW_P90:
{
draw = 2
shoot = 3
}
case CSW_P228:
{
draw = 6
shoot = 1
shoot_empty = 4
}
case CSW_SCOUT:
{
draw = 4
shoot = 1
}
case CSW_SG550:
{
draw = 4
shoot = 1
}
case CSW_SG552:
{
draw = 2
shoot = 3
}
case CSW_TMP:
{
draw = 2
shoot = 3
}
case CSW_UMP45:
{
draw = 2
shoot = 3
}
case CSW_USP:
{
draw = 14
shoot = 9
shoot_empty = 12
}
case CSW_XM1014:
{
draw = 6
shoot = 1
}
case CSW_C4:
{
draw = 1
}
case CSW_HEGRENADE:
{
draw = 3
}
case CSW_FLASHBANG:
{
draw = 3
}
case CSW_SMOKEGRENADE:
{
draw = 3
}
}
// silen wpn
if (wpn == CSW_M4A1 && g_silen[id][CSW_M4A1])
{
draw -= 7
shoot -= 7
shoot_empty -= 7
}
else if (wpn == CSW_USP && g_silen[id][CSW_USP])
{
draw -= 8
shoot -= 8
shoot_empty -= 8
}
// random anim shoot2
if (!(NOSHOOT2_BS & (1<<wpn))) shoot += random_num(0, 1)
// return value
if (type == ANIM_DRAW) return draw
else if (type == ANIM_SHOOT) return shoot
else if (type == ANIM_SHOOT_EMPTY) return shoot_empty
return 0
}
// ########################## NATIVES ##########################
public natives_send_weapon_anim(player, anim)
{
playanim2(player, anim)
return 1
}
về tự vọc nhớPHP:#include <amxmodx> #include <hamsandwich> #include <fakemeta> #include <nst_player> #define PLUGIN "NST Wpn Hand" #define VERSION "1.0" #define AUTHOR "NST" new cvar_run new g_wpn[33], g_silen[33][CSW_P90+1], g_attack[33], g_anim[33], g_glock[33], g_change[33] const SILENT_BS = ((1<<CSW_USP)|(1<<CSW_M4A1)) const PISTOLS_BS = ((1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)) const m_iId = 43 const m_fSilent = 74 enum { ANIM_DRAW = 1, ANIM_SHOOT, ANIM_SHOOT2, ANIM_SHOOT_EMPTY } new const V_KNIFE[2][] = {"models/v_knife.mdl", "models/nst_wpn/v_knife_w.mdl"} new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249", "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552", "weapon_ak47", "weapon_knife", "weapon_p90" } new g_fwWeaponDraw, g_fwDummyResult const NOSHOOT2_BS = ((1<<CSW_KNIFE)|(1<<CSW_GLOCK18)|(1<<CSW_ELITE)) // ########################## MAIN PLUGINS ########################## public plugin_natives() { register_native("nst_wpn_send_weapon_anim", "natives_send_weapon_anim", 1) } public plugin_precache() { engfunc(EngFunc_PrecacheModel, V_KNIFE[0]) engfunc(EngFunc_PrecacheModel, V_KNIFE[1]) } public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) cvar_run = register_cvar("nst_wpn_hand", "1") for (new i=1; i<=CSW_P90; i++) { if (strlen(WEAPONENTNAMES[i])) { RegisterHam(Ham_Weapon_SendWeaponAnim, WEAPONENTNAMES[i], "fw_Weapon_SendWeaponAnim") RegisterHam(Ham_Weapon_PrimaryAttack, WEAPONENTNAMES[i], "fw_primary_attack_post",1) RegisterHam(Ham_Item_PostFrame, WEAPONENTNAMES[i], "fw_Item_PostFrame") } } register_event("CurWeapon","checkWeapon","be","1=1") register_forward(FM_CmdStart, "fw_CmdStart") //register_concmd("qq", "qq") // Custom Forwards g_fwWeaponDraw = CreateMultiForward("nst_wpn_weapon_draw", ET_IGNORE, FP_CELL) } // ########################## MAIN PUBLIC ########################## public fw_Item_PostFrame(ent) { new id = pev(ent, pev_owner) if (!is_user_connected(id)) return HAM_IGNORED // check silent static iId ; iId = get_pdata_int(ent, m_iId, 4) if (SILENT_BS & (1<<iId)) { if (get_pdata_int(ent, m_fSilent, 4)) g_silen[id][iId] = 1 else g_silen[id][iId] = 0 } return HAM_IGNORED } public fw_Weapon_SendWeaponAnim(ent, iAnim, skiplocal, body) { new id = pev(ent, pev_owner) if (!is_user_connected(id)) return HAM_IGNORED g_attack[id] = 0 playanim(id, iAnim) // Fix Anim Glock18 new classname[64] pev(ent, pev_classname, classname, charsmax(classname)) new idwpn = cs_weapon_name_to_id(classname) if (iAnim == get_num_anim(id, idwpn, ANIM_DRAW) && g_wpn[id] == idwpn) { g_change[id] = 1 ExecuteForward(g_fwWeaponDraw, g_fwDummyResult, id) //client_print(0, print_chat, "[%s][%s]", g_weapon_models[id][0], g_weapon_models[id][1]) return HAM_SUPERCEDE } if (idwpn == CSW_GLOCK18) { if (iAnim == 8 || iAnim == 11) g_anim[id] = iAnim else if (iAnim == 0 || iAnim == 1 || iAnim == 2) { g_glock[id] = 1 g_anim[id] = iAnim } else g_anim[id] = 0 } //client_print(0, print_chat, "[%i][%i][%i][%i]", id, iAnim, skiplocal, body) return HAM_IGNORED } public fw_primary_attack_post(ent) { new id = pev(ent, pev_owner) if (!is_user_connected(id)) return HAM_IGNORED new plrClip, plrAmmo get_user_weapon(id, plrClip , plrAmmo) if (plrClip) { g_attack[id] = 1 } return HAM_IGNORED } public checkWeapon(id) { new plrClip, plrAmmo, plrWeapId plrWeapId = get_user_weapon(id, plrClip , plrAmmo) if (g_attack[id]) { new ani if (!plrClip) ani = get_num_anim(id, plrWeapId, ANIM_SHOOT_EMPTY) else if (!ani) ani = get_num_anim(id, plrWeapId, ANIM_SHOOT) playanim(id, ani) g_attack[id] = 0 } if (plrWeapId == CSW_KNIFE) { new model_v[64] pev(id, pev_viewmodel2, model_v, charsmax(model_v)) if (equal(model_v, V_KNIFE[0])) { if (nst_get_user_sex(id) == 2) set_pev(id, pev_viewmodel2, V_KNIFE[1]) else set_pev(id, pev_viewmodel2, V_KNIFE[0]) } } //client_print(id, print_chat, "2[%i]", plrClip) } public fw_CmdStart(id, uc_handle, seed) { //new num = pev(id, pev_weaponanim) //client_print(id, print_chat, "AT[%i]", g_silen[id]) if (!is_user_alive(id)) return; new plrClip, plrAmmo, plrWeapId plrWeapId = get_user_weapon(id, plrClip , plrAmmo) if (g_wpn[id] != plrWeapId || g_change[id]) { new anim = get_num_anim(id, plrWeapId, ANIM_DRAW) if (plrWeapId == CSW_GLOCK18) { anim = max(anim, g_anim[id]) g_anim[id] = 0 } playanim(id, anim) g_wpn[id] = plrWeapId g_attack[id] = 0 g_change[id] = 0 } else if (!g_attack[id]) { if (plrWeapId == CSW_GLOCK18 && g_glock[id]) { playanim(id, g_anim[id]) g_glock[id] = 0 g_anim[id] = 0 } } } public qq(id) { } // ########################## FUNCTION ########################## playanim(player, anim) { if (!is_user_alive(player) || !get_pcvar_num(cvar_run)) return; if (g_wpn[player] == CSW_ELITE && g_attack[player]) return; new hand = nst_get_user_hand(player) if (!hand) return; //set_pev(player, pev_weaponanim, anim) message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player) write_byte(anim) write_byte(hand) message_end() } playanim2(player, anim) { new hand = nst_get_user_hand(player) //set_pev(player, pev_weaponanim, anim) message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player) write_byte(anim) write_byte(hand) message_end() } cs_weapon_name_to_id(const weapon[]) { static i for (i = 0; i < sizeof WEAPONENTNAMES; i++) { if (equal(weapon, WEAPONENTNAMES[i])) return i; } return 0; } get_num_anim(id, wpn, type) { // type = 1 : draw - type = 2 : shoot new draw, shoot, shoot_empty switch(wpn) { case CSW_AK47: { draw = 2 shoot = 3 } case CSW_AUG: { draw = 2 shoot = 3 } case CSW_AWP: { draw = 5 shoot = 1 } case CSW_DEAGLE: { draw = 5 shoot = 1 shoot_empty = 3 } case CSW_ELITE: { draw = 15 shoot = 6 shoot_empty = 7 } case CSW_FAMAS: { draw = 2 shoot = 3 } case CSW_FIVESEVEN: { draw = 5 shoot = 1 shoot_empty = 3 } case CSW_G3SG1: { draw = 4 shoot = 1 } case CSW_GALIL: { draw = 2 shoot = 3 } case CSW_GLOCK18: { draw = 8 shoot = 5 shoot_empty = 6 } case CSW_KNIFE: { draw = 3 shoot = 1 } case CSW_M3: { draw = 6 shoot = 1 } case CSW_M4A1: { draw = 12 shoot = 8 } case CSW_M249: { draw = 4 shoot = 1 } case CSW_MAC10: { draw = 2 shoot = 3 } case CSW_MP5NAVY: { draw = 2 shoot = 3 } case CSW_P90: { draw = 2 shoot = 3 } case CSW_P228: { draw = 6 shoot = 1 shoot_empty = 4 } case CSW_SCOUT: { draw = 4 shoot = 1 } case CSW_SG550: { draw = 4 shoot = 1 } case CSW_SG552: { draw = 2 shoot = 3 } case CSW_TMP: { draw = 2 shoot = 3 } case CSW_UMP45: { draw = 2 shoot = 3 } case CSW_USP: { draw = 14 shoot = 9 shoot_empty = 12 } case CSW_XM1014: { draw = 6 shoot = 1 } case CSW_C4: { draw = 1 } case CSW_HEGRENADE: { draw = 3 } case CSW_FLASHBANG: { draw = 3 } case CSW_SMOKEGRENADE: { draw = 3 } } // silen wpn if (wpn == CSW_M4A1 && g_silen[id][CSW_M4A1]) { draw -= 7 shoot -= 7 shoot_empty -= 7 } else if (wpn == CSW_USP && g_silen[id][CSW_USP]) { draw -= 8 shoot -= 8 shoot_empty -= 8 } // random anim shoot2 if (!(NOSHOOT2_BS & (1<<wpn))) shoot += random_num(0, 1) // return value if (type == ANIM_DRAW) return draw else if (type == ANIM_SHOOT) return shoot else if (type == ANIM_SHOOT_EMPTY) return shoot_empty return 0 } // ########################## NATIVES ########################## public natives_send_weapon_anim(player, anim) { playanim2(player, anim) return 1 }
cậu copy file hamsandwich.dll từ cso nst qua thì mới chạy đc
+1 Ha hathế đừng script nữa, dùng plugin có sẵn thôi
vì cái hamsandwich.dll mặc định không hỗ trợ Ham_Weapon_SendWeaponAnim (vào là bị đơ)@sontung0 : hamsandwich của ông khác j với hamsandwich của amx , hay chỉ là bản build mới hơn ??....
public fw_Weapon_SendWeaponAnim(ent, iAnim, skiplocal, body)
tớ toàn xem native trong các file ini của amxx và các plugin mẫu thôiThanks so much!Vọc là khả năng tốt nhất của tớ mà! À có ít ebook hay web nào vọc AMXX cậu share tớ với ! Thấy code của cậu có những hàm lạ hoắc ko có trong ebook amxx của tớ! NICE!