#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <hamsandwich>
#include <xs>
#include <nst_zombie>
#include <nst_scenario>
#include <nst_wpn>
#define PLUGIN "NST Wpn Mod"
new const TEST_WPN = 1
// main value
new auto_buy[33], g_weappickup[33], g_freezetime, g_mywpn_enable, g_canbuy[33], g_inbuyzone[33], g_command[33],
g_fastrun[33], Float:g_idle[33], g_current_wpn[33], Float:cl_pushangle[33][3], g_modruning
new cvar_bot_use_weapons, cvar_weapons_stay, cvar_buyzone, cvar_free, cvar_sound_attack, cvar_remove_shield,
cvar_fastrun_speed, cvar_timebuy, cvar_sight_recoil, cvar_sight_speed_player, cvar_sight_speed_weapon, cvar_maxmoney, cvar_maxspeed
// Task offsets
enum(+= 100)
{
TASK_WELLCOME = 2000,
TASK_CANBUY
}
#define ID_CANBUY (taskid - TASK_CANBUY)
// id msg
new g_msgTextMsg, g_msgWeapPickup
new g_hamczbots, cvar_botquota, cvar_friendlyfire
// cs offsets
const m_pPlayer = 41
const m_flNextPrimaryAttack = 46
const m_flNextSecondaryAttack = 47
const m_flTimeWeaponIdle = 48
const m_flNextAttack = 83
// cs weapons default value
new const WEAPONSNAME[][] = { "", "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"
}
//############################################# #################
// REGISTER PLUGIN
//############################################# #################
public plugin_natives()
{
new config_dir[64], url_csdm[64], url_zb3[64], url_zbu[64], url_zbs[64], url_hs[64], url_gh[64]
get_configsdir(config_dir, charsmax(config_dir))
format(url_csdm, charsmax(url_csdm), "%s/plugins-csdm.ini", config_dir)
format(url_zb3, charsmax(url_zb3), "%s/plugins-nstzb3.ini", config_dir)
format(url_zbu, charsmax(url_zbu), "%s/plugins-nstzbu.ini", config_dir)
format(url_zbs, charsmax(url_zbs), "%s/plugins-nstzbs.ini", config_dir)
format(url_hs, charsmax(url_hs), "%s/plugins-nsthms.ini", config_dir)
format(url_gh, charsmax(url_gh), "%s/plugins-ghost.ini", config_dir)
// get modruning
if (file_exists(url_csdm))
{
new csdm_single[64]
format(csdm_single, charsmax(csdm_single), "%s/csdm-single.cfg", config_dir)
if (!file_exists(csdm_single)) g_modruning = NST_MOD_CSDM_SINGLE
else g_modruning = NST_MOD_CSDM_TEAM
}
else if (file_exists(url_zb3)) g_modruning = NST_MOD_ZB3
else if (file_exists(url_zbu)) g_modruning = NST_MOD_ZBU
else if (file_exists(url_zbs)) g_modruning = NST_MOD_ZBS
else if (file_exists(url_hs)) g_modruning = NST_MOD_HMS
else if (file_exists(url_gh)) g_modruning = NST_MOD_GHOST
else g_modruning = NST_MOD_DEFAULT
// reg native
if (g_modruning!=NST_MOD_ZB3 && g_modruning!=NST_MOD_ZBU && g_modruning!=NST_MOD_ZBS)
{
register_native("nst_zb_get_user_sex", "natives_novalue", 1)
register_native("nst_zb_get_user_zombie", "natives_novalue", 1)
register_native("nst_zb_get_user_hero", "natives_novalue", 1)
register_native("nst_zb_get_user_supplybox", "natives_novalue", 1)
register_native("nst_zb_remove_user_supplybox ", "natives_novalue", 1)
register_native("nst_zb_remove_weapons_newrou nd", "natives_novalue", 1)
register_native("nst_zb_get_weapons_ammo", "natives_novalue", 1)
register_native("nst_zb_get_user_level", "natives_novalue", 1)
register_native("nst_zb_get_user_damage_attac k", "natives_novalue", 1)
register_native("nst_zb_set_user_damage_attac k", "natives_novalue", 1)
register_native("nst_zb_get_take_damage", "natives_novalue", 1)
register_native("nst_zb_get_damage_nade", "natives_novalue", 1)
CreateMultiForward("nst_zb_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
}
if (g_modruning!=NST_MOD_HMS)
{
register_native("nst_scn_get_damage_nade", "natives_novalue", 1)
register_native("nst_scn_get_human_takedmg", "natives_novalue", 1)
register_native("nst_scn_get_bot_health", "natives_novalue", 1)
register_native("nst_scn_is_bot", "natives_novalue", 1)
register_native("nst_scn_is_boss", "natives_novalue", 1)
register_native("nst_scn_human_kill_bot", "natives_novalue", 1)
register_native("nst_scn_get_weapons_ammo", "natives_novalue", 1)
}
// reg native
register_native("nst_get_mod_runing", "natives_get_mod_runing", 1)
register_native("nst_get_weapon_type", "natives_get_weapon_type", 1)
register_native("nst_get_user_buyzone", "natives_get_user_buyzone", 1)
register_native("nst_bot_use_weapons", "natives_bot_use_weapons", 1)
register_native("nst_weapons_stay", "natives_weapons_stay", 1)
register_native("nst_color_saytext", "natives_color_saytext", 1)
register_native("nst_set_user_money", "natives_set_user_money", 1)
register_native("nst_is_user_admin", "natives_is_user_admin", 1)
register_native("nst_wpn_free", "natives_wpn_free", 1)
register_native("nst_wpn_get_sound_attack", "natives_get_sound_attack", 1)
register_native("nst_wpn_show_weaponpickup", "natives_show_weaponpickup", 1)
register_native("nst_wpn_take_damage", "natives_take_damage", 1)
register_native("nst_wpn_get_canbuy_team_mod" , "natives_get_canbuy_team_mod", 1)
register_native("nst_wpn_get_freezetime", "natives_get_freezetime", 1)
register_native("nst_wpn_get_mod_has_supplybo x", "natives_get_mod_has_supplybox", 1)
register_native("nst_wpn_mywpn", "natives_mywpn", 1)
register_native("nst_wpn_set_cweapon_maxspeed ", "natives_set_cweapon_maxspeed", 1)
register_native("nst_wpn_set_fullammo", "natives_set_fullammo", 1)
register_native("nst_wpn_get_user_sight", "natives_get_user_sight", 1)
register_native("nst_wpn_get_user_fastrun", "natives_get_user_fastrun", 1)
register_native("nst_wpn_get_fastrunanim_weap on", "natives_get_fastrunanim_weapon", 1)
register_native("nst_wpn_get_int", "natives_get_int", 1)
register_native("nst_wpn_get_float", "natives_get_float", 1)
register_native("nst_wpn_give_weapon", "natives_give_weapon", 1)
}
public plugin_precache()
{
mywpn_load_config()
}
public plugin_init()
{
register_plugin(PLUGIN, NST_WPN_VERSION, NST_WPN_AUTHOR)
// Language files
register_dictionary("nst_wpn.txt")
// idmsg
g_msgTextMsg = get_user_msgid("TextMsg")
g_msgWeapPickup = get_user_msgid("WeapPickup")
// register public
register_event("StatusIcon", "event_check_in_buyzone", "be", "2=buyzone")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
register_event("CurWeapon","event_CurWeapon", "be","1=1")
register_logevent("logevent_round_start",2, "1=Round_Start")
register_logevent("logevent_round_end", 2, "1=Round_End")
RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
register_forward(FM_SetModel, "fw_SetModel")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_message(g_msgWeapPickup, "message_WeapPickup")
register_message(g_msgTextMsg, "message_TextMsg")
register_message(get_user_msgid("Money"), "message_Money")
// HAM Forwards
for(new i=1; i<=CSW_P90; i++)
{
if (strlen(WEAPONSNAME[i]))
{
RegisterHam(Ham_Weapon_PrimaryAttack, WEAPONSNAME[i], "fw_Weapon_PrimaryAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, WEAPONSNAME[i], "fw_Weapon_PrimaryAttack_Post", 1)
RegisterHam(Ham_Weapon_WeaponIdle, WEAPONSNAME[i], "fw_Weapon_WeaponIdle")
RegisterHam(Ham_Weapon_Reload, WEAPONSNAME[i], "fw_Weapon_Reload")
RegisterHam(Ham_Weapon_Reload, WEAPONSNAME[i], "fw_Weapon_Reload_Post", 1)
}
}
// Command
register_clcmd("shield", "block_clcmd")
register_clcmd("nst_wpn", "cmd_menu_main")
register_clcmd("+fastrun", "cmd_fastrun")
register_clcmd("-fastrun", "cmd_fastrun_end")
register_clcmd("nst_wpn_rebuy", "cmd_wpn_rebuy")
// Cvar
cvar_weapons_stay = register_cvar("nst_weapons_stay","5")
cvar_bot_use_weapons = register_cvar("nst_bot_use_weapons","5")
cvar_buyzone = register_cvar("nst_set_buyzone","0")
cvar_free = register_cvar("nst_wpn_free","0")
cvar_sound_attack = register_cvar("nst_wpn_sound","1")
cvar_remove_shield = register_cvar("nst_wpn_remove_shield", "1")
cvar_timebuy = register_cvar("nst_wpn_buy_time", "30")
cvar_fastrun_speed = register_cvar("nst_wpn_fastrun_speed", "1.2")
cvar_sight_recoil = register_cvar("nst_wpn_sight_recoil", "0.6")
cvar_sight_speed_player = register_cvar("nst_wpn_sight_speed_player", "0.5")
cvar_sight_speed_weapon = register_cvar("nst_wpn_sight_speed_weapon", "1.0")
cvar_maxmoney = register_cvar("nst_maxmoney", "16000")
cvar_maxspeed = register_cvar("nst_wpn_maxspeed","300")
cvar_botquota = get_cvar_pointer("bot_quota")
cvar_friendlyfire = get_cvar_pointer("mp_friendlyfire")
// other
//register_clcmd("ww", "ww")
}
public plugin_cfg()
{
// Get configs dir
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
// Execute config file (nst.cfg)
server_cmd("exec %s/%s", cfgdir, "nst.cfg")
// Cache CVARs after configs are loaded / call roundstart manually
set_task(0.5, "event_round_start")
set_task(0.5, "logevent_round_start")
}
public ww(id)
{
client_print(id, print_chat, "[%i]", nst_scn_get_weapons_ammo(get_user_weapon(id)) )
/*
new str[32]
new num = nst_wpn_get_data(id, get_pcvar_num(cvar_sight_recoil))
num_to_str(num, str, 31)
client_print(id, print_chat, "[%s][%i]", str, num)*/
}
//############################################# #################
// MAIN PUBLIC
//############################################# #################
public client_putinserver(id)
{
g_command[id] = 1
if (is_user_bot(id) && !g_hamczbots && cvar_botquota)
{
set_task(0.1, "register_ham_czbots", id)
}
}
public fw_ClientDisconnect(id)
{
g_command[id] = 0
}
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_TakeDamage, id, "fw_TakeDamage")
RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
RegisterHamFromEntity(Ham_Spawn, id, "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_round_start()
{
g_freezetime = 1
for (new i = 1; i < 33; i++)
{
if (auto_buy[i] == 1) client_cmd(i, "nst_wpn_1_rebuy;nst_wpn_2_rebuy;nst_wpn_3_re buy;nst_wpn_4_rebuy")
}
// wellcome
remove_task(TASK_WELLCOME)
set_task(5.0, "task_wellcome", TASK_WELLCOME)
}
public logevent_round_start()
{
g_freezetime = 0
}
public logevent_round_end()
{
}
public task_wellcome()
{
new message[64]
format(message, charsmax(message), "^x04[NST Wpn]^x01 %L", LANG_PLAYER, "NOTICE_HELP_BUY")
color_saytext(0, message)
}
public cmd_wpn_rebuy(id)
{
client_cmd(id, "nst_rebuy_wpn1;nst_rebuy_wpn2;nst_rebuy_wpn3 ;nst_rebuy_wpn4")
}
public cmd_fastrun(id)
{
if (g_fastrun[id] || !g_idle[id] || !natives_get_int(id, NST_WPN_DATA_FASTRUN)) return PLUGIN_HANDLED
g_fastrun[id] = 1
nst_wpn_send_weapon_anim(id, nst_wpn_get_fastrunanim_weapon(id, NST_ANI_FASTRUN_BEGIN))
set_weapons_timeidle(id, 1.0)
return PLUGIN_HANDLED
}
public cmd_fastrun_end(id)
{
if (g_fastrun[id])
{
g_fastrun[id] = 0
if (!g_idle[id] || !natives_get_int(id, NST_WPN_DATA_FASTRUN)) return PLUGIN_HANDLED
nst_wpn_send_weapon_anim(id, nst_wpn_get_fastrunanim_weapon(id, NST_ANI_FASTRUN_END))
set_weapons_timeidle(id, 1.0)
}
return PLUGIN_HANDLED
}
public block_clcmd(id)
{
if (get_pcvar_num(cvar_remove_shield)) return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public message_TextMsg()
{
static textmsg[22]
get_msg_arg_string(2, textmsg, charsmax(textmsg))
// Game restarting, reset scores and call round end to balance the teams
if (equal(textmsg, "#Game_will_restart_in"))
{
logevent_round_end()
}
return PLUGIN_CONTINUE;
}
public message_Money(msg_id, msg_dest, msg_entity)
{
new money, maxmoney
money = get_msg_arg_int(1)
maxmoney = get_pcvar_num(cvar_maxmoney)
if (money>maxmoney)
{
fm_cs_set_user_money(msg_entity, maxmoney)
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public message_WeapPickup(msg_id, msg_dest, msg_entity)
{
if (g_weappickup[msg_entity])
{
g_weappickup[msg_entity] = 0
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public event_check_in_buyzone(id)
{
g_inbuyzone[id] = read_data(1)
//client_print(id, print_chat, "[%i]", g_inbuyzone[id])
}
public fw_Weapon_PrimaryAttack(ent)
{
new id = pev(ent,pev_owner)
g_idle[id] = 0.0
// set punchangle of player
pev(id, pev_punchangle, cl_pushangle[id])
}
public fw_Weapon_PrimaryAttack_Post(ent)
{
new id = pev(ent,pev_owner)
// set speed of weapon
new Float:speed = natives_get_float(id, NST_WPN_DATA_SPEED)
if (TEST_WPN) speed = get_pcvar_float(cvar_free)
if (natives_get_user_sight(id)) speed *= get_pcvar_float(cvar_sight_speed_weapon)
new Float:delay = get_pdata_float(ent, m_flNextPrimaryAttack, 4)*speed
if (delay>0.0) set_pdata_float(ent, m_flNextPrimaryAttack, delay, 4)
// set recoil of weapon
new Float:recoil = natives_get_float(id, NST_WPN_DATA_RECOIL)
if (recoil>0.0)
{
// recoil when sight
if (natives_get_user_sight(id)) recoil *= get_pcvar_float(cvar_sight_recoil)
new Float:push[3]
pev(id, pev_punchangle, push)
xs_vec_sub(push, cl_pushangle[id], push)
xs_vec_mul_scalar(push, recoil, push)
xs_vec_add(push, cl_pushangle[id], push)
set_pev(id, pev_punchangle, push)
}
}
public fw_Weapon_WeaponIdle(iEnt)
{
static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
if (!g_idle[id]) g_idle[id] = get_gametime()
}
public fw_Weapon_Reload(ent)
{
new id = pev(ent,pev_owner)
g_idle[id] = 0.0
}
public fw_Weapon_Reload_Post(ent)
{
new id = pev(ent,pev_owner)
// set time reload
new Float:time_reload = natives_get_float(id, NST_WPN_DATA_RELOAD)
if (TEST_WPN) time_reload = get_pcvar_float(cvar_free)
if (time_reload) set_player_nextattack(id, time_reload)
}
public fw_PlayerSpawn_Post(id)
{
// Not alive or didn't join a team yet
if (!is_user_alive(id))
return;
// remove time buy
g_canbuy[id] = 1
if (task_exists(id+TASK_CANBUY)) remove_task(id+TASK_CANBUY)
set_task(get_pcvar_float(cvar_timebuy), "task_remove_canbuy", id+TASK_CANBUY)
// Get configs dir
if (g_command[id])
{
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
server_cmd("exec %s/%s", cfgdir, "nst_cmd.cfg")
g_command[id] = 0
}
// remove value
g_fastrun[id] = 0
}
public task_remove_canbuy(taskid)
{
new id = ID_CANBUY
g_canbuy[id] = 0
}
public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
{
// Non-player damage or self damage
if (victim == attacker || !is_user_connected(attacker) || !is_user_connected(victim))
return HAM_IGNORED;
// New round starting or round ended
if (g_freezetime) return HAM_SUPERCEDE;
new mod_runing = natives_get_mod_runing()
if ((mod_runing == NST_MOD_ZB3 || mod_runing == NST_MOD_ZBU || mod_runing == NST_MOD_ZBS) && !nst_zb_get_take_damage())
return HAM_SUPERCEDE;
// Prevent friendly fire
if (get_user_team(attacker)==get_user_team(victi m) && !get_pcvar_num(cvar_friendlyfire))
return HAM_SUPERCEDE;
// Victim isn't a zombie or not bullet damage, nothing else to do here
if (!(damage_type & DMG_BULLET))
return HAM_IGNORED;
// Get distance between players
static origin1[3], origin2[3]
get_user_origin(victim, origin1)
get_user_origin(attacker, origin2)
// Get victim's velocity
static Float:velocity[3]
pev(victim, pev_velocity, velocity)
xs_vec_mul_scalar(direction, damage, direction)
// Use weapon power on knockback calculation
new knockback = natives_get_int(attacker, NST_WPN_DATA_KNOCKBACK)
if (TEST_WPN) knockback = get_pcvar_num(cvar_free)
if (knockback) xs_vec_mul_scalar(direction, float(knockback), direction)
else return HAM_IGNORED;
// Add up the new vector
xs_vec_add(velocity, direction, direction)
// Set the knockback'd victim's velocity
set_pev(victim, pev_velocity, direction)
//client_print(attacker, print_chat, "[%i]", knockback)
return HAM_IGNORED;
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
// Non-player damage or self damage
if (victim == attacker)
return HAM_IGNORED;
// Fix bug player not connect
if (!pev_valid(victim) || !is_user_connected(attacker))
return HAM_IGNORED;
// Take damage
new Float
damage = natives_get_float(attacker, NST_WPN_DATA_DAMAGE)
if (TEST_WPN) xdamage = get_pcvar_float(cvar_free)
if (xdamage>0.0)
{
damage *= xdamage
SetHamParamFloat(4, damage)
}
return HAM_IGNORED
}
public event_CurWeapon(id)
{
if (!is_user_alive(id)) return;
new wpnid, wpnclip, wpnammo
wpnid = get_user_weapon(id, wpnclip , wpnammo)
// drop shield
if (get_pcvar_num(cvar_remove_shield) && !pev(id, pev_gamestate))
{
if (strlen(WEAPONSNAME[wpnid]))
{
engclient_cmd(id, "drop", WEAPONSNAME[wpnid])
}
}
// update current wpn
if (g_current_wpn[id] != wpnid)
{
g_idle[id] = 0.0
g_current_wpn[id] = wpnid
g_fastrun[id] = 0
// set deploy time
new Float:tdeploy = natives_get_float(id, NST_WPN_DATA_DEPLOY)
if (TEST_WPN) tdeploy = get_pcvar_float(cvar_free)
if (wpnclip && tdeploy) set_player_nextattack(id, tdeploy)
}
}
public fw_TouchWeapon(weapon, id)
{
// Not a player
if (!is_user_connected(id))
return HAM_IGNORED;
// Dont pickup weapons
if (get_pcvar_num(cvar_remove_shield))
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id) || nst_wpn_get_freezetime() || nst_zb_get_user_zombie(id)) return;
new maxspeed = natives_get_int(id, NST_WPN_DATA_GRAVITY)
if (TEST_WPN) maxspeed = get_pcvar_num(cvar_free)
if (!maxspeed) maxspeed = get_weapon_speed(get_user_weapon(id))
new Float:maxspeed_set
maxspeed_set = float(maxspeed)
if (g_fastrun[id])
{
maxspeed_set *= get_pcvar_float(cvar_fastrun_speed)
set_player_nextattack(id, 0.5)
}
else if (natives_get_user_sight(id))
{
maxspeed_set *= get_pcvar_float(cvar_sight_speed_player)
}
maxspeed_set = float(min(floatround(maxspeed_set), get_pcvar_num(cvar_maxspeed)))
set_pev(id, pev_maxspeed, maxspeed_set)
}
public fw_SetModel(entity, const model[])
{
// check mod
new mod_runing = natives_get_mod_runing()
if (mod_runing != NST_MOD_CSDM_SINGLE && mod_runing != NST_MOD_CSDM_TEAM) return FMRES_IGNORED
// check valid ent
if (!is_valid_ent(entity)) return FMRES_IGNORED
// We don't care
if (strlen(model) <
return FMRES_IGNORED
// get ent classname
new ent_classname[32]
pev(entity, pev_classname, ent_classname, charsmax(ent_classname))
// set weapon stay
if (equal(ent_classname, "weaponbox"))
{
set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_weapons_stay))
}
return FMRES_IGNORED
}
// MENU MAIN
public cmd_menu_main(id)
{
if (!is_user_alive(id)) return PLUGIN_HANDLED
new type, type_str[32]
read_argv(1, type_str, charsmax(type_str))
type = str_to_num(type_str)
menu_wpn(id, type)
return PLUGIN_HANDLED
}
menu_wpn(id, type)
{
// member only use main menu wpn
if (g_mywpn_enable && !natives_is_user_admin(id) && type!=NST_MENUWPN_MAIN) return;
new title[64], item_name[32][32], item_cmd[32][32]
if (type==NST_MENUWPN_MAIN) format(title, charsmax(title), "[NST Wpn] %L:", LANG_PLAYER, "MENU_TITLE")
else if (type==NST_MENUWPN_SHOP) format(title, charsmax(title), "[NST Wpn] %L:", LANG_PLAYER, "MENU_TITLE_SHOP")
else if (type==NST_MENUWPN_MYWPN) format(title, charsmax(title), "[NST Wpn] %L:", LANG_PLAYER, "MENU_TITLE_MYWPN_EDIT")
format(item_name[1], 31, "%L", LANG_PLAYER, "MENU_ITEM_RIFLES")
format(item_name[2], 31, "%L", LANG_PLAYER, "MENU_ITEM_PISTOLS")
format(item_name[3], 31, "%L", LANG_PLAYER, "MENU_ITEM_KNIFE")
format(item_name[4], 31, "%L", LANG_PLAYER, "MENU_ITEM_HE")
format(item_name[5], 31, "%L", LANG_PLAYER, "MENU_ITEM_SHOP")
format(item_name[6], 31, "%L", LANG_PLAYER, "MENU_ITEM_MYWPN_EDIT")
format(item_name[7], 31, "%L", LANG_PLAYER, "MENU_ITEM_REBUY")
format(item_name[8], 31, "%L", LANG_PLAYER, "MENU_ITEM_AUTOBUY")
new mHandleID = menu_create(title, "menu_wpn_handler")
// item menu wpn
for (new i=1; i<=4; i++)
{
format(item_cmd[i], 31, "nst_menu_wpn%i %i", i, type)
}
format(item_cmd[5], 31, "nst_wpn %i", NST_MENUWPN_SHOP)
format(item_cmd[6], 31, "nst_wpn %i", NST_MENUWPN_MYWPN)
format(item_cmd[7], 31, "rebuy")
format(item_cmd[8], 31, "auto_rebuy")
// menu main wpn
menu_additem(mHandleID, item_name[1], item_cmd[1], 0)
menu_additem(mHandleID, item_name[2], item_cmd[2], 0)
menu_additem(mHandleID, item_name[3], item_cmd[3], 0)
menu_additem(mHandleID, item_name[4], item_cmd[4], 0)
// item of mywpn
if (g_mywpn_enable)
{
if (type==NST_MENUWPN_MAIN)
{
if (natives_is_user_admin(id))
{
menu_additem(mHandleID, item_name[5], item_cmd[5], 0)
menu_additem(mHandleID, item_name[6], item_cmd[6], 0)
}
menu_additem(mHandleID, item_name[7], item_cmd[7], 0)
menu_additem(mHandleID, item_name[8], item_cmd[8], 0)
}
}
else
{
menu_additem(mHandleID, item_name[7], item_cmd[7], 0)
menu_additem(mHandleID, item_name[8], item_cmd[8], 0)
}
menu_display(id, mHandleID, 0)
}
public menu_wpn_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new cmdbuy[32], name[32], access
menu_item_getinfo(menu, item, access, cmdbuy, 31, name, 31, access)
if (equal(cmdbuy, "rebuy")) client_cmd(id, "nst_wpn_rebuy")
else if (equal(cmdbuy, "auto_rebuy"))
{
auto_buy[id] = 1
new rebuy_cmd[32]
for (new i=1; i<=4; i++)
{
format(rebuy_cmd, charsmax(rebuy_cmd), "nst_rebuy_wpn%i", i)
client_cmd(id, rebuy_cmd)
}
}
else client_cmd(id, cmdbuy)
menu_destroy(menu)
return PLUGIN_HANDLED
}
//############################################# #################
// FUNCTION - STOCK
//############################################# #################
get_weapon_speed(idwpn)
{
new speed
switch (idwpn)
{
case CSW_P228: speed = 250
case CSW_SCOUT: speed = 260
case CSW_HEGRENADE: speed = 250
case CSW_XM1014: speed = 240
case CSW_C4: speed = 250
case CSW_MAC10: speed = 250
case CSW_AUG: speed = 240
case CSW_SMOKEGRENADE: speed = 250
case CSW_ELITE: speed = 250
case CSW_FIVESEVEN: speed = 250
case CSW_UMP45: speed = 250
case CSW_SG550: speed = 210
case CSW_GALIL: speed = 240
case CSW_FAMAS: speed = 240
case CSW_USP: speed = 250
case CSW_GLOCK18: speed = 250
case CSW_AWP: speed = 210
case CSW_MP5NAVY: speed = 250
case CSW_M249: speed = 220
case CSW_M3: speed = 230
case CSW_M4A1: speed = 230
case CSW_TMP: speed = 250
case CSW_G3SG1: speed = 210
case CSW_FLASHBANG: speed = 250
case CSW_DEAGLE: speed = 250
case CSW_SG552: speed = 235
case CSW_AK47: speed = 221
case CSW_KNIFE: speed = 250
case CSW_P90: speed = 245
default: speed = 250
}
return speed;
}
color_saytext(player, const message[], any:...)
{
new text[301]
format(text, 300, "%s", message)
new dest
if (player) dest = MSG_ONE
else dest = MSG_ALL
message_begin(dest, get_user_msgid("SayText"), {0,0,0}, player)
write_byte(1)
write_string(check_text(text))
return message_end()
}
check_text(text1[])
{
new text[301]
format(text, 300, "%s", text1)
replace_all(text, 300, ">x04", "^x04")
replace_all(text, 300, ">x03", "^x03")
replace_all(text, 300, ">x01", "^x01")
return text
}
get_weapon_ent(id, weaponid)
{
static wname[32], weapon_ent
if (weaponid) get_weaponname(weaponid, wname, charsmax(wname))
weapon_ent = fm_find_ent_by_owner(-1, wname, id)
return weapon_ent
}
sendmsg_ItemPickup(id, item[])
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ItemPickup"), _, id)
write_string(item)
message_end()
}
mywpn_load_config()
{
// Build customization file file_url
new file_url[64]
get_configsdir(file_url, charsmax(file_url))
format(file_url, charsmax(file_url), "%s/%s", file_url, NST_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]
// Open customization file for reading
new file = fopen(file_url, "rt")
while (file && !feof(file))
{
// Read one line at a time
fgets(file, linedata, charsmax(linedata))
// Replace newlines with a null character to prevent headaches
replace(linedata, charsmax(linedata), "^n", "")
// Blank line or comment
if (!linedata[0] || linedata[0] == ';')
{
continue;
}
// Get key and value(s)
strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
// Trim spaces
trim(key)
trim(value)
if (equali(key, "ENABLE")) g_mywpn_enable = str_to_num(value)
}
}
stock set_weapons_timeidle(id, Float:timeidle)
{
new entwpn = get_weapon_ent(id, get_user_weapon(id))
if (pev_valid(entwpn)) set_pdata_float(entwpn, m_flTimeWeaponIdle, timeidle+3.0, 4)
}
stock set_player_nextattack(id, Float:nexttime)
{
set_pdata_float(id, m_flNextAttack, nexttime, 4)
}
stock set_player_nexprimaryattack(id, Float:nexttime)
{
new entwpn = get_weapon_ent(id, get_user_weapon(id))
//set_pdata_float(id, m_flNextAttack, nexttime, 4)
set_pdata_float(entwpn, m_flNextPrimaryAttack, nexttime, 4)
set_pdata_float(entwpn, m_flNextSecondaryAttack, nexttime, 4)
}
stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
new strtype[11] = "classname", ent = index;
switch (jghgtype) {
case 1: strtype = "target";
case 2: strtype = "targetname";
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent;
}
stock fm_cs_set_user_money(id, money)
{
cs_set_user_money(id, min(money, get_pcvar_num(cvar_maxmoney)), 1)
}
//############################################# #################
// NATIVES
//############################################# #################
public natives_get_user_buyzone(id)
{
new buyzone = g_inbuyzone[id]
if (get_pcvar_num(cvar_buyzone)) return 1;
new mod_runing = natives_get_mod_runing()
if (mod_runing == NST_MOD_CSDM_SINGLE || mod_runing == NST_MOD_ZB3) buyzone = 1
else if (mod_runing == NST_MOD_ZBS && g_canbuy[id]) buyzone = 1
if (is_user_bot(id)) buyzone = 1
return buyzone
}
public natives_get_mod_runing()
{
return g_modruning
}
public natives_get_weapon_type(weapon_id)
{
new type_wpn
if (weapon_id == CSW_P228 || weapon_id == CSW_ELITE || weapon_id == CSW_FIVESEVEN || weapon_id == CSW_USP || weapon_id == CSW_GLOCK18 || weapon_id == CSW_DEAGLE)
{
type_wpn = NST_WPN_PISTOLS
}
else if (weapon_id == CSW_KNIFE)
{
type_wpn = NST_WPN_KNIFE
}
else if (weapon_id == CSW_HEGRENADE)
{
type_wpn = NST_WPN_HE
}
else if (weapon_id == CSW_FLASHBANG)
{
type_wpn = 41
}
else if (weapon_id == CSW_SMOKEGRENADE)
{
type_wpn = 42
}
else if (weapon_id == CSW_C4)
{
type_wpn = 5
}
else if (weapon_id == CSW_VEST || weapon_id == CSW_VESTHELM)
{
type_wpn = 8
}
else
{
type_wpn = NST_WPN_RIFLES
}
return type_wpn
}
public natives_set_cweapon_maxspeed(id)
{
new Float:maxspeed = float(get_weapon_speed(get_user_weapon(id)))
set_pev(id, pev_maxspeed, maxspeed)
return;
}
public natives_bot_use_weapons()
{
return get_pcvar_num(cvar_bot_use_weapons)
}
public natives_weapons_stay()
{
return get_pcvar_num(cvar_weapons_stay)
}
public natives_novalue(id)
{
return 0
}
public natives_color_saytext(player, const message[], any:...)
{
param_convert(2)
color_saytext(player, message)
}
public natives_wpn_free()
{
return get_pcvar_num(cvar_free)
}
public natives_get_sound_attack()
{
return get_pcvar_num(cvar_sound_attack)
}
public natives_show_weaponpickup(id, const weapon[])
{
param_convert(2)
new hudweapon[32]
format(hudweapon, charsmax(hudweapon), "p_%s", weapon)
g_weappickup[id] = 1
sendmsg_ItemPickup(id, hudweapon)
}
public natives_take_damage(attacker, victim, Float:damage, damage_type)
{
if (!pev_valid(attacker) || !damage) return;
if (pev(victim, pev_health))
{
new mod_runing = natives_get_mod_runing()
if (mod_runing == NST_MOD_ZB3 || mod_runing == NST_MOD_ZBU || mod_runing == NST_MOD_ZBS)
{
if (!nst_zb_get_take_damage()) return;
// x damage for nade type
if (damage_type==NST_WPN_TYPEDAMAGE_NADE) damage += float(nst_zb_get_damage_nade())
// x damage for zombie mod
if (mod_runing==NST_MOD_ZB3 || mod_runing==NST_MOD_ZBS)
{
// x damage
new level_at = nst_zb_get_user_level(attacker)
damage = damage * (float(level_at)*0.1+1.0)
// update damage attack for zb3
if (mod_runing==NST_MOD_ZB3)
{
new dmg_attack_set = nst_zb_get_user_damage_attack(attacker) + min(get_user_health(victim), floatround(damage))
nst_zb_set_user_damage_attack(attacker, dmg_attack_set)
//client_print(attacker, print_chat, "D[%i]", fnFloatToNum(damage))
}
}
}
else if (mod_runing==NST_MOD_HMS)
{
// victim is bot
if (nst_scn_is_bot(victim))
{
// get damage level
damage = float(nst_scn_get_human_takedmg(attacker, damage))
// x damage for nade type
if (damage_type==NST_WPN_TYPEDAMAGE_NADE) damage += float(nst_scn_get_damage_nade())
// update total kills of human
if (0<nst_scn_get_bot_health(victim)<=floatround (damage)) nst_scn_human_kill_bot(attacker, victim)
}
}
// take dmaage
if (damage>0.0) ExecuteHam(Ham_TakeDamage, victim, attacker, attacker, damage, DMG_BULLET)
}
}
public natives_get_canbuy_team_mod()
{
new canbuy
new mod_runing = natives_get_mod_runing()
if (mod_runing==NST_MOD_CSDM_SINGLE || mod_runing==NST_MOD_ZB3 || mod_runing==NST_MOD_ZBS || mod_runing==NST_MOD_HMS) canbuy = 1
return canbuy
}
public natives_get_freezetime()
{
return g_freezetime
}
public natives_get_mod_has_supplybox()
{
new has_box, mod_runing
mod_runing = natives_get_mod_runing()
if (mod_runing==NST_MOD_ZB3 || mod_runing==NST_MOD_ZBU || mod_runing==NST_MOD_ZBS) has_box = 1
return has_box
}
public natives_mywpn()
{
return g_mywpn_enable
}
public natives_is_user_admin(id)
{
new isadmin
if (get_user_flags(id) & ADMIN_KICK) isadmin = 1
return isadmin
}
public natives_get_user_fastrun(id)
{
return g_fastrun[id]
}
public natives_set_user_money(id, money)
{
fm_cs_set_user_money(id, money)
}
public natives_set_fullammo(id)
{
nst_wpn_set_fullammo1(id)
nst_wpn_set_fullammo2(id)
}
public natives_give_weapon(id, const weapon[])
{
param_convert(2)
nst_wpn_give_weapon1(id, weapon)
nst_wpn_give_weapon2(id, weapon)
nst_wpn_give_weapon3(id, weapon)
nst_wpn_give_weapon4(id, weapon)
}
public natives_get_fastrunanim_weapon(id, type)
{
new type_wpn, anim
type_wpn = nst_get_weapon_type(get_user_weapon(id))
switch (type_wpn)
{
case NST_WPN_RIFLES: anim = nst_wpn_get_fastrunanim_weapon1(id, type)
case NST_WPN_PISTOLS: anim = nst_wpn_get_fastrunanim_weapon2(id, type)
}
return anim;
}
public natives_get_user_sight(id)
{
new type_wpn, result
type_wpn = nst_get_weapon_type(get_user_weapon(id))
switch (type_wpn)
{
case NST_WPN_RIFLES: result = nst_wpn_get_user_sight1(id)
case NST_WPN_PISTOLS: result = nst_wpn_get_user_sight2(id)
}
return result;
}
public natives_get_int(id, data)
{
new type_wpn, result
type_wpn = natives_get_weapon_type(get_user_weapon(id))
switch (type_wpn)
{
case NST_WPN_RIFLES: result = nst_wpn_get_int1(id, data)
case NST_WPN_PISTOLS: result = nst_wpn_get_int2(id, data)
case NST_WPN_KNIFE: result = nst_wpn_get_int3(id, data)
case NST_WPN_HE: result = nst_wpn_get_int4(id, data)
}
return result;
}
public Float:natives_get_float(id, data)
{
new type_wpn, Float:result
type_wpn = natives_get_weapon_type(get_user_weapon(id))
switch (type_wpn)
{
case NST_WPN_RIFLES: result = nst_wpn_get_float1(id, data)
case NST_WPN_PISTOLS: result = nst_wpn_get_float2(id, data)
case NST_WPN_KNIFE: result = nst_wpn_get_float3(id, data)
case NST_WPN_HE: result = nst_wpn_get_float4(id, data)
}
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 }
*/