Raised This Month: $32 Target: $400
 8% 

[nst_wpn system] knife delay


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CSNAVYFIRE
New Member
Join Date: May 2014
Old 05-18-2014 , 07:06   [nst_wpn system] knife delay
Reply With Quote #1

Well currently , you have probably know CSO-NST right ? I have his source code from beta 2. But the problem is the melee wpn that i add in can't stab correctly(delay). I mean the animation is't finished yet but the player has taken damage. I have the plugin here but i still don't figure out what it's used for
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <xs>
#include <engine>
#include <nst_zombie>
#include <nst_wpn>

// Var main
const TYPE_WPN NST_WPN_KNIFE
const MAX_WPN 32
const MAX_MYWPN 6
new COUNT_WPN

new c_name[MAX_WPN][64]
new 
c_model[MAX_WPN][32]
new 
c_wpnchange[MAX_WPN]
new 
c_gravity[MAX_WPN]
new 
c_team[MAX_WPN]
new 
c_buy[MAX_WPN]
new 
c_knockback[MAX_WPN]
new 
Float:c_deploy[MAX_WPN]
new 
Float:c_damage[MAX_WPN]
new 
Float:c_time_attack[MAX_WPN]
new 
c_cost[MAX_WPN]
new 
c_model_p[MAX_WPN][64]
new 
c_model_v[MAX_WPN][64]
new 
c_model_v_bl[MAX_WPN][64]
new 
c_model_v_gr[MAX_WPN][64]
new 
c_sound_miss[MAX_WPN][64]
new 
c_sound_hitwall[MAX_WPN][64]
new 
c_sound_hit1[MAX_WPN][64]
new 
c_sound_hit2[MAX_WPN][64]
new 
c_sound_stab[MAX_WPN][64]

//for delay knife damage
const Float:def_first_attack 0.5
const Float:def_second_attack 1.2
const Float:def_range 70.0
const Float:def_first_dmg_delay 0.25
const Float:def_second_dmg_delay 0.5
const Float:def_second_dmg 100.0
new Float:g_fDelay[33]
enum
{
    
ANIM_IDLE,
    
ANIM_SLASH1,
    
ANIM_SLASH2,
    
ANIM_DRAW,
    
ANIM_STAB,
    
ANIM_STAB_MISS,
    
ANIM_MIDSLASH1,
    
ANIM_MIDSLASH2
}

// main value
new g_weapon[33], g_lastbuy[33], g_canbuy[33]

////for show weapon pickup///////////
new pre_weapon[64] = "0";
////////////////////////////
// my weapons
new g_mywpn[MAX_MYWPN], g_mywpn_cache[MAX_MYWPN][32], total_mywpn_cache

// section config
enum
{
    
SECTION_TYPE 0,
    
SECTION_NAME,
    
SECTION_MODEL,
    
SECTION_WPNCHANGE,
    
SECTION_DAMAGE,
    
SECTION_GRAVITY,
    
SECTION_KNOCKBACK,
    
SECTION_DEPLOY,
    
SECTION_COST
    
SECTION_TEAM,
    
SECTION_BUY,
    
SECTION_TIME_ATTACK
}

// Task offsets
enum (+= 100)
{
    
TASK_GIVEWPN 2000,
    
TASK_GIVEWPNBOT
}
#define ID_GIVEWPN (taskid - TASK_GIVEWPN)
#define ID_GIVEWPNBOT (taskid - TASK_GIVEWPNBOT)
//for delay damage
#define task_execute_my_damage 25251325

new g_msgTextMsg
new g_hamczbotscvar_botquota

// cs offsets value
const m_pPlayer            41
const m_flNextPrimaryAttack    46
const m_flNextSecondaryAttack    47
const m_flTimeWeaponIdle    48
const m_flNextAttack        83


//##############################################################
// REGISTER PLUGIN
//##############################################################
public plugin_natives()
{
    
register_native("nst_wpn_give_weapon3""natives_give_weapon"1)
    
register_native("nst_wpn_get_int3""natives_get_int"1)
    
register_native("nst_wpn_get_float3""natives_get_float"1)
    
}
public 
plugin_precache()
{
    
// get list weapon cache
    
mywpn_create_ini(NST_WPN_INI_READ)
    
    
// load config
    
load_config_from_files()
    
    
// create mywpn
    
mywpn_create_mywpn()
}
public 
plugin_init()
{
    
register_plugin(NST_WPN_NAME_KNIFENST_WPN_VERSIONNST_WPN_AUTHOR)
    
    
// Language files
    
register_dictionary(NST_WPN_LANG_FILE)
    
    
// idmsg
    
g_msgTextMsg get_user_msgid("TextMsg")
    
    
// Reg Public
    
register_event("CurWeapon","event_CurWeapon","be","1=1")
    
register_event("HLTV""event_start_freezetime""a""1=0""2=0")
    
register_forward(FM_EmitSound,"fw_emitsound")
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
    
register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
    
    
// Reg Cmd
    
register_clcmd("nst_menu_wpn3""cmd_menu_wpn")
    
register_clcmd("nst_rebuy_wpn3""cmd_rebuy_wpn")
    
register_clcmd("nst_buy_wpn""cmd_buy_wpn")
    
register_clcmd("nst_buy_mywpn""cmd_buy_mywpn")
    
    
cvar_botquota get_cvar_pointer("bot_quota")

    
//delay damage for knife
    
register_forward(FM_CmdStart"fw_cmdstart")
    
register_forward(FM_UpdateClientData"fm_update_data"1)

}
public 
execute_my_damage(taskid)
{
    new 
id taskid task_execute_my_damage
    
if (!is_user_alive(id))
        return
    if (
get_user_weapon(id) != CSW_KNIFE)
        return
    
// Find target
    
new Float:ftorigin[3]
    new 
Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
    new 
aimOrigin[3], targetbody
    get_user_origin
(idaimOrigin0)
    
get_user_aiming(idtargetbody)
    
get_user_origin(idRetVec4)
    
pev(targetpev_originftorigin)
    
IVecFVec(aimOriginfaimOrigin)
    
IVecFVec(RetVecfRetVec)
    new 
hitplace
    
new ent find_ent_by_owner(-1"weapon_knife"id)
    if(
target && target <= get_maxplayers())
    {    
        new 
Float:range vector_distance(faimOriginftorigin)
        if (
range <= def_range)
        {
            if (
body != 8)
            {
                if (!
get_cvar_num("mp_friendlyfire"))
                    if (
get_user_team(id) == get_user_team(target))
                        return
                
ExecuteHamB(Ham_TakeDamagetargetentiddef_second_dmgDMG_SLASH)
                
ExecuteHamB(Ham_TraceAttacktargetiddef_second_dmgfRetVecbodyDMG_SLASH)
                
//fakedamage(target, "", damage , DMG_BULLET)
                
if (body == HIT_HEAD)
                    
hitplace 1
                
if (body != HIT_HEAD)
                    
hitplace 0
                
new random_sound random_num(14)
                new 
random_file[256]
                
format(random_file255"weapons/knife_hit%d.wav"random_sound)
                
emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                
//if (!is_user_alive(target))
                //    g4u_set_knife_kill(id, hitplace)
                
            
}
            else
            {
                new 
random_sound random_num(12)
                new 
random_file[256]
                
format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                
emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
            }
        } 
    }
    else 
    {
        if(
target)
        {
            new 
torigin[3]
            
get_user_origin(idtorigin3)
            
IVecFVec(toriginftorigin)
            new 
Float:range vector_distance(faimOriginftorigin)
            if (
range <= def_range)
            {
                new 
classname[32]
                
pev(targetpev_classnameclassname31)
                if (
equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                {
                    new 
Float:hdamage random_float(80.0100.0)
                    
fakedamage(target"knife"hdamage DMG_SLASH)
                    new 
health pev(targetpev_health)
                    if (
pev(targetpev_iuser1) < 1)
                    {
                        if (
float(health) - hdamage 0.0 )
                        {
                            
client_print(idprint_center"#Injured_Hostage")
                            
cs_set_user_money(idcs_get_user_money(id) - 3001)
                        }
                        else
                        {
                            
client_print(idprint_center"#Killed_Hostage")
                            
cs_set_user_money(idcs_get_user_money(id) - 33001)
                            
cs_set_user_hostagekills(idcs_get_user_hostagekills(id) + 1)
                            
set_pev(targetpev_iuser11)
                        }
                    }
                    
//ExecuteHamB(Ham_TakeDamage, target, ent, id, random_float(damage, damage * 1.5), DMG_SLASH)
                
}
                if (
equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                {
                    new 
flags pev(targetpev_spawnflags)
                    if (
flags != SF_BREAK_TRIGGER_ONLY)
                        
ExecuteHamB(Ham_TakeDamagetargetentidrandom_float(80.0100.0), DMG_SLASH)
                    
//fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                    
emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            new 
torigin[3]
            
get_user_origin(idtorigin3)
            
IVecFVec(toriginftorigin)
            new 
Float:range vector_distance(faimOriginftorigin)
            if (
range <= def_range)
                
emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
        }
    }
}

public 
fm_update_data(idsendweaponcd_handle)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED
    
if (get_user_weapon(id) != CSW_KNIFE)
        return 
FMRES_IGNORED
    set_cd
(cd_handleCD_flNextAttackget_gametime() + 0.00001)
    return 
FMRES_HANDLED
}

public 
fw_cmdstart(iduchandleseed)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED
        
if (get_user_weapon(id) == CSW_KNIFE)
        {
                new 
button get_uc(uchandleUC_Buttons)
                if (
button IN_ATTACK)
                {
                    
set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK)
                    if (
get_gametime() - g_fDelay[id] >= def_first_attack)
                    {
                        new 
ent find_ent_by_owner(-1"weapon_knife"id)
                        
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
                        
g_fDelay[id] = get_gametime()
                        
set_pdata_float(ent46def_first_attack4)
                        
                    }
                }
                else if (
button IN_ATTACK2)
                {
                    
set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK2)
                    if (
get_gametime() - g_fDelay[id] >= def_second_attack)
                    {
                        
//if (task_exists(id + task_execute_my_damage))
                            //remove_task(id + task_execute_my_damage)
                        
new ent find_ent_by_owner(-1"weapon_knife"id)
                        
set_task(def_second_dmg_delay"execute_my_damage"id task_execute_my_damage)
                        
SendWeaponAnim(idANIM_STAB)
                        
g_fDelay[id] = get_gametime()
                        
set_pdata_float(ent46def_second_attack4)
                        
                    }
                }
        }

    return 
FMRES_IGNORED
}



//##############################################################
// LOAD CONFIG
//##############################################################
new data_name[64], data_model[32], data_wpnchangeFloat:data_damagedata_gravitydata_costdata_teamdata_buydata_knockbackFloat:data_deployFloat:data_time_attack
load_config_from_files
()
{
    
// Build customization file path
    
new path[64]
    
get_configsdir(pathcharsmax(path))
    
format(pathcharsmax(path), "%s/%s"pathNST_WPN_SETTING_FILE)
    
    
// File not present
    
if (!file_exists(path))
    {
        new 
error[100]
        
formatex(errorcharsmax(error), "Cannot load customization file %s!"path)
        
set_fail_state(error)
        return;
    }
    
    
// Set up some vars to hold parsing info
    
new linedata[1024], key[64], value[960]
    
    
// Open customization file for reading
    
new file fopen(path"rt")
    new 
idwpn 1
    
while (file && !feof(file))
    {
        
// Read one line at a time
        
fgets(filelinedatacharsmax(linedata))
        
        
// Replace newlines with a null character to prevent headaches
        
replace(linedatacharsmax(linedata), "^n""")
        
        
// Blank line or comment
        
if (!linedata[0] || linedata[0] == ';') continue;
        
        
// Replace
        
replace_all(linedatacharsmax(linedata), ",""")
        
replace_all(linedatacharsmax(linedata), "[type]"",")
        
replace_all(linedatacharsmax(linedata), "[name]"",")
        
replace_all(linedatacharsmax(linedata), "[model]"",")
        
replace_all(linedatacharsmax(linedata), "[wchange]"",")
        
replace_all(linedatacharsmax(linedata), "[damage]"",")
        
replace_all(linedatacharsmax(linedata), "[gravity]"",")
        
replace_all(linedatacharsmax(linedata), "[knockback]"",")
        
replace_all(linedatacharsmax(linedata), "[deploy]"",")
        
replace_all(linedatacharsmax(linedata), "[cost]"",")
        
replace_all(linedatacharsmax(linedata), "[team]"",")
        
replace_all(linedatacharsmax(linedata), "[buy]"",")
        
replace_all(linedatacharsmax(linedata), "[time_attack]"",")

        
// Get value
        
strtok(linedatakeycharsmax(key), valuecharsmax(value), ',')
        new 
i
        
while (value[0] != && strtok(valuekeycharsmax(key), valuecharsmax(value), ','))
        {
            switch (
i)
            {
                case 
SECTION_NAMEformat(data_namecharsmax(data_name), "%s"key)
                case 
SECTION_MODELformat(data_modelcharsmax(data_model), "%s"key)
                case 
SECTION_WPNCHANGEdata_wpnchange str_to_num(key)
                case 
SECTION_DAMAGEdata_damage str_to_float(key)
                case 
SECTION_GRAVITYdata_gravity str_to_num(key)
                case 
SECTION_KNOCKBACKdata_knockback str_to_num(key)
                case 
SECTION_DEPLOYdata_deploy str_to_float(key)
                case 
SECTION_COSTdata_cost str_to_num(key)
                case 
SECTION_TEAMdata_team str_to_num(key)
                case 
SECTION_BUYdata_buy str_to_num(key)
                case 
SECTION_TIME_ATTACKdata_time_attack str_to_num(key
            }
            
//client_print(0, print_chat, "STT[%i] VL[%s]", i, key)
            
i++
        }
        
        
// no cache weapon can't buy
        
if (!data_buy && !nst_wpn_get_mod_has_supplybox()) continue;

    
// Set Value
        
if (nst_get_weapon_type(data_wpnchange) == TYPE_WPN)
        {
        
// Set Value
            
format(c_name[idwpn], 63"%s"data_name)
            
format(c_model[idwpn], 31"%s"data_model)
            
c_wpnchange[idwpn] = data_wpnchange
            c_gravity
[idwpn] = data_gravity
            c_team
[idwpn] = data_team
            c_buy
[idwpn] = data_buy
            c_knockback
[idwpn] = data_knockback
            c_deploy
[idwpn] = data_deploy
            c_damage
[idwpn] = data_damage
            c_cost
[idwpn] = data_cost
            c_time_attack
[idwpn]= data_time_attack

        
// Precache
            
if ( !nst_wpn_mywpn() || (nst_wpn_mywpn() && mywpn_check_cached(data_model)) || (!data_buy && nst_wpn_get_mod_has_supplybox()) )
            {
                
format(c_model_p[idwpn], 63"models/nst_wpn/p_%s.mdl"data_model)
                
format(c_model_v[idwpn], 63"models/nst_wpn/v_%s.mdl"data_model)
                
precache_model(c_model_p[idwpn])
                
//precache_model(c_model_v[idwpn])
                //testing for bl&gr file v
                
format(c_model_v_bl[idwpn], 63"models/nst_wpn/v_%s_BL.mdl"data_model)
                
format(c_model_v_gr[idwpn], 63"models/nst_wpn/v_%s_GR.mdl"data_model)
                if(
file_exists(c_model_v_bl[idwpn]))
                    
precache_model(c_model_v_bl[idwpn])
                else
                    
precache_model(c_model_v[idwpn])
                if(
file_exists(c_model_v_gr[idwpn]))
                    
precache_model(c_model_v_gr[idwpn])
                
                
format(c_sound_miss[idwpn], 63"weapons/%s_miss.wav"data_model)
                
format(c_sound_hitwall[idwpn], 63"weapons/%s_hitwall.wav"data_model)
                
format(c_sound_hit1[idwpn], 63"weapons/%s_hit1.wav"data_model)
                
format(c_sound_hit2[idwpn], 63"weapons/%s_hit2.wav"data_model)
                
format(c_sound_stab[idwpn], 63"weapons/%s_stab.wav"data_model)
                
precache_sound(c_sound_miss[idwpn])
                
precache_sound(c_sound_hitwall[idwpn])
                
precache_sound(c_sound_hit1[idwpn])
                
precache_sound(c_sound_hit2[idwpn])
                
precache_sound(c_sound_stab[idwpn])
            }

            
COUNT_WPN idwpn
            idwpn
++
        }
        
        
// check max wpn
        
if (idwpn == MAX_WPN) return;
        
//client_print(0, print_chat, "==[%i][%s]", idwpn, linedata)
    
}
}

//##############################################################
// MAIN PUBLIC
//##############################################################
public nst_zb_user_infected(idinfector)
{
    if (
nst_zb_get_user_zombie(id))
    {
        
g_weapon[id] = 0
    
}
}
public 
client_disconnect(id)
{
    
g_weapon[id] = 0
}
public 
client_putinserver(id)
{
    
g_weapon[id] = 0

    
if (is_user_bot(id) && !g_hamczbots && cvar_botquota)
    {
        
set_task(0.1"register_ham_czbots"id)
    }
}
public 
register_ham_czbots(id)
{
    
// Make sure it's a CZ bot and it's still connected
    
if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota))
        return;
        
    
RegisterHamFromEntity(Ham_Spawnid"fw_PlayerSpawn_Post"1)
    
    
// Ham forwards for CZ bots succesfully registered
    
g_hamczbots true
    
    
// If the bot has already spawned, call the forward manually for him
    
if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
}
public 
event_start_freezetime()
{
    new 
reset[33]
    
g_canbuy reset
    
if (nst_zb_remove_weapons_newround()) g_weapon reset
}
public 
message_DeathMsg()
{
    
// get value data
    
static killerweapon[32], weaponidvictim//, headshot
    
killer get_msg_arg_int(1)
    
victim get_msg_arg_int(2)
    
//headshot = get_msg_arg_int(3)
    
get_msg_arg_string(4weaponcharsmax(weapon))
    if (
equali(weapon"grenade")) format(weaponcharsmax(weapon), "hegrenade")
    
format(weaponcharsmax(weapon), "weapon_%s"weapon)
    
weaponid get_weaponid(weapon)    
    
    
// get wpn sprites name
    
new attacker_wpn g_weapon[killer]
    if (
attacker_wpn && weaponid==c_wpnchange[attacker_wpn])
    {
        
// get sprites weapon
        
new sprites_wpn[32]
        
format(sprites_wpncharsmax(sprites_wpn), "%s"c_model[attacker_wpn])
        
        
// send deathmsg
        
set_msg_arg_string(4sprites_wpn)
    }
    
    
// remove wpn of victim
    
g_weapon[victim] = 0
}
// Change Sound
public fw_emitsound(entity,channel,sample[],Float:volume,Float:attenuation,fFlags,pitch)

    new 
id entity
    
    
if (!is_user_connected(id))
        return 
FMRES_IGNORED;
        

    new 
CURENT_WEAPON g_weapon[id]
    new 
CHANGE_WEAPON c_wpnchange[CURENT_WEAPON]
    new 
plrClipplrAmmoplrWeapId
    plrWeapId 
get_user_weapon(idplrClip plrAmmo)
    
    if (
plrWeapId == CHANGE_WEAPON && g_weapon[id])
    {
        new 
sound_new[64]
        if( (
equal(sample,"weapons/knife_slash1.wav")) || (equal(sample,"weapons/knife_slash2.wav")) ) copy(sound_new63c_sound_miss[CURENT_WEAPON])
        else if(
equal(sample,"weapons/knife_hitwall1.wav")) copy(sound_new63c_sound_hitwall[CURENT_WEAPON])
        else if( (
equal(sample,"weapons/knife_hit1.wav")) || (equal(sample,"weapons/knife_hit3.wav"))) copy(sound_new63c_sound_hit1[CURENT_WEAPON])
        else if( (
equal(sample,"weapons/knife_hit2.wav")) || (equal(sample,"weapons/knife_hit4.wav"))) copy(sound_new63c_sound_hit2[CURENT_WEAPON])
        else if(
equal(sample,"weapons/knife_stab.wav")) copy(sound_new63c_sound_stab[CURENT_WEAPON])

        if (
strlen(sound_new)) emit_sound(entity,channel,sound_new,volume,attenuation,fFlags,pitch)
        return 
FMRES_SUPERCEDE
    
}

    return 
FMRES_IGNORED;
}
// Ham Player Spawn Post Forward
public fw_PlayerSpawn_Post(id)
{
    
// Not alive or didn't join a team yet
    
if (!is_user_alive(id))
        return;

    new 
mod_runing nst_get_mod_runing()
    
// set can buy in zb3
    
if (mod_runing == NST_MOD_ZB3)
    {
        
g_canbuy[id] = 0
    
}
    
// give weapon in new round for scenario mod
    
else if (mod_runing == NST_MOD_HMS)
    {
        if (
g_weapon[id]) 
        {
            static 
params[1]
            
params[0] = g_weapon[id]
            if (
task_exists(id+TASK_GIVEWPN)) remove_task(id+TASK_GIVEWPN)
            
set_task(0.1"task_give_wpn"id+TASK_GIVEWPNparamssizeof params)
        }
    }
    
    
// give random weapons for bot
    
if (is_user_bot(id))
    {
        new 
Floattime_give random_float(2.04.0)
        if (
task_exists(id+TASK_GIVEWPNBOT)) remove_task(id+TASK_GIVEWPNBOT)
        
set_task(time_give"task_give_wpn_bot"id+TASK_GIVEWPNBOT)
    }
    
}
public 
task_give_wpn(params[1], taskid)
{
    new 
id ID_GIVEWPN
    give_weapon_mod
(idparams[0])
}
public 
task_give_wpn_bot(taskid)
{
    new 
id ID_GIVEWPNBOT
    
    
new bot_use_wpn random_num(0nst_bot_use_weapons())
    if (
bot_use_wpn)
    {
        if (!
g_weapon[id]) buy_weapon(idget_random_weapon())
    }
}
get_random_weapon()
{
    
// check total weapon can buy
    
new total_canbuy get_total_weapon_buy(1)
    if (!
total_canbuy) return 0;
    
    
// random weapon
    
new idwpn
    
// when use myweapons
    
if (nst_wpn_mywpn())
    {
        if (!
total_mywpn_cache) return 0;

        new 
random(total_mywpn_cache)
        
idwpn get_idwpn_from_model(g_mywpn_cache[i])
        return 
idwpn;
    }
    
// when not use my weapons
    
else
    {
        for (new 
i=0i<MAX_WPNi++)
        {
            
idwpn random_num(1COUNT_WPN)
            if (
c_buy[idwpn]) return idwpn;
        }
    }
    
    return 
0;
}
get_total_weapon_buy(buy)
{
    new 
total
    
for (new i=1i<=COUNT_WPNi++)
    {
        if (
c_buy[i]==buytotal++
    }
    
    return 
total;
}
// Give Weapon
public give_weapon(id)
{
    if (!
is_user_alive(id)) return;

    new 
CURENT_WEAPON g_weapon[id]
    new 
CHANGE_WEAPON c_wpnchange[CURENT_WEAPON]
    
    
// check wpn
    
if (!CHANGE_WEAPON) return;
    
    
// give wpn
    
new weaponname[32]
    
get_weaponname(CHANGE_WEAPONweaponnamecharsmax(weaponname))
    
fm_give_item(idweaponname)
    
    return;
}
// Check Weapon
public checkModel(id)
{    
    if (
nst_zb_get_user_zombie(id)) return PLUGIN_HANDLED

    
new CURENT_WEAPON g_weapon[id]
    new 
CHANGE_WEAPON c_wpnchange[CURENT_WEAPON]
    
    new 
plrClipplrAmmoplrWeapId
    plrWeapId 
get_user_weapon(idplrClip plrAmmo)
    if ( 
plrWeapId == CHANGE_WEAPON && g_weapon[id])
    {
        if(
get_user_team(id)==1)
            if (
file_exists(c_model_v_bl[CURENT_WEAPON])) 
                
set_pev(idpev_viewmodel2,c_model_v_bl[CURENT_WEAPON])
            else
                
set_pev(idpev_viewmodel2c_model_v[CURENT_WEAPON])
        else
            if (
file_exists(c_model_v_gr[CURENT_WEAPON]))     
                
set_pev(idpev_viewmodel2,c_model_v_gr[CURENT_WEAPON])
            else
                
set_pev(idpev_viewmodel2,c_model_v[CURENT_WEAPON])

        
set_pev(idpev_weaponmodel2c_model_p[CURENT_WEAPON])

        if(!
is_user_bot(id))
        {
            
/////////////////////write weapon name to file////////////////
                
new file_name[256]
                
format(file_name255"/addons/amxmodx/configs/current_wpn_name.cfg")
                
write_file(file_name,c_model[g_weapon[id]], 0)
            
//////////////////////////////////////////////////////////////////
        
}

    }
    return 
PLUGIN_HANDLED
}
public 
fw_CmdStart(iduc_handleseed)
{
    new 
CURENT_WEAPON g_weapon[id]
    static 
buttons
    buttons 
get_uc(uc_handleUC_Buttons)
    new 
Float:time_attack c_time_attack[CURENT_WEAPON]
    if ((
buttons IN_ATTACK2))
    {
        
set_player_nextattack(idtime_attack)
    }

}

public 
event_CurWeapon(id)
{
    if (
nst_zb_get_user_zombie(id)) return;

    new 
CURENT_WEAPON g_weapon[id]
    new 
CHANGE_WEAPON c_wpnchange[CURENT_WEAPON]
    
    new 
plrClipplrAmmoplrWeapId
    plrWeapId 
get_user_weapon(idplrClip plrAmmo)

    if (
CURENT_WEAPON && plrWeapId==CHANGE_WEAPON)
    {
        
checkModel(id)
    }
    if(
CURENT_WEAPON==&& !is_user_bot(id))
    {    
        new 
WeaponNum read_data(2)  // read and store the weaponID    
        
if(WeaponNum ==29)
        {
            
/////////////////////write weapon name to file////////////////
                
new file_name[256],temp_normal[64]
                
format(file_name255"/addons/amxmodx/configs/current_wpn_name.cfg")
                
format(temp_normal,63,"%d",WeaponNum)        
                
write_file(file_name,temp_normal0)
            
//////////////////////////////////////////////////////////////////
            //checkModel_Normal(id,WeaponNum)
        
}
    }
    new 
current_wpn_sprite[256],text[64],trash    
    format
(current_wpn_sprite255"/addons/amxmodx/configs/current_wpn_name.cfg")
    
read_file(current_wpn_sprite0text63trash)
    if(
strcmp(pre_weapon,text))
    {
        
Show_WeaponPickup(id)
        
pre_weapon=text
    
}

}


//##############################################################
// BUY WEAPON
//##############################################################
public cmd_buy_wpn(id)
{
    new 
models[64]
    
read_argv(1models63)
    
    new 
idwpn get_idwpn_from_model(models)
    if (
nst_wpn_mywpn()) mywpn_add(ididwpn)
    else 
buy_weapon(ididwpn)
}
public 
cmd_buy_mywpn(id)
{
    new 
models[64]
    
read_argv(1models63)
    
    new 
idwpn get_idwpn_from_model(models)
    
buy_weapon(ididwpn)
}
public 
buy_weapon(ididwpn)
{    
    
// Check can buy weapon
    
if (!is_user_alive(id) || !c_wpnchange[idwpn] || !c_buy[idwpn]) return;
    if (!
nst_wpn_get_canbuy_team_mod() && c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) return;

    
// get value
    
new message[128], buyzonemod_runingfree_wpn
    buyzone 
nst_get_user_buyzone(id)    
    
mod_runing nst_get_mod_runing()
    
free_wpn nst_wpn_free()
    
    
// zombie mod3 can buy weapon
    
if (mod_runing == NST_MOD_ZB3 && g_canbuy[id])
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_BUY_CANNOT")
        
nst_color_saytext(idmessage)
        return;
    }
    
    
// check buyzone
    
if (!buyzone)
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_NOT_BUYZONE")
        
nst_color_saytext(idmessage)
        return;
    }
    
    
// check money
    
new money cs_get_user_money(id)
    if (!
free_wpnmoney -= c_cost[idwpn]
    if (
money<0)
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_ENOUGH_MONEY")
        
nst_color_saytext(idmessage)
        return;
    }
    
    
// buy ammmo if has weapon
    
if (g_weapon[id] == idwpn)
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_BOUGHT"c_name[idwpn])
        
nst_color_saytext(idmessage)
        return;
    }
    
    
// not in mywpn
    
if (nst_wpn_mywpn() && !mywpn_check_cached(c_model[idwpn]) && c_buy[idwpn])
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_NOT_IN_MYWPN"c_name[idwpn])
        
nst_color_saytext(idmessage)
        return;
    }
    
    
// Give weapon
    
give_weapon_mod(ididwpn)
    
nst_set_user_money(idmoney)
    
    
// set can buy zombie mod3
    
if (mod_runing == NST_MOD_ZB3g_canbuy[id] = 1
}
give_weapon_mod(ididwpn)
{
    if (!
c_wpnchange[idwpn]) return;
    
    new 
message[128]
    if (!
is_user_alive(id))
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_BUY_WHEN_ALIVE"c_name[idwpn])
        
nst_color_saytext(idmessage)
        return;
    }
    else if (
nst_zb_get_user_zombie(id))
    {
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_ZOMBIE_NOT_BUY")
        
nst_color_saytext(idmessage)
        return;
    }

    
    if (
c_buy[idwpn]) g_lastbuy[id] = idwpn
    g_weapon
[id] = idwpn
    Show_WeaponPickup
(id)
    
give_weapon(id)
    
checkModel(id)
    if (
get_user_weapon(id) == c_wpnchange[g_weapon[id]]) nst_wpn_send_weapon_anim(id3)
    
    
//format(message, charsmax(message), "^x04[NST Wpn]^x01 %L", LANG_PLAYER, "NOTICE_BUY_COMPLETE", c_name[idwpn])
    //nst_color_saytext(id, message)    
}
get_idwpn_from_model(models[])
{
    for(new 
i=1i<MAX_WPNi++)
    {
        if (
equali(c_model[i], models)) return i;
    }
    return 
0;
}
Show_WeaponPickup(id)
{
    
nst_wpn_show_weaponpickup(idc_model[g_weapon[id]])
}

    
//##############################################################
// MENU WEAPON
//##############################################################
public cmd_menu_wpn(id)
{
    if (!
is_user_alive(id)) return PLUGIN_HANDLED

    
new typetype_str[32], mywpn_enable
    read_argv
(1type_strcharsmax(type_str))
    
type str_to_num(type_str)
    
mywpn_enable nst_wpn_mywpn()
    
    
// member only use main menu wpn if use mywpn
    
if (mywpn_enable && !nst_is_user_admin(id) && type!=NST_MENUWPN_MAIN) return PLUGIN_HANDLED

    
// show menu wpn
    
if (mywpn_enable)
    {
        if (
type==NST_MENUWPN_SHOPmenu_wpn(id)
        else 
menu_mywpn(idtype)
    }
    else 
menu_wpn(id)

    
    return 
PLUGIN_HANDLED
}
menu_wpn(id)
{    
    new 
menuwpn_title[64]
    
format(menuwpn_title63"[%L] %L:"LANG_PLAYER"MENU_TITLE_SHOP"LANG_PLAYER"MENU_TITLE_KNIFE")

    new 
mHandleID menu_create(menuwpn_title"menu_wpn_handler")
    
menu_additem(mHandleID"Default Knife""0"0)
    new 
1check_value 1
    
while(check_value && i<MAX_WPN)
    {
        if ( (!
nst_wpn_mywpn() && !nst_wpn_get_canbuy_team_mod() && c_team[i] && get_user_team(id)!=c_team[i]) || !c_buy[i])
        {
            
i++
            continue;
        }
        
        if (
c_wpnchange[i] <= 0check_value 0
        
if (check_value)
        {
            new 
wpn_cost c_cost[i]
            new 
item_name[150], idwpn[32]
            
format(item_name149"%s: %i$"c_name[i], wpn_cost)
            
format(idwpn31"%i"i)
            
            new 
free_wpncheck_moneyuser_money
            free_wpn 
nst_wpn_free()
            
user_money cs_get_user_money(id)
            if (!
free_wpn && user_money<wpn_cost && !nst_wpn_mywpn()) check_money 1
            
            menu_additem
(mHandleIDitem_nameidwpncheck_money)
        }
        
i++
    }
    
    
menu_display(idmHandleID0)
    return 
PLUGIN_HANDLED
}
public 
menu_wpn_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
idwpn[32], name[32], access
    menu_item_getinfo
(menuitemaccessidwpn31name31access)

    new 
idweapon str_to_num(idwpn)
    if (
nst_wpn_mywpn()) mywpn_add(ididweapon)
    else 
buy_weapon(ididweapon)
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
public 
cmd_rebuy_wpn(id)
{
    new 
idwpn g_lastbuy[id]
    if (
idwpn>0buy_weapon(ididwpn)
    
    return 
PLUGIN_HANDLED
}


//##############################################################
// MY WEAPONS
//##############################################################
// ADD WEAPON INTO MYWEAPONS
mywpn_add(ididwpn)
{
    
// check value
    
if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn] || g_mywpn[0]==idwpn) return;

    
// admin only
    
if (!nst_is_user_admin(id))
    {
        new 
message[128]
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_ONLY_FOR_ADMIN")
        
nst_color_saytext(idmessage)
        return;
    }
    
    
// add new weapon in to my weapons
    
new mywpn_set[MAX_MYWPN], check_hascheck_origin
    check_has 
mywpn_check_has(idwpn)
    
    new 
origin_last MAX_MYWPN-1
    mywpn_set
[0] = idwpn
    
for (new i=1i<MAX_MYWPNi++)
    {
        if (!
check_has || g_mywpn[origin_last]==idwpn)
        {
            
mywpn_set[i] = g_mywpn[i-1]
        }
        else
        {
            if (
g_mywpn[i-1]==idwpncheck_origin 1
            
            
if (check_originmywpn_set[i] = g_mywpn[i]
            else 
mywpn_set[i] = g_mywpn[i-1]

        }
    }
    
g_mywpn mywpn_set
    
    
// update file res & ini
    
mywpn_create_res()
    
mywpn_create_ini(NST_WPN_INI_SAVE)
    
    new 
message[128]
    
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_ADD_MYWPN"c_name[idwpn])
    
nst_color_saytext(0message)
    
format(messagecharsmax(message), "%L"LANG_PLAYER"NOTICE_HELP_MYWPN")
    
SendCenterText(0message)
    
    
// show mywpn
    
menu_mywpn(idNST_MENUWPN_MYWPN)
}
mywpn_check_has(idwpn)
{
    for (new 
i=0i<MAX_MYWPNi++)
    {
        if (
g_mywpn[i]==idwpn) return 1;
    }
    return 
0;
}
mywpn_check_cached(model[])
{
    for (new 
i=0i<MAX_MYWPNi++)
    {
        if (
equali(g_mywpn_cache[i], model)) return 1;
    }
    return 
0;
}
// CREATE INI FILE
mywpn_create_ini(run)
{
    
// Build customization file file_url
    
new file_url[64]
    
get_configsdir(file_urlcharsmax(file_url))
    
format(file_urlcharsmax(file_url), "%s/%s"file_urlNST_MYWPN_SETTING_FILE)
    
    
// File not present
    
if (!file_exists(file_url))
    {
        
write_file(file_url"", -1)
        return;
    }
    
    
// Set up some vars to hold parsing info
    
new linedata[1024], key[64], value[960], ilineset[1024]
    
    
// Open customization file for reading
    
new file fopen(file_url"rt")
    
    while (
file && !feof(file))
    {
        
// Read one line at a time
        
fgets(filelinedatacharsmax(linedata))
        
        
// Replace newlines with a null character to prevent headaches
        
replace(linedatacharsmax(linedata), "^n""")
        
        
// Blank line or comment
        
if (!linedata[0] || linedata[0] == ';')
        {
            
i++
            continue;
        }
        
        
// Get key and value(s)
        
strtok(linedatakeycharsmax(key), valuecharsmax(value), '=')
        
        
// Trim spaces
        
trim(key)
        
trim(value)
        
        
// update weapon
        
if (equali(key"KNIFE"))
        {
            
// update list weapons
            
if (run==NST_WPN_INI_SAVE)
            {
                
// get list weapon
                
new valueset[512]
                for (new 
e=0e<MAX_MYWPNe++)
                {
                    if (!
g_mywpn[e]) continue;
                    
format(valuesetcharsmax(valueset), "%s, %s"valuesetc_model[g_mywpn[e]])
                }
                
                
// save list weapon
                
format(linesetcharsmax(lineset), "%s = %s"keyvalueset[2])
                
write_file(file_urllineseti)
                
//client_print(0, print_chat, "da cap nhat xong")
            
}
            
// set value for g_mywpn in new round
            
else if (run==NST_WPN_INI_READ)
            {
                
strtolower(value)
                new 
e
                
while (e<MAX_MYWPN && value[0] != && strtok(valuekeycharsmax(key), valuecharsmax(value), ','))
                {
                    
trim(key)
                    
trim(value)
                    
format(g_mywpn_cache[e], 31"%s"key)
                    
e++
                }
            }
        }
        
        
i++
    }
}
mywpn_create_mywpn()
{
    new 
idwpn
    
    
// create g_mywpn
    
for (new i=0i<MAX_MYWPNi++)
    {
        
idwpn get_idwpn_from_model(g_mywpn_cache[i])
        if (
c_wpnchange[idwpn])
        {
            
g_mywpn[total_mywpn_cache] = idwpn
            total_mywpn_cache
++
        }
    }
    
    
// update g_mywpn_cache
    
for (new i=0i<MAX_MYWPNi++)
    {
        
idwpn g_mywpn[i]
        if (
c_wpnchange[idwpn]) format(g_mywpn_cache[i], 31"%s"c_model[idwpn])
        else 
format(g_mywpn_cache[i], 31"")
    }
    
}

// CREATE RES FILE
mywpn_create_res()
{
    
// File not present
    
if (!file_exists(nst_mywpn_res_url))
    {
        return;
    }
    
    
// Set up some vars to hold parsing info
    
new linedata[1024], type_wpn_str[32]
    
num_to_str(TYPE_WPNtype_wpn_strcharsmax(type_wpn_str))
    
    
// Open customization file for reading
    
new file fopen(nst_mywpn_res_url"rt")
    
    new 
i
    
while (file && !feof(file))
    {
        
// Read one line at a time
        
fgets(filelinedatacharsmax(linedata))
        
        
// Replace newlines with a null character to prevent headaches
        
replace(linedatacharsmax(linedata), "^n""")
        
replace(linedatacharsmax(linedata), " """)
        
        if (
linedata[0]=='/' && linedata[1]=='/' && linedata[2]==type_wpn_str[0])
        {
            
mywpn_set_row_value(ilinedata)
        }

        
i++
    }
    if (
filefclose(file)
}
mywpn_set_row_value(ilinedata[])
{
    
//client_print(0, print_chat, "[%s]", linedata)
    
new res_row_search[64], res_row_set[64]
    new 
idwpnwpnchange
    
for (new e=0e<MAX_MYWPNe++)
    {
        
idwpn g_mywpn[e]
        
wpnchange c_wpnchange[idwpn]
        
        
// img
        
format(res_row_searchcharsmax(res_row_search), nst_mywpn_res_img_searchTYPE_WPNe+1)
        if (
wpnchangeformat(res_row_setcharsmax(res_row_set), nst_mywpn_res_img_setc_model[idwpn])
        else 
res_row_set nst_mywpn_res_img_none
        
if (equali(linedatares_row_search))
        {
            
write_file(nst_mywpn_res_url_ctres_row_seti+1)
            
write_file(nst_mywpn_res_url_terres_row_seti+1)
            return;
        }
        
// team
        
format(res_row_searchcharsmax(res_row_search), nst_mywpn_res_team_searchTYPE_WPNe+1)
        if (
wpnchangeformat(res_row_setcharsmax(res_row_set), nst_mywpn_res_team_setc_team[idwpn])
        else 
res_row_set nst_mywpn_res_team_none
        
if (equali(linedatares_row_search))
        {
            
write_file(nst_mywpn_res_url_ctres_row_seti+1)
            
write_file(nst_mywpn_res_url_terres_row_seti+1)
            return;
        }
        
// name
        
format(res_row_searchcharsmax(res_row_search), nst_mywpn_res_name_searchTYPE_WPNe+1)
        if (
wpnchangeformat(res_row_setcharsmax(res_row_set), nst_mywpn_res_name_setc_name[idwpn], c_cost[idwpn])
        else 
res_row_set nst_mywpn_res_name_none
        
if (equali(linedatares_row_search))
        {
            
write_file(nst_mywpn_res_url_ctres_row_seti+1)
            
write_file(nst_mywpn_res_url_terres_row_seti+1)
            return;
        }
        
// command
        
format(res_row_searchcharsmax(res_row_search), nst_mywpn_res_bottom_searchTYPE_WPNe+1)
        if (
wpnchangeformat(res_row_setcharsmax(res_row_set), nst_mywpn_res_bottom_setc_model[idwpn])
        else 
res_row_set nst_mywpn_res_bottom_none
        
if (equali(linedatares_row_search))
        {
            
write_file(nst_mywpn_res_url_ctres_row_seti+1)
            
write_file(nst_mywpn_res_url_terres_row_seti+1)
            return;
        }
        
    }
}
// MENU MYWPN
public menu_mywpn(idtype)
{    
    new 
title[64], fun_name[32]
    
format(titlecharsmax(title), "[%L] %L:"LANG_PLAYER"MENU_TITLE_MYWPN"LANG_PLAYER"MENU_TITLE_KNIFE")
    if (
type==NST_MENUWPN_MYWPNformat(fun_namecharsmax(fun_name), "menu_editmywpn_handler")
    else 
format(fun_namecharsmax(fun_name), "menu_mywpn_handler")
    
    new 
mHandleID menu_create(titlefun_name)
    for (new 
i=0i<MAX_MYWPNi++)
    {
        new 
idwpn
        
        
if (type==NST_MENUWPN_MYWPNidwpn g_mywpn[i]
        else 
idwpn get_idwpn_from_model(g_mywpn_cache[i])
        
        if (!
idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
        
        if (
type!=NST_MENUWPN_MYWPN && !nst_wpn_get_canbuy_team_mod() && c_team[idwpn] && get_user_team(id)!=c_team[idwpn])
            continue;
        
        new 
wpn_cost c_cost[idwpn]
        new 
item_name[128], idweapon[32]
        
format(item_namecharsmax(item_name), "%s: %i$"c_name[idwpn], wpn_cost)
        
format(idweaponcharsmax(idweapon), "%i"idwpn)
        
        new 
free_wpncheck_moneyuser_money
        free_wpn 
nst_wpn_free()
        
user_money cs_get_user_money(id)
        if (!
free_wpn && user_money<wpn_costcheck_money 1
        
        menu_additem
(mHandleIDitem_nameidweaponcheck_money)
    }
    
    
menu_display(idmHandleID0)
}
public 
menu_mywpn_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
idwpn[32], name[32], access
    menu_item_getinfo
(menuitemaccessidwpn31name31access)

    new 
idweapon str_to_num(idwpn)
    
buy_weapon(ididweapon)
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
public 
menu_editmywpn_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
idwpn[32], name[32], access
    menu_item_getinfo
(menuitemaccessidwpn31name31access)

    new 
idweapon str_to_num(idwpn)
    
mywpn_remove(ididweapon)
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
mywpn_remove(ididwpn)
{
    if (!
idwpn || !c_wpnchange[idwpn]) return;
    
    if (!
nst_is_user_admin(id))
    {
        new 
message[128]
        
format(messagecharsmax(message), "^x04[NST Wpn]^x01 %L"LANG_PLAYER"NOTICE_ONLY_FOR_ADMIN")
        
nst_color_saytext(idmessage)
        return;
    }
    
    new 
mywpn_set[MAX_MYWPN], check_origin
    
for (new i=0i<MAX_MYWPNi++)
    {
        if (
g_mywpn[i]==idwpn)
        {
            
check_origin i
            g_mywpn
[i] = 0
        
}
    }
    for (new 
i=0i<MAX_MYWPNi++)
    {
        if (!
check_origin)
        {
            if (
i==MAX_MYWPN-1mywpn_set[i] = 0
            
else mywpn_set[i] = g_mywpn[i+1]
        }
        else
        {
            if (
i==MAX_MYWPN-1mywpn_set[i] = 0
            
else if (i>=check_origin && i<MAX_MYWPN-1mywpn_set[i] = g_mywpn[i+1]
            else 
mywpn_set[i] = g_mywpn[i]
        }
    }
    
g_mywpn mywpn_set
    
    
// show menu mywpn
    
menu_mywpn(idNST_MENUWPN_MYWPN)
    
    
// update file res & ini
    
mywpn_create_res()
    
mywpn_create_ini(NST_WPN_INI_SAVE)
}
SendCenterText(idmessage[])
{
    new 
dest
    
if (iddest MSG_ONE
    
else dest MSG_ALL
    
    message_begin
(destg_msgTextMsg, {0,0,0}, id)
    
write_byte(4)
    
write_string(message)
    
message_end()
}


//##############################################################
// STOCK
//##############################################################
stock SendWeaponAnim(idiAnim)
{
    
set_pev(idpev_weaponanimiAnim)
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM_id)
    
write_byte(iAnim)
    
write_byte(pev(id,pev_body))
    
message_end()
}
// Give an item to a player (from fakemeta_util)
stock fm_give_item(id, const item[])
{
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent)) return;
    
    static 
Float:originF[3]
    
pev(idpev_originoriginF)
    
set_pev(entpev_originoriginF)
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
    
dllfunc(DLLFunc_Spawnent)
    
    static 
save
    save 
pev(entpev_solid)
    
dllfunc(DLLFunc_Touchentid)
    if (
pev(entpev_solid) != save)
        return;
    
    
engfunc(EngFunc_RemoveEntityent)
}
stock set_player_nextattack(idFloat:nexttime)
{
    
set_pdata_float(idm_flNextAttacknexttime4)
}


//##############################################################
// NATIVE
//##############################################################
public natives_give_weapon(id, const weapon[])
{
    
param_convert(2)
    
    new 
namewpn[64]
    
format(namewpncharsmax(namewpn), "%s"weapon)
    new 
idwpn get_idwpn_from_model(namewpn)
    
give_weapon_mod(ididwpn)
}
public 
natives_get_int(iddata)
{
    new 
CURENT_WEAPON g_weapon[id]
    new 
CHANGE_WEAPON c_wpnchange[CURENT_WEAPON]
    if (!
CURENT_WEAPON || get_user_weapon(id)!=CHANGE_WEAPON) return 0;
    
    new 
result
    
switch (data)
    {
        case 
NST_WPN_DATA_HASWEAPONresult CURENT_WEAPON
        
case NST_WPN_DATA_KNOCKBACKresult c_knockback[CURENT_WEAPON]
        case 
NST_WPN_DATA_GRAVITYresult c_gravity[CURENT_WEAPON]
    }

    return 
result;
}
public 
Float:natives_get_float(iddata)
{
    new 
CURENT_WEAPON g_weapon[id]
    new 
CHANGE_WEAPON c_wpnchange[CURENT_WEAPON]
    if (!
CURENT_WEAPON || get_user_weapon(id)!=CHANGE_WEAPON) return 0.0;
    
    new 
Float:result
    
switch (data)
    {
        case 
NST_WPN_DATA_DEPLOYresult c_deploy[CURENT_WEAPON]
        case 
NST_WPN_DATA_DAMAGEresult c_damage[CURENT_WEAPON]
    }

    return 
result;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
*/ 
The plugin below is named NST_Wpn_Knife.amxx
Please help me Thank you so much

Last edited by CSNAVYFIRE; 05-18-2014 at 07:07.
CSNAVYFIRE is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-18-2014 , 15:56   Re: [nst_wpn system] knife delay
Reply With Quote #2

https://forums.alliedmods.net/showpo...8&postcount=27
__________________
Black Rose is offline
CSNAVYFIRE
New Member
Join Date: May 2014
Old 05-18-2014 , 20:22   Re: [nst_wpn system] knife delay
Reply With Quote #3

But what you showed me only work for kukri right ?
CSNAVYFIRE is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-19-2014 , 06:16   Re: [nst_wpn system] knife delay
Reply With Quote #4

The code can be edited to whatever. I made it and I have no idea what kukri is. I based it upon the request Randomize made.
__________________
Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode