Помогите внедрить код Damage в VIP Environment 2.1.1
И ещё бы прикрутить к этому плагину золотое оружие ак и эмку.Думал взять код с vip_custom ,но там не знаю как сделать.
Помогите пожалуйста.
// Bullet Damage
public Event_Damage(iVictim)
{
if((read_data(4) || read_data(5) || read_data(6)))
{
static damage; damage = read_data(2)
if( recieved && IsPlayer(iVictim) && UserConnected(iVictim))
{
if(g_bAccess[iVictim])
{
set_hudmessage(255, 0, 0, 0.45, 0.50, 0, 6.0, 3.0, _, _, 3)
show_hudmessage(iVictim, "%d", damage)
}
}
new id = get_user_attacker(iVictim)
if( IsPlayer(id) && UserConnected(id))
{
new iPos = ++g_iPlayerPos[id]
if( iPos == sizeof(g_flCoords))
{
iPos = g_iPlayerPos[id] = 0
}
new iCol = ++g_iPlayerCol[id]
if( iCol == sizeof(g_iColors))
{
iCol = g_iPlayerCol[id] = 0
}
if(g_bAccess[id])
{
switch(damager)
{ case 1:{
set_hudmessage(dmgcolors[0], dmgcolors[1], dmgcolors[2], 0.51, 0.51, 0, 6.0, 3.0, _, _, 3)
}
case 2:{
set_hudmessage(dmgcolors[0], dmgcolors[1], dmgcolors[2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
}
case 3:{
set_hudmessage(g_iColors[iCol][0], g_iColors[iCol][1], g_iColors[iCol][2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
}
}
show_hudmessage(id, "%d", damage)
}
}
}
}
public Event_Damage(iVictim)
{
if((read_data(4) || read_data(5) || read_data(6)))
{
static damage; damage = read_data(2)
if( recieved && IsPlayer(iVictim) && UserConnected(iVictim))
{
if(g_bAccess[iVictim])
{
set_hudmessage(255, 0, 0, 0.45, 0.50, 0, 6.0, 3.0, _, _, 3)
show_hudmessage(iVictim, "%d", damage)
}
}
new id = get_user_attacker(iVictim)
if( IsPlayer(id) && UserConnected(id))
{
new iPos = ++g_iPlayerPos[id]
if( iPos == sizeof(g_flCoords))
{
iPos = g_iPlayerPos[id] = 0
}
new iCol = ++g_iPlayerCol[id]
if( iCol == sizeof(g_iColors))
{
iCol = g_iPlayerCol[id] = 0
}
if(g_bAccess[id])
{
switch(damager)
{ case 1:{
set_hudmessage(dmgcolors[0], dmgcolors[1], dmgcolors[2], 0.51, 0.51, 0, 6.0, 3.0, _, _, 3)
}
case 2:{
set_hudmessage(dmgcolors[0], dmgcolors[1], dmgcolors[2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
}
case 3:{
set_hudmessage(g_iColors[iCol][0], g_iColors[iCol][1], g_iColors[iCol][2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
}
}
show_hudmessage(id, "%d", damage)
}
}
}
}
// Copyright © 2016 Vaqtincha
/*******************************************************
*
* Credits:
* - wopox1337 - for: pieces of advice and testing
* - a2 - for: testing
* - Safety1st - for: Code "Menu Obeying BuyZone sample" & "Drop Pistol Without Shield"
* - Exolent[jNr] for: Tutorial "Dynamic Items in Menu and Plugin API"
* - ConnorMcLeod - for: Method checking buytime
* - xPaw - for: Code ScoreBoard "VIP" string
* - КАПИТАН - for: testing
*
********************************************************/
//■■■■■■■■■■■■■■■■■■■■■■■ CONFIG START ■■■■■■■■■■■■■■■■■■■■■■■//
new const MAIN_MENU_CMD[] = "mainmenu"
new const WEAPON_MENU_CMD[] = "weaponmenu"
new const BUY_MENU_CMD[] = "buymenu"
new const REBUY_CMD[] = "vrebuy"
#define CS_DEFAULT_BUY_SYSTEM // buying time & buyzone check
// #define DONT_CLOSE_MENU //
#define WEAPON_STRIP // remove all weapons from the slot (or drop)
#define VAULT_EXPIRE_DAYS 1 // save user settings
// #define DEBUG // console info
//■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG END ■■■■■■■■■■■■■■■■■■■■■■■■//
#define VERSION "2.1.1"
new const CONFIG_FILE[] = "vip_environment.ini"
stock const VAULT_FILE[] = "vip_environment_vault"
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <vip_environment>
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
#define SetUserSurvived(%1) (g_bNotKilled |= (1<<(%1 & 31)))
#define ClearUserSurvived(%1) (g_bNotKilled &= ~(1<<(%1 & 31)))
#define IsUserSurvived(%1) (g_bNotKilled & (1<<(%1 & 31)))
const CONFIG_PATH_LEN = 128
const MAX_WEAPON_NAME_LEN = 20
const MAX_COMMAND_LEN = 16
const MAX_MENU_TEXT_LEN = 64
const REFILL_CLIP = 1<<0
const GIVE_AMMO = 1<<1
const DEFAULT_PISTOL = 0
const NO_MENU = -1
const TASKID_MENUCLOSE = 12138
const Menu_Buy = 4
const Menu_BuyItem = 10
// scoreattrib:
const SCOREATTRIB_VIP = 1<<2
const ScoreAttrib_PlayerID = 1
const ScoreAttrib_Flags = 2
enum _:MENU_TYPES
{
MENU_NULL,
MENU_OFF,
MENU_MAIN,
MENU_WEAPON
}
new const MENU_TEXT[MENU_TYPES][] = {
"",
"\rDONT SHOW",
"\wMAIN MENU",
"\wWEAPON MENU"
}
enum _:WEAPON_DATA
{
szWeaponName[MAX_WEAPON_NAME_LEN],// weapon/item name
szMenuName[MAX_MENU_TEXT_LEN], // menu item name
iWeaponID, // weapon id
iAmount, // bpammo/amount
iCounter, // counter
iItemTeam // team
}
enum _:BUYMENU_DATA
{
szItemName[MAX_MENU_TEXT_LEN],
szItemCmd[MAX_COMMAND_LEN],
iItemCost,
iTeam,
iPluginID,
iFuncID
}
enum _:PLAYER_DATA
{
iUsedCounter,
iSpawnCounter,
iLastUsedTime,
iInMenu,
iInBuyMenu,
iPreviousItem,
iPreviousBuy,
iPistolIndex,
iShowMenu,
bool:bCloseMenu
}
new bool:g_bMapHasBombTarget, g_iRoundCounter, g_iMaxPlayers
new g_iMsgIdBlinkAcct, g_iMsgHookScoreAttrib, g_bNotKilled
new mp_buytime, mp_freezetime, Float:g_flEndOfBuyTime, g_szBuyTime[3], bool:g_bBuyTime
// player arrays
new g_ePlayerData[MAX_PLAYERS+1][PLAYER_DATA]
// dynamic arrays
new Array:g_aDataBuyMenuItems, g_iNumBuyMenuItems
new Array:g_aDataSpawnItems, g_iNumSpawnItems
new Array:g_aDataMenuItems, g_iNumMenuItems
new Array:g_aDataPistols, g_iPistolsTotal
// menus
new g_iMainMenuID, g_iMainMenuCB, g_iWeaponMenuID, g_iWeaponMenuCB
// custom forwards
new g_iFwdSpawn, g_iFwdKill, g_iFwdCfgReload, g_iFwdSetModel
// configs
new g_iReloadWeaponFlags, g_iCounterType, g_iMaxUse, g_iResetType, g_iResetTime
new bool:g_bIsAllowedMap, bool:g_bScoreBoardFlag, g_iMenuAuto, g_iMenuCloseTime
new g_iAccessWeaponMenu, g_iAccessBuyMenu, g_iAccessSpawnItems, g_iAccessOther
public plugin_precache()
{
g_aDataSpawnItems = ArrayCreate(WEAPON_DATA)
g_aDataMenuItems = ArrayCreate(WEAPON_DATA)
g_aDataBuyMenuItems = ArrayCreate(BUYMENU_DATA)
g_aDataPistols = ArrayCreate(WEAPON_DATA)
new eBuyData[BUYMENU_DATA]
ArrayPushArray(g_aDataBuyMenuItems, eBuyData) // empty holder so id's start at 1
g_iNumBuyMenuItems++
}
#if defined VAULT_EXPIRE_DAYS
#include <nvault>
const MAX_AUTHID_LEN = 32
new g_iVaultData
new g_szAuthid[MAX_PLAYERS+1][MAX_AUTHID_LEN]
GetNvault()
{
g_iVaultData = nvault_open(VAULT_FILE)
if(g_iVaultData == INVALID_HANDLE)
{
set_fail_state("[V.I.P] ERROR: Opening nVault failed!")
}else{
nvault_prune(g_iVaultData, 0, get_systime() - (86400 * VAULT_EXPIRE_DAYS))
}
}
public client_authorized(id)
{
new iFlags = get_user_flags(id)
if(iFlags & g_iAccessWeaponMenu || iFlags & g_iAccessBuyMenu || iFlags & g_iAccessSpawnItems)
{
new szKey[MAX_AUTHID_LEN+15]
get_user_authid(id, g_szAuthid[id], MAX_AUTHID_LEN -1)
formatex(szKey, charsmax(szKey), "%s_ShowMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
new nShowMenu = nvault_get(g_iVaultData, szKey)
if(nShowMenu)
{
g_ePlayerData[id][iShowMenu] = nShowMenu
}else{
g_ePlayerData[id][iShowMenu] = MENU_MAIN
}
formatex(szKey, charsmax(szKey), "%s_SpawnPistol", g_szAuthid[id][10]) // strip STEAM_0:0:
new nSpawnWeapon = nvault_get(g_iVaultData, szKey)
if(nSpawnWeapon)
{
g_ePlayerData[id][iPistolIndex] = nSpawnWeapon
if(nSpawnWeapon >= g_iPistolsTotal) // fix array error
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
}else{
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
}
formatex(szKey, charsmax(szKey), "%s_CloseMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
g_ePlayerData[id][bCloseMenu] = bool:nvault_get(g_iVaultData, szKey)
}else{
g_szAuthid[id][0] = 0
}
}
#endif
public plugin_end()
{
#if defined VAULT_EXPIRE_DAYS
nvault_close(g_iVaultData)
#endif
ArrayDestroy(g_aDataSpawnItems)
ArrayDestroy(g_aDataMenuItems)
ArrayDestroy(g_aDataBuyMenuItems)
ArrayDestroy(g_aDataPistols)
DestroyForward(g_iFwdSpawn)
DestroyForward(g_iFwdCfgReload)
DestroyForward(g_iFwdSetModel)
DestroyForward(g_iFwdKill)
}
// ================== Custom Natives ==================
public plugin_natives()
{
register_library("vip_environment")
register_native("RegisterCustomItem", "__add_custom_item")
register_native("GetUserAccess", "__get_user_access")
register_native("GetCurrentRound", "__get_round_counter")
register_native("GetUserSpawns", "__get_user_spawns")
register_native("IsAllowedMap", "__check_allowed_map")
register_native("GetCounterType", "__get_counter_type")
}
public __add_custom_item(iPlugin, iParams)
{
new eBuyData[BUYMENU_DATA], szHandler[64]
get_string(1, eBuyData[szItemName], charsmax(eBuyData[szItemName]))
get_string(2, eBuyData[szItemCmd], charsmax(eBuyData[szItemCmd]))
eBuyData[iPluginID] = iPlugin
get_string(3, szHandler, charsmax(szHandler))
if(!szHandler[0])
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Invalid callback specified for allowed!")
return 0
}
eBuyData[iFuncID] = get_func_id(szHandler, iPlugin)
if(eBuyData[iFuncID] < 0)
{
log_error(AMX_ERR_NOTFOUND, "[V.I.P] ERROR: Public function ^"%s^" was not found!", szHandler)
return 0
}
eBuyData[iItemCost] = get_param(4)
if(eBuyData[iItemCost] < FREE_ITEM)
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Wrong item price ^"%d^"", eBuyData[iItemCost])
return 0
}
eBuyData[iTeam] = get_param(5)
if(!(TEAM_TT <= eBuyData[iTeam] <= TEAM_ALL))
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Wrong team option ^"%d^"", eBuyData[iTeam])
return 0
}
ArrayPushArray(g_aDataBuyMenuItems, eBuyData)
g_iNumBuyMenuItems++
return (g_iNumBuyMenuItems - 1)
}
public __get_round_counter()
{
return g_iRoundCounter
}
public __get_counter_type()
{
return g_iCounterType
}
public __get_user_spawns()
{
new id = get_param(1)
if(!IsPlayer(id))
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Invalid index %d", id)
return 0
}
return g_ePlayerData[id][iSpawnCounter]
}
public __check_allowed_map()
{
return bool:g_bIsAllowedMap
}
public __get_user_access()
{
new id = get_param(1)
if(!IsPlayer(id))
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Invalid index %d", id)
return 0
}
if(is_user_connected(id))
{
new iAccess = 0, iFlags = get_user_flags(id)
iFlags & g_iAccessSpawnItems ? (iAccess |= ACCESS_SPAWN_ITEMS) : 0
iFlags & g_iAccessWeaponMenu ? (iAccess |= ACCESS_WEAPON_MENU) : 0
iFlags & g_iAccessBuyMenu ? (iAccess |= ACCESS_BUY_MENU) : 0
iFlags & g_iAccessOther ? (iAccess |= ACCESS_OTHER) : 0
return iAccess
}
return 0
}
public plugin_init()
{
LoadConfig()
#if defined VAULT_EXPIRE_DAYS
GetNvault()
#endif
register_plugin(PLUGIN_NAME, VERSION, "Vaqtincha")
register_cvar("vip_environment_version", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
register_concmd("vip_reloadcfg", "ConCmd_CfgReload", ADMIN_CFG, "< reload config >")
register_clcmd(MAIN_MENU_CMD, "ClCmd_MainMenu")
register_clcmd(WEAPON_MENU_CMD, "ClCmd_WeaponMenu")
register_clcmd(BUY_MENU_CMD, "ClCmd_BuyMenu")
register_clcmd(REBUY_CMD, "ClCmd_Rebuy")
register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
register_event("TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing")
#if defined CS_DEFAULT_BUY_SYSTEM
register_event("StatusIcon", "Event_HideStatusIcon", "b", "1=0", "2=buyzone")
#endif
RegisterHam(Ham_Spawn, "player", "PlayerSpawn_Pre", .Post = false)
RegisterHam(Ham_Spawn, "player", "PlayerSpawn_Post", .Post = true)
RegisterHam(Ham_Killed, "player", "PlayerKilled_Pre", .Post = false)
g_iFwdSpawn = CreateMultiForward("UserPostSpawn", ET_IGNORE, FP_CELL)
g_iFwdKill = CreateMultiForward("UserPreKilled", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL)
g_iFwdCfgReload = CreateMultiForward("ConfigReloaded", ET_IGNORE)
g_iFwdSetModel = CreateMultiForward("SetWeaponWorldModel", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_STRING)
g_bMapHasBombTarget = bool:IsBombDefuseMap()
g_iMaxPlayers = get_maxplayers()
g_iMsgIdBlinkAcct = get_user_msgid("BlinkAcct")
mp_buytime = get_cvar_pointer("mp_buytime")
mp_freezetime = get_cvar_pointer("mp_freezetime")
Event_NewRound()
}
public plugin_cfg()
{
BuildMenu() // build menu
if(g_iNumBuyMenuItems <= 1)
return
register_forward(FM_SetModel, "SetModel_Pre", false)
new eBuyData[BUYMENU_DATA]
for(new i = 1; i < g_iNumBuyMenuItems; i++)
{
ArrayGetArray(g_aDataBuyMenuItems, i, eBuyData)
#if defined DEBUG
server_print("BUY ITEMS (ItemName: ^"%s^" | ItemAlias: ^"%s^" | Cost: ^"%d^" | Team: ^"%d^")", eBuyData[szItemName], eBuyData[szItemCmd], eBuyData[iItemCost], eBuyData[iTeam])
#endif
if(eBuyData[szItemCmd][0] > 0) // skip ""
{
register_clcmd(eBuyData[szItemCmd], "ClCmd_Alias")
}
}
}
LoadConfig(bool:bReloadCfg = false)
{
new szConfigFile[CONFIG_PATH_LEN], szMsg[CONFIG_PATH_LEN+60], szMapName[32]
get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
// add(szConfigFile, charsmax(szConfigFile), CONFIG_FILE)
formatex(szConfigFile, charsmax(szConfigFile), "%s/%s", szConfigFile, CONFIG_FILE)
get_mapname(szMapName, charsmax(szMapName))
if(!file_exists(szConfigFile))
{
formatex(szMsg, charsmax(szMsg), "[V.I.P] ERROR: Config file ^"%s^" not found!", szConfigFile)
set_fail_state(szMsg)
return 0
}
new iFilePointer = fopen(szConfigFile, "rt")
if(!iFilePointer)
{
set_fail_state("[V.I.P] ERROR: Failed reading file!")
return 0
}
if(bReloadCfg) // reset
{
ArrayClear(g_aDataSpawnItems)
ArrayClear(g_aDataMenuItems)
ArrayClear(g_aDataPistols)
g_iNumSpawnItems = 0
g_iNumMenuItems = 0
g_iPistolsTotal = 0
g_iReloadWeaponFlags = 0
menu_destroy(g_iWeaponMenuID)
}
new szDatas[64], szKey[32], szSign[2], szValue[5], eItemData[WEAPON_DATA], iSection, i
new szClassName[MAX_WEAPON_NAME_LEN], szMenuText[MAX_MENU_TEXT_LEN], szAmount[4], szCounter[4]
new Trie:tCheckWeaponName = TrieCreate()
for(i = 1; i< sizeof(g_szWeaponName); i++)
{
TrieSetCell(tCheckWeaponName, g_szWeaponName, i)
}
TrieSetCell(tCheckWeaponName, "item_kevlar", i)
TrieSetCell(tCheckWeaponName, "item_assaultsuit", i)
TrieSetCell(tCheckWeaponName, "item_thighpack", i)
ArrayPushArray(g_aDataMenuItems, eItemData) // empty holder so id's start at 1
g_iNumMenuItems++
ArrayPushArray(g_aDataPistols, eItemData)
g_iPistolsTotal++
while(!feof(iFilePointer))
{
fgets(iFilePointer, szDatas, charsmax(szDatas))
trim(szDatas)
if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#')
continue
if(szDatas[0] == '[')
{
if(equali(szDatas, "[settings]")){
iSection = 1
}else if(equali(szDatas, "[weaponmenu]")){
iSection = 2
}else if(equali(szDatas, "[spawnitems]")){
iSection = 3
}else if(equali(szDatas, "[maps]")){
iSection = 4
}else iSection = 0
continue
}
switch(iSection)
{
case 1:{
parse(szDatas, szKey, charsmax(szKey), szSign, charsmax(szSign), szValue, charsmax(szValue))
if(szSign[0] == '=')
{
if(equali(szKey, "spawn_item_access_flags")){
g_iAccessSpawnItems = read_flags(szValue)
}else if(equali(szKey, "weapon_menu_access_flags")){
g_iAccessWeaponMenu = read_flags(szValue)
}else if(equali(szKey, "buy_menu_access_flags")){
g_iAccessBuyMenu = read_flags(szValue)
}else if(equali(szKey, "other_access_flags")){
g_iAccessOther = read_flags(szValue)
}else if(equali(szKey, "scoreboard_flag")){
g_bScoreBoardFlag = bool:(szValue[0] == '1')
}else if(equali(szKey, "reload_weapon_flags")){
if(containi(szValue, "a") != INVALID_HANDLE)
g_iReloadWeaponFlags |= REFILL_CLIP
if(containi(szValue, "b") != INVALID_HANDLE)
g_iReloadWeaponFlags |= GIVE_AMMO
}else if(equali(szKey, "counter_type")){
g_iCounterType = str_to_num(szValue)
}else if(equali(szKey, "intelligent_menu")){
g_iMenuAuto = str_to_num(szValue)
}else if(equali(szKey, "close_delay")){
g_iMenuCloseTime = str_to_num(szValue)
}else if(equali(szKey, "option_max_use")){
g_iMaxUse = str_to_num(szValue)
}else if(equali(szKey, "reset_type")){
g_iResetType = str_to_num(szValue)
}else if(equali(szKey, "reset_time")){
g_iResetTime = str_to_num(szValue)
}
}
}
case 2:{
parse(szDatas, szClassName, charsmax(szClassName), szMenuText, charsmax(szMenuText), szAmount, charsmax(szAmount), szCounter, charsmax(szCounter))
strtolower(szClassName) // AbC > to > abs
if(!szClassName[0] || !TrieGetCell(tCheckWeaponName, szClassName, i))
{
server_print("[V.I.P] WARNING: Invalid weapon name ^"%s^" will be skipped!", szClassName)
continue
}
copy(eItemData[szWeaponName], charsmax(eItemData[szWeaponName]), szClassName)
eItemData[iWeaponID] = get_weaponid(szClassName)
eItemData[iAmount] = str_to_num(szAmount)
eItemData[iCounter] = str_to_num(szCounter)
copy(eItemData[szMenuName], charsmax(eItemData[szMenuName]), szMenuText) // weapon_
#if defined DEBUG
server_print("MENU ITEMS (WeaponName: ^"%s^" | WeaponID: ^"%d^" | Amount: ^"%d^" | Counter: ^"%d^" | MenuName: ^"%s^")", eItemData[szWeaponName], eItemData[iWeaponID], eItemData[iAmount], eItemData[iCounter], eItemData[szMenuName])
#endif
ArrayPushArray(g_aDataMenuItems, eItemData)
g_iNumMenuItems++
}
case 3:{
parse(szDatas, szClassName, charsmax(szClassName), szValue, charsmax(szValue), szAmount, charsmax(szAmount), szCounter, charsmax(szCounter))
strtolower(szDatas) // AbC > to > abs
if(!szClassName[0] || !TrieGetCell(tCheckWeaponName, szClassName, i))
{
server_print("[V.I.P] WARNING: Invalid weapon/item name ^"%s^" will be skipped!", szClassName)
continue
}
copy(eItemData[szWeaponName], charsmax(eItemData[szWeaponName]), szClassName)
eItemData[iWeaponID] = get_weaponid(szClassName)
eItemData[iAmount] = str_to_num(szAmount)
eItemData[iCounter] = str_to_num(szCounter)
eItemData[iItemTeam] = szValue[0] == 't' ? TEAM_TT : szValue[0] == 'c' ? TEAM_CT : szValue[0] == 'a' ? TEAM_ALL : 0
#if defined DEBUG
server_print("SPAWN ITEMS (WeaponName: ^"%s^" | WeaponID: ^"%d^" | Amount: ^"%d^" | Counter: ^"%d^" | Team: ^"%d^")", eItemData[szWeaponName], eItemData[iWeaponID], eItemData[iAmount], eItemData[iCounter], eItemData[iItemTeam])
#endif
if(1<<eItemData[iWeaponID] & SECONDARY_WEAPONS_BIT_SUM || 1<<eItemData[iWeaponID] & PRIMARY_WEAPONS_BIT_SUM)
{
eItemData[iAmount] = str_to_num(szValue)
eItemData[iCounter] = str_to_num(szAmount)
strtoupper(szClassName)
copy(eItemData[szMenuName], charsmax(eItemData[szMenuName]), szClassName[7])
ArrayPushArray(g_aDataPistols, eItemData)
g_iPistolsTotal++
#if defined DEBUG
server_print("PISTOLS (PistolName ^"%s^" | PistolID ^"%d^" | PistolAmmo ^"%d^" | PistolCounter ^"%d^"", eItemData[szWeaponName], eItemData[iWeaponID], eItemData[iAmount], eItemData[iCounter])
#endif
}else{
ArrayPushArray(g_aDataSpawnItems, eItemData)
g_iNumSpawnItems++
}
}
case 4:{
if(!g_bIsAllowedMap && containi(szMapName, szDatas) != INVALID_HANDLE){
g_bIsAllowedMap = true
}else if(g_bIsAllowedMap && szDatas[0] == '@' && equali(szMapName, szDatas[1])){
g_bIsAllowedMap = false
}
}
}
}
fclose(iFilePointer)
TrieDestroy(tCheckWeaponName)
CheckRegisterMessage()
CheckConfigValues()
ArrayFixErrors()
return 1
}
// error fix "Invalid cellvector handle provided (4:2:2)"
ArrayFixErrors()
{
new id
for(id = 1; id < g_iMaxPlayers; id++)
{
if(g_ePlayerData[id][iPreviousItem] >= g_iNumMenuItems)
g_ePlayerData[id][iPreviousItem] = 0
if(g_ePlayerData[id][iPistolIndex] >= g_iPistolsTotal)
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
}
}
BuildMenu()
{
g_iMainMenuID = menu_create("Main Menu", "MainMenuHandler") // static menu
g_iMainMenuCB = menu_makecallback("MainMenuCallback")
// menu_setprop(g_iMainMenuID, MPROP_NUMBER_COLOR, "\y")
if(g_iNumBuyMenuItems > 1)
{
menu_additem(g_iMainMenuID, "Weapon Menu", "1", g_iAccessWeaponMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Buy Menu^n", "2", g_iAccessBuyMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Previous Item: [NONE]", "3", g_iAccessWeaponMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Previous Buy: [NONE]^n^n", "4", g_iAccessBuyMenu, g_iMainMenuCB)
}else{
menu_additem(g_iMainMenuID, "Weapon Menu^n", "1", g_iAccessWeaponMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Previous Item: [NONE]^n^n", "3", g_iAccessWeaponMenu, g_iMainMenuCB)
}
if(g_iMenuAuto > 0)
menu_additem(g_iMainMenuID, "Show Menu: [DISABLED]", "5", g_iAccessWeaponMenu, g_iMainMenuCB)
if(g_iPistolsTotal > 1)
menu_additem(g_iMainMenuID, "Spawn Weapons: [DISABLED]", "6", g_iAccessSpawnItems, g_iMainMenuCB)
if(g_iMenuCloseTime > 0)
menu_additem(g_iMainMenuID, "Menu AutoClose: [DISABLED]", "7", g_iAccessWeaponMenu, g_iMainMenuCB)
new szMenuText[MAX_MENU_TEXT_LEN]
switch(g_iCounterType)
{
case COUNTER_ROUND: formatex(szMenuText, charsmax(szMenuText), "Weapons Menu\RRound^t")
case COUNTER_SPAWN: formatex(szMenuText, charsmax(szMenuText), "Weapons Menu\RSpawn^t")
case COUNTER_FRAG: formatex(szMenuText, charsmax(szMenuText), "Weapons Menu\RFrag^t")
default: formatex(szMenuText, charsmax(szMenuText), "\yWeapons Menu\RCounter^t")
}
g_iWeaponMenuID = menu_create(szMenuText, "WeaponMenuHandler") // static menu
// menu_setprop(g_iWeaponMenuID, MPROP_NUMBER_COLOR, "\y")
g_iWeaponMenuCB = menu_makecallback("WeaponMenuCallback")
if(g_iNumMenuItems <= 1)
return
new eMenuData[WEAPON_DATA], szNum[3], i
for(i = 1; i < g_iNumMenuItems; i++)
{
ArrayGetArray(g_aDataMenuItems, i, eMenuData)
formatex(szMenuText, charsmax(szMenuText), "%s\R\y%d%s", eMenuData[szMenuName], eMenuData[iCounter], g_iNumMenuItems > 8 ? "^t^t^t^t" : "^t")
num_to_str(i, szNum, charsmax(szNum))
menu_additem(g_iWeaponMenuID, szMenuText, szNum, 0, g_iWeaponMenuCB)
}
}
#if defined VAULT_EXPIRE_DAYS
SaveData(id)
{
if(!g_szAuthid[id][0]) // non vip
return
new szKey[MAX_AUTHID_LEN+15], szValue[3]
formatex(szKey, charsmax(szKey), "%s_ShowMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
num_to_str(g_ePlayerData[id][iShowMenu], szValue, charsmax(szValue))
nvault_set(g_iVaultData, szKey, szValue)
num_to_str(g_ePlayerData[id][iPistolIndex], szValue, charsmax(szValue))
formatex(szKey, charsmax(szKey), "%s_SpawnPistol", g_szAuthid[id][10]) // strip STEAM_0:0:
nvault_set(g_iVaultData, szKey, szValue)
formatex(szKey, charsmax(szKey), "%s_CloseMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
nvault_set(g_iVaultData, szKey, g_ePlayerData[id][bCloseMenu] ? "1" : "0")
}
#endif
public client_putinserver(id)
{
ResetAll(id)
}
public client_disconnect(id)
{
#if defined VAULT_EXPIRE_DAYS
SaveData(id)
#endif
ResetAll(id)
}
// ================== Events & Messages ==================
public Event_HideStatusIcon(id)
{
CloseMenu(id, g_ePlayerData[id][iInBuyMenu])
}
public Event_MenuAutoClose(taskid)
{
new id = taskid - TASKID_MENUCLOSE
if(!g_ePlayerData[id][bCloseMenu])
CloseMenu(id, g_ePlayerData[id][iInMenu])
}
public Event_NewGame()
{
new id
for(id = 1; id < g_iMaxPlayers; id++)
{
g_ePlayerData[id][iUsedCounter] = 0
g_ePlayerData[id][iLastUsedTime] = 0
g_ePlayerData[id][iSpawnCounter] = 0
}
g_iRoundCounter = 0
}
public Event_NewRound()
{
if(g_iResetType == RESET_ROUND)
{
new id
for(id = 1; id < g_iMaxPlayers; id++)
{
g_ePlayerData[id][iUsedCounter] = 0
}
}
g_bBuyTime = true
new Float:flBuyTime = floatmax(get_pcvar_float(mp_buytime), 0.0) * 60
g_flEndOfBuyTime = get_gametime() + flBuyTime + get_pcvar_float(mp_freezetime)
num_to_str(floatround(flBuyTime), g_szBuyTime, charsmax(g_szBuyTime))
g_iRoundCounter++
}
public SetModel_Pre(iEnt, const szModel[])
{
if(/* pev_valid(iEnt) || */ (strlen(szModel) > MAX_WEAPON_NAME_LEN && (szModel[17] == 'x')))
return FMRES_IGNORED
new szClassName[MAX_WEAPON_NAME_LEN]
pev(iEnt, pev_classname, szClassName, charsmax(szClassName))
if(szClassName[8] != 'x') // checks for weaponbox
return FMRES_IGNORED
new wEnt, iSlot, iRet, iImpulse, iOwner = pev(iEnt, pev_owner)
for(iSlot = 1; iSlot<= 2; iSlot++) // only primary & secondary
{
wEnt = get_pdata_cbase(iEnt, m_rgpPlayerItems_CWeaponBox[iSlot], XO_WEAPON)
if(wEnt > 0 && IsPlayer(iOwner))
{
iImpulse = pev(wEnt, pev_impulse)
#if defined DEBUG
server_print("EntityID: ^"%d^" | WeaponEntityID: ^"%d^" | WeaponImpulse: ^"%d^" | OwnerID: ^"%d^" | Model: ^"%s^"", iEnt, wEnt, iImpulse, iOwner, szModel)
#endif
ExecuteForward(g_iFwdSetModel, iRet, iEnt, wEnt, iImpulse, iOwner, szModel)
return iRet
}
}
return FMRES_IGNORED
}
public Message_ScoreAttrib(MsgId, MsgType, MsgEnt)
{
if(get_msg_arg_int(ScoreAttrib_Flags) || ~get_user_flags(get_msg_arg_int(ScoreAttrib_PlayerID)) & g_iAccessOther)
return
set_msg_arg_int(ScoreAttrib_Flags, ARG_BYTE, SCOREATTRIB_VIP)
}
public PlayerKilled_Pre(id, killer)
{
if(g_iResetType == RESET_DEATH)
g_ePlayerData[id][iUsedCounter] = 0
new iRet
ExecuteForward(g_iFwdKill, iRet, id, IsPlayer(killer) ? killer : 0, get_user_last_hitgroup(id), cs_get_user_team(id) == cs_get_user_team(killer))
}
public PlayerSpawn_Pre(id)
{
if(/* pev_valid(id) == PDATA_SAFE && */ TEAM_TT <= cs_get_user_team(id) <= TEAM_CT)
get_pdata_int(id, m_fHasSurvivedLastRound) ? SetUserSurvived(id) : ClearUserSurvived(id)
}
public PlayerSpawn_Post(id)
{
set_task(0.1, "Spawned", id) // delay
}
public Spawned(id)
{
if(!is_user_alive(id))
return
new iRet
ExecuteForward(g_iFwdSpawn, iRet, id)
g_ePlayerData[id][iSpawnCounter]++
if(g_iResetType == RESET_SPAWN)
g_ePlayerData[id][iUsedCounter] = 0
new iFlags = get_user_flags(id)
if(iFlags & g_iAccessOther && g_iReloadWeaponFlags > 0)
WeaponsReload(id)
if(!g_bIsAllowedMap || !CheckConfigValues())
return
if(iFlags & g_iAccessWeaponMenu)
OpenWeaponMenu(id)
if(~iFlags & g_iAccessSpawnItems)
return
GivePistol(id)
if(!g_iNumSpawnItems)
return
new eItemData[WEAPON_DATA], i, iUserTeam = cs_get_user_team(id)
for(i = 0; i < g_iNumSpawnItems; i++)
{
ArrayGetArray(g_aDataSpawnItems, i, eItemData)
// except item_thighpack (defuser) non target maps
if(!g_bMapHasBombTarget && (eItemData[szWeaponName][0] == 'i' && eItemData[szWeaponName][5] == 't'))
continue
if(!eItemData[iItemTeam] || (iUserTeam != eItemData[iItemTeam] && eItemData[iItemTeam] != TEAM_ALL))
continue
if(GetItemAllowed(id, eItemData[iCounter]))
GiveItem(id, eItemData, .bNotify = false)
}
}
OpenWeaponMenu(id)
{
if(!g_iMenuAuto || g_ePlayerData[id][iShowMenu] == MENU_OFF || (g_iMenuAuto == 1 && IsUserSurvived(id)) || (g_iMenuAuto == 2 && cs_get_user_hasprim(id)))
return
new eItemData[WEAPON_DATA], i
for(i = 1; i < g_iNumMenuItems; i++)
{
ArrayGetArray(g_aDataMenuItems, i, eItemData)
if(GetItemAllowed(id, eItemData[iCounter]))
{
switch(g_ePlayerData[id][iShowMenu]) // always open
{
case MENU_NULL, MENU_OFF: return
case MENU_MAIN: ShowMainMenu(id)
case MENU_WEAPON: ShowWeaponMenu(id, .iPage = 0, .bNotify = false)
// default: return
}
}
break
}
}
// ================== Commands ==================
public ConCmd_CfgReload(id, level)
{
if(~get_user_flags(id) & level)
return PLUGIN_HANDLED
show_menu(0, 0, "^n", 1)
if(LoadConfig(.bReloadCfg = true))
{
BuildMenu() // rebuild menu
if(id)
client_print(id, print_console, "[V.I.P] Configuration reloaded successfully")
else
server_print("[V.I.P] Configuration reloaded successfully")
new iRet
ExecuteForward(g_iFwdCfgReload, iRet)
}
return PLUGIN_HANDLED
}
public ClCmd_Alias(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessBuyMenu)
return PLUGIN_HANDLED
#if defined CS_DEFAULT_BUY_SYSTEM
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "You are outside the buyzone!")
return PLUGIN_HANDLED
}
#endif
new eBuyData[BUYMENU_DATA], szCommand[MAX_COMMAND_LEN]
read_argv(0, szCommand, charsmax(szCommand))
for(new i = 1; i < g_iNumBuyMenuItems; i++)
{
ArrayGetArray(g_aDataBuyMenuItems, i, eBuyData)
if(equali(eBuyData[szItemCmd], szCommand))
{
if(cs_get_user_team(id) != eBuyData[iTeam] && eBuyData[iTeam] != TEAM_ALL)
{
client_print_center(id, "#Alias_Not_Avail", eBuyData[szItemName])
return PLUGIN_HANDLED
}
if(BuyItem(id, eBuyData))
g_ePlayerData[id][iPreviousBuy] = i
break
}
}
return PLUGIN_HANDLED
}
public ClCmd_Rebuy(id)
{
if(!g_bIsAllowedMap || !g_ePlayerData[id][iPreviousBuy] || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessBuyMenu)
return PLUGIN_HANDLED
PreviousBuy(id)
return PLUGIN_HANDLED
}
public ClCmd_MainMenu(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id))
return PLUGIN_HANDLED
new iFlags = get_user_flags(id)
if(iFlags & g_iAccessWeaponMenu || iFlags & g_iAccessBuyMenu || iFlags & g_iAccessSpawnItems)
ShowMainMenu(id)
return PLUGIN_HANDLED
}
public ClCmd_BuyMenu(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessBuyMenu)
return PLUGIN_HANDLED
ShowBuyMenu(id, .iPage = 0)
return PLUGIN_HANDLED
}
public ClCmd_WeaponMenu(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessWeaponMenu)
return PLUGIN_HANDLED
ShowWeaponMenu(id, .iPage = 0)
return PLUGIN_HANDLED
}
// ================== Menus ==================
ShowMainMenu(id)
{
// menu fix
#if AMXX_VERSION_NUM < 183
cs_set_user_menu(id, 0)
#endif
menu_display(id, g_iMainMenuID, 0)
g_ePlayerData[id][iInMenu] = g_iMainMenuID
if(g_iMenuCloseTime > 0)
{
remove_task(TASKID_MENUCLOSE + id)
set_task(float(g_iMenuCloseTime), "Event_MenuAutoClose", TASKID_MENUCLOSE + id)
}
}
ShowBuyMenu(id, iPage)
{
if(g_iNumBuyMenuItems <= 1)
return
#if defined CS_DEFAULT_BUY_SYSTEM
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "You are outside the buyzone!")
return
}
#endif
iPage = clamp(iPage, 0, (g_iNumBuyMenuItems - 1) / 7)
new iBuyMenuID = menu_create("Buy Menu\R$^t^tCost", "BuyMenuHandler") // dynamic menu
// menu_setprop(iBuyMenuID, MPROP_NUMBER_COLOR, "\y")
new eBuyData[BUYMENU_DATA], szItem[MAX_MENU_TEXT_LEN], szNum[3]
new iMoney = cs_get_user_money(id), iUserTeam = cs_get_user_team(id)
for(new i = 1; i < g_iNumBuyMenuItems; i++)
{
ArrayGetArray(g_aDataBuyMenuItems, i, eBuyData)
if(iUserTeam != eBuyData[iTeam] && eBuyData[iTeam] != TEAM_ALL)
continue
if(eBuyData[iItemCost] == FREE_ITEM)
{
formatex(szItem, charsmax(szItem), "%s\R\yFREE%s", eBuyData[szItemName], g_iNumBuyMenuItems > 8 ? "^t^t^t^t" : "")
}else{
if((iMoney - eBuyData[iItemCost]) < 0)
{
formatex(szItem, charsmax(szItem), "\d%s\R\r%d%s", eBuyData[szItemName], eBuyData[iItemCost], g_iNumBuyMenuItems > 8 ? "^t^t^t^t" : "")
}else{
formatex(szItem, charsmax(szItem), "%s\R\y%d%s", eBuyData[szItemName], eBuyData[iItemCost], g_iNumBuyMenuItems > 8 ? "^t^t^t^t" : "")
}
}
num_to_str(i, szNum, charsmax(szNum))
menu_additem(iBuyMenuID, szItem, szNum)
}
// menu fix
#if AMXX_VERSION_NUM < 183
cs_set_user_menu(id, 0)
#endif
menu_display(id, iBuyMenuID, iPage)
g_ePlayerData[id][iInBuyMenu] = iBuyMenuID
}
ShowWeaponMenu(id, iPage, bool:bNotify = true)
{
if(!CheckConfigValues())
return
if(!g_iMaxUse || g_iNumMenuItems <= 1)
{
if(bNotify)
client_print(id, print_center, "Menu disabled!")
return
}
if(g_ePlayerData[id][iUsedCounter] >= g_iMaxUse && !CheckResetType(id, bool:bNotify))
return
iPage = clamp(iPage, 0, (g_iNumMenuItems - 1) / 7)
// menu fix
#if AMXX_VERSION_NUM < 183
cs_set_user_menu(id, 0)
#endif
menu_display(id, g_iWeaponMenuID, iPage)
g_ePlayerData[id][iInMenu] = g_iWeaponMenuID
if(g_iMenuCloseTime > 0)
{
remove_task(TASKID_MENUCLOSE + id)
set_task(float(g_iMenuCloseTime), "Event_MenuAutoClose", TASKID_MENUCLOSE + id)
}
}
public MainMenuHandler(id, iMenu, iItem)
{
g_ePlayerData[id][iInMenu] = NO_MENU
if(g_iMenuCloseTime > 0)
remove_task(TASKID_MENUCLOSE + id)
if(iItem == MENU_EXIT || iItem < 0)
return PLUGIN_HANDLED
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
switch(str_to_num(szNum))
{
case 1: ShowWeaponMenu(id, .iPage = 0)
case 2: ShowBuyMenu(id, .iPage = 0)
case 3: PreviousItem(id)
case 4: PreviousBuy(id)
case 5:{
if(g_ePlayerData[id][iShowMenu]++ == MENU_WEAPON)
g_ePlayerData[id][iShowMenu] = MENU_OFF
menu_display(id, g_iMainMenuID, 0)
}
case 6:{
if(g_ePlayerData[id][iPistolIndex]++ == g_iPistolsTotal-1)
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
menu_display(id, g_iMainMenuID, 0)
}
case 7:{
g_ePlayerData[id][bCloseMenu] = g_ePlayerData[id][bCloseMenu] ? false : true
menu_display(id, g_iMainMenuID, 0)
}
}
return PLUGIN_HANDLED
}
public MainMenuCallback(id, iMenu, iItem)
{
if(iItem < 0)
return PLUGIN_HANDLED
new szNum[3], szMenuText[MAX_MENU_TEXT_LEN], iAccess, hCallback, iFlags = get_user_flags(id)
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), szMenuText, charsmax(szMenuText), hCallback)
new eMenuData[WEAPON_DATA], eBuyData[BUYMENU_DATA], eItemData[WEAPON_DATA]
switch(szNum[0])
{
case '1':{
if(!g_iMaxUse || g_iNumMenuItems <= 1 || ~iFlags & g_iAccessWeaponMenu)
return ITEM_DISABLED
}
case '2':{
if(~iFlags & g_iAccessBuyMenu)
return ITEM_DISABLED
}
case '3':{
if(!g_ePlayerData[id][iPreviousItem] || ~iFlags & g_iAccessWeaponMenu)
{
formatex(szMenuText, charsmax(szMenuText), (g_iNumBuyMenuItems > 1) ? "Previous Item: [NONE]" : "Previous Item: [NONE]^n^n")
menu_item_setname(iMenu, iItem, szMenuText)
return ITEM_DISABLED
}
ArrayGetArray(g_aDataMenuItems, g_ePlayerData[id][iPreviousItem], eMenuData)
formatex(szMenuText, charsmax(szMenuText), (g_iNumBuyMenuItems > 1) ? "Previous Item: \y[\w%s\y]" : "Previous Item: \y[\w%s\y]^n^n", eMenuData[szMenuName])
menu_item_setname(iMenu, iItem, szMenuText)
}
case '4':{
if(!g_ePlayerData[id][iPreviousBuy] || ~iFlags & g_iAccessBuyMenu)
{
formatex(szMenuText, charsmax(szMenuText), "Previous Buy: [NONE]^n^n")
menu_item_setname(iMenu, iItem, szMenuText)
return ITEM_DISABLED
}
ArrayGetArray(g_aDataBuyMenuItems, g_ePlayerData[id][iPreviousBuy], eBuyData)
formatex(szMenuText, charsmax(szMenuText), "Previous Buy: \y[\w%s\y]\R$^t%d^n^n", eBuyData[szItemName], eBuyData[iItemCost])
menu_item_setname(iMenu, iItem, szMenuText)
}
case '5':{
if(~iFlags & g_iAccessWeaponMenu)
return ITEM_DISABLED
formatex(szMenuText, charsmax(szMenuText), "Show Menu: \y[%s\y]", MENU_TEXT[g_ePlayerData[id][iShowMenu]])
menu_item_setname(iMenu, iItem, szMenuText)
}
case '6':{
if(~iFlags & g_iAccessSpawnItems)
return ITEM_DISABLED
if(g_ePlayerData[id][iPistolIndex] == DEFAULT_PISTOL)
{
formatex(szMenuText, charsmax(szMenuText), "Spawn Pistol: \y[\rDEFAULT\y]")
}else{
ArrayGetArray(g_aDataPistols, g_ePlayerData[id][iPistolIndex], eItemData)
formatex(szMenuText, charsmax(szMenuText), "Spawn Pistol: \y[\w%s\y]", eItemData[szMenuName])
}
menu_item_setname(iMenu, iItem, szMenuText)
}
case '7':{
if(~iFlags & g_iAccessWeaponMenu)
return ITEM_DISABLED
formatex(szMenuText, charsmax(szMenuText), "Menu Auto Close: \y[%s\y]", !g_ePlayerData[id][bCloseMenu] ? "\wYES" : "\rNO")
menu_item_setname(iMenu, iItem, szMenuText)
}
}
return ITEM_IGNORE
}
public BuyMenuHandler(id, iMenu, iItem)
{
g_ePlayerData[id][iInBuyMenu] = NO_MENU
if(iItem == MENU_EXIT || iItem < 0)
return menu_destroy(iMenu)
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
new iItemIndex = str_to_num(szNum)
new eBuyData[BUYMENU_DATA]
ArrayGetArray(g_aDataBuyMenuItems, iItemIndex, eBuyData)
if(BuyItem(id, eBuyData))
g_ePlayerData[id][iPreviousBuy] = iItemIndex
#if defined DONT_CLOSE_MENU
ShowBuyMenu(id, .iPage = (iItem / 7))
#endif
return menu_destroy(iMenu)
}
public WeaponMenuHandler(id, iMenu, iItem)
{
g_ePlayerData[id][iInMenu] = NO_MENU
if(g_iMenuCloseTime > 0)
remove_task(TASKID_MENUCLOSE + id)
if(iItem == MENU_EXIT || iItem < 0)
return PLUGIN_HANDLED
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
new iItemIndex = str_to_num(szNum)
new eMenuData[WEAPON_DATA]
ArrayGetArray(g_aDataMenuItems, iItemIndex, eMenuData)
if(GiveItem(id, eMenuData))
{
g_ePlayerData[id][iPreviousItem] = iItemIndex
g_ePlayerData[id][iUsedCounter]++
if(g_iResetType == RESET_TIME && g_iResetTime > 0)
g_ePlayerData[id][iLastUsedTime] = floatround(get_gametime())
}
#if defined DONT_CLOSE_MENU
ShowWeaponMenu(id, .iPage = (iItem / 7), .bNotify = false)
#endif
return PLUGIN_HANDLED
}
public WeaponMenuCallback(id, iMenu, iItem)
{
if(iItem < 0)
return PLUGIN_HANDLED
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
new eMenuData[WEAPON_DATA]
ArrayGetArray(g_aDataMenuItems, str_to_num(szNum), eMenuData)
if(!GetItemAllowed(id, eMenuData[iCounter]))
return ITEM_DISABLED
return ITEM_IGNORE
}
//================= Functions ================
WeaponsReload(id)
{
new iSlot, wEnt, iId
for(iSlot = 1; iSlot<= 2; iSlot++)
{
wEnt = get_pdata_cbase(id, m_rgpPlayerItems_CBasePlayer[iSlot])
while(wEnt > 0)
{
iId = cs_get_weapon_id(wEnt)
if(g_iReloadWeaponFlags & REFILL_CLIP && IsUserSurvived(id))
cs_set_weapon_ammo(wEnt, g_iMaxClip[iId])
if(g_iReloadWeaponFlags & GIVE_AMMO)
ExecuteHamB(Ham_GiveAmmo, id, g_iMaxBPAmmo[iId], g_szAmmoType[iId], g_iMaxBPAmmo[iId])
wEnt = get_pdata_cbase(wEnt, m_pNext, XO_WEAPON)
}
}
}
PreviousBuy(id)
{
#if defined CS_DEFAULT_BUY_SYSTEM
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "You are outside the buyzone!")
return
}
#endif
new eBuyData[BUYMENU_DATA]
ArrayGetArray(g_aDataBuyMenuItems, g_ePlayerData[id][iPreviousBuy], eBuyData)
if(cs_get_user_team(id) != eBuyData[iTeam] && eBuyData[iTeam] != TEAM_ALL)
{
client_print_center(id, "#Alias_Not_Avail", eBuyData[szItemName])
g_ePlayerData[id][iPreviousBuy] = 0
return
}
BuyItem(id, eBuyData)
}
PreviousItem(id)
{
if(g_ePlayerData[id][iUsedCounter] >= g_iMaxUse && !CheckResetType(id, .bNotify = true))
return
new eMenuData[WEAPON_DATA]
ArrayGetArray(g_aDataMenuItems, g_ePlayerData[id][iPreviousItem], eMenuData)
if(GiveItem(id, eMenuData))
{
g_ePlayerData[id][iUsedCounter]++
if(g_iResetType == RESET_TIME && g_iResetTime > 0)
g_ePlayerData[id][iLastUsedTime] = floatround(get_gametime())
}
}
ResetAll(id)
{
g_ePlayerData[id][iUsedCounter] = 0
g_ePlayerData[id][iLastUsedTime] = 0
g_ePlayerData[id][iSpawnCounter] = 0
g_ePlayerData[id][iInMenu] = NO_MENU
g_ePlayerData[id][iInBuyMenu] = NO_MENU
g_ePlayerData[id][iPreviousItem] = 0
g_ePlayerData[id][iPreviousBuy] = 0
if(g_iMenuCloseTime > 0)
remove_task(TASKID_MENUCLOSE + id)
ClearUserSurvived(id)
}
CloseMenu(id, iMenu)
{
if(is_user_connected(id) && !(Menu_Buy <= cs_get_user_menu(id) <= Menu_BuyItem))
{
new iOldMenu, iNewMenu
player_menu_info(id, iOldMenu, iNewMenu)
if(iNewMenu != NO_MENU && iNewMenu == iMenu)
{
menu_cancel(id)
show_menu(id, 0, "^n", 1)
}
}
}
CheckRegisterMessage()
{
static iMsgIdScoreAttrib
if(!iMsgIdScoreAttrib)
iMsgIdScoreAttrib = get_user_msgid("ScoreAttrib")
if(g_bScoreBoardFlag && !g_iMsgHookScoreAttrib)
{
g_iMsgHookScoreAttrib = register_message(iMsgIdScoreAttrib, "Message_ScoreAttrib")
}else{
unregister_message(iMsgIdScoreAttrib, g_iMsgHookScoreAttrib)
g_iMsgHookScoreAttrib = 0
}
}
GivePistol(id)
{
if(g_iPistolsTotal <= 1 || g_ePlayerData[id][iPistolIndex] == DEFAULT_PISTOL)
return
new eItemData[WEAPON_DATA]
ArrayGetArray(g_aDataPistols, g_ePlayerData[id][iPistolIndex], eItemData)
if(GetItemAllowed(id, eItemData[iCounter]))
GiveItem(id, eItemData,.bNotify = false)
}
GiveItem(id, Data[WEAPON_DATA], bool:bNotify = true)
{
new iId = Data[iWeaponID]
if(1<<iId & EXCP_WEAPONS_BIT_SUM || ~pev(id, pev_weapons) & 1<<iId)
{
DoDropWeapon(id, iId)
give_item(id, Data[szWeaponName])
if(Data[iAmount] > 0)
{
if(Data[szWeaponName][0] == 'w') // weapon_
ExecuteHamB(Ham_GiveAmmo, id, Data[iAmount], g_szAmmoType[iId], Data[iAmount])
// set armor value ( item_kevlar, item_assaultsuit )
if(Data[szWeaponName][0] == 'i' && (Data[szWeaponName][5] == 'a' || Data[szWeaponName][5] == 'k'))
set_user_armor(id, Data[iAmount])
}
return 1
}
if(bNotify)
client_print(id, print_center, "#Cstrike_Already_Own_Weapon")
return 0
}
BuyItem(id, eBuyData[BUYMENU_DATA])
{
#if defined CS_DEFAULT_BUY_SYSTEM
if(!CheckBuytime(id))
return 0
#endif
new iMoney = cs_get_user_money(id) - eBuyData[iItemCost]
if(iMoney < 0)
{
client_print(id, print_center, "You need $%d more to buy this item!", (iMoney * -1))
message_begin(MSG_ONE_UNRELIABLE, g_iMsgIdBlinkAcct, .player = id)
write_byte(2/*BlinkAmt*/)
message_end()
return 0
}
callfunc_begin_i(eBuyData[iFuncID], eBuyData[iPluginID])
callfunc_push_int(id)
if(callfunc_end() == BUY_SUCCESS)
{
cs_set_user_money(id, iMoney)
return 1
}
return 0
}
// ==================== Stocks ====================
stock bool:GetItemAllowed(id, iItemCounter)
{
switch(g_iCounterType)
{
case COUNTER_ROUND: return (g_iRoundCounter < iItemCounter) ? false : true
case COUNTER_SPAWN: return (g_ePlayerData[id][iSpawnCounter] < iItemCounter) ? false : true
case COUNTER_FRAG: return (get_user_frags(id) < iItemCounter) ? false : true
default: return false
}
return false
}
stock bool:CheckConfigValues()
{
if(!(COUNTER_ROUND <= g_iCounterType <= COUNTER_FRAG))
{
server_print("[V.I.P] WARNING: Invalid ^"counter_type^" value ^"%d^"", g_iCounterType)
return false
}
if(!(RESET_RESTART <= g_iResetType <= RESET_TIME))
{
server_print("[V.I.P] WARNING: Invalid ^"reset_type^" value ^"%d^"", g_iResetType)
return false
}
return true
}
stock bool:CheckResetType(id, bool:bNotify = false)
{
new bool:bReturn
switch(g_iResetType)
{
case RESET_RESTART:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per game", g_iMaxUse)
bReturn = false
}
case RESET_ROUND:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per round", g_iMaxUse)
bReturn = false
}
case RESET_DEATH:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per life", g_iMaxUse)
bReturn = false
}
case RESET_SPAWN:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per spawn", g_iMaxUse)
bReturn = false
}
case RESET_TIME:{
new iCurTime = floatround(get_gametime())
new iTime = (g_ePlayerData[id][iLastUsedTime] + g_iResetTime)
if(iTime > iCurTime)
{
if(bNotify)
client_print(id, print_center, "Is available after %d second(s)", (iTime - iCurTime))
bReturn = false
}
else if(iTime <= iCurTime)
{
g_ePlayerData[id][iUsedCounter] = 0
bReturn = true
}
}
}
return bReturn
}
stock bool:CheckBuytime(id)
{
if(!g_bBuyTime || !(g_bBuyTime = get_gametime() < g_flEndOfBuyTime))
{
client_print_center(id, "#Cant_buy", g_szBuyTime)
return false
}
return true
}
/*******************************************************
*
* Credits:
* - wopox1337 - for: pieces of advice and testing
* - a2 - for: testing
* - Safety1st - for: Code "Menu Obeying BuyZone sample" & "Drop Pistol Without Shield"
* - Exolent[jNr] for: Tutorial "Dynamic Items in Menu and Plugin API"
* - ConnorMcLeod - for: Method checking buytime
* - xPaw - for: Code ScoreBoard "VIP" string
* - КАПИТАН - for: testing
*
********************************************************/
//■■■■■■■■■■■■■■■■■■■■■■■ CONFIG START ■■■■■■■■■■■■■■■■■■■■■■■//
new const MAIN_MENU_CMD[] = "mainmenu"
new const WEAPON_MENU_CMD[] = "weaponmenu"
new const BUY_MENU_CMD[] = "buymenu"
new const REBUY_CMD[] = "vrebuy"
#define CS_DEFAULT_BUY_SYSTEM // buying time & buyzone check
// #define DONT_CLOSE_MENU //
#define WEAPON_STRIP // remove all weapons from the slot (or drop)
#define VAULT_EXPIRE_DAYS 1 // save user settings
// #define DEBUG // console info
//■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG END ■■■■■■■■■■■■■■■■■■■■■■■■//
#define VERSION "2.1.1"
new const CONFIG_FILE[] = "vip_environment.ini"
stock const VAULT_FILE[] = "vip_environment_vault"
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <vip_environment>
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
#define SetUserSurvived(%1) (g_bNotKilled |= (1<<(%1 & 31)))
#define ClearUserSurvived(%1) (g_bNotKilled &= ~(1<<(%1 & 31)))
#define IsUserSurvived(%1) (g_bNotKilled & (1<<(%1 & 31)))
const CONFIG_PATH_LEN = 128
const MAX_WEAPON_NAME_LEN = 20
const MAX_COMMAND_LEN = 16
const MAX_MENU_TEXT_LEN = 64
const REFILL_CLIP = 1<<0
const GIVE_AMMO = 1<<1
const DEFAULT_PISTOL = 0
const NO_MENU = -1
const TASKID_MENUCLOSE = 12138
const Menu_Buy = 4
const Menu_BuyItem = 10
// scoreattrib:
const SCOREATTRIB_VIP = 1<<2
const ScoreAttrib_PlayerID = 1
const ScoreAttrib_Flags = 2
enum _:MENU_TYPES
{
MENU_NULL,
MENU_OFF,
MENU_MAIN,
MENU_WEAPON
}
new const MENU_TEXT[MENU_TYPES][] = {
"",
"\rDONT SHOW",
"\wMAIN MENU",
"\wWEAPON MENU"
}
enum _:WEAPON_DATA
{
szWeaponName[MAX_WEAPON_NAME_LEN],// weapon/item name
szMenuName[MAX_MENU_TEXT_LEN], // menu item name
iWeaponID, // weapon id
iAmount, // bpammo/amount
iCounter, // counter
iItemTeam // team
}
enum _:BUYMENU_DATA
{
szItemName[MAX_MENU_TEXT_LEN],
szItemCmd[MAX_COMMAND_LEN],
iItemCost,
iTeam,
iPluginID,
iFuncID
}
enum _:PLAYER_DATA
{
iUsedCounter,
iSpawnCounter,
iLastUsedTime,
iInMenu,
iInBuyMenu,
iPreviousItem,
iPreviousBuy,
iPistolIndex,
iShowMenu,
bool:bCloseMenu
}
new bool:g_bMapHasBombTarget, g_iRoundCounter, g_iMaxPlayers
new g_iMsgIdBlinkAcct, g_iMsgHookScoreAttrib, g_bNotKilled
new mp_buytime, mp_freezetime, Float:g_flEndOfBuyTime, g_szBuyTime[3], bool:g_bBuyTime
// player arrays
new g_ePlayerData[MAX_PLAYERS+1][PLAYER_DATA]
// dynamic arrays
new Array:g_aDataBuyMenuItems, g_iNumBuyMenuItems
new Array:g_aDataSpawnItems, g_iNumSpawnItems
new Array:g_aDataMenuItems, g_iNumMenuItems
new Array:g_aDataPistols, g_iPistolsTotal
// menus
new g_iMainMenuID, g_iMainMenuCB, g_iWeaponMenuID, g_iWeaponMenuCB
// custom forwards
new g_iFwdSpawn, g_iFwdKill, g_iFwdCfgReload, g_iFwdSetModel
// configs
new g_iReloadWeaponFlags, g_iCounterType, g_iMaxUse, g_iResetType, g_iResetTime
new bool:g_bIsAllowedMap, bool:g_bScoreBoardFlag, g_iMenuAuto, g_iMenuCloseTime
new g_iAccessWeaponMenu, g_iAccessBuyMenu, g_iAccessSpawnItems, g_iAccessOther
public plugin_precache()
{
g_aDataSpawnItems = ArrayCreate(WEAPON_DATA)
g_aDataMenuItems = ArrayCreate(WEAPON_DATA)
g_aDataBuyMenuItems = ArrayCreate(BUYMENU_DATA)
g_aDataPistols = ArrayCreate(WEAPON_DATA)
new eBuyData[BUYMENU_DATA]
ArrayPushArray(g_aDataBuyMenuItems, eBuyData) // empty holder so id's start at 1
g_iNumBuyMenuItems++
}
#if defined VAULT_EXPIRE_DAYS
#include <nvault>
const MAX_AUTHID_LEN = 32
new g_iVaultData
new g_szAuthid[MAX_PLAYERS+1][MAX_AUTHID_LEN]
GetNvault()
{
g_iVaultData = nvault_open(VAULT_FILE)
if(g_iVaultData == INVALID_HANDLE)
{
set_fail_state("[V.I.P] ERROR: Opening nVault failed!")
}else{
nvault_prune(g_iVaultData, 0, get_systime() - (86400 * VAULT_EXPIRE_DAYS))
}
}
public client_authorized(id)
{
new iFlags = get_user_flags(id)
if(iFlags & g_iAccessWeaponMenu || iFlags & g_iAccessBuyMenu || iFlags & g_iAccessSpawnItems)
{
new szKey[MAX_AUTHID_LEN+15]
get_user_authid(id, g_szAuthid[id], MAX_AUTHID_LEN -1)
formatex(szKey, charsmax(szKey), "%s_ShowMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
new nShowMenu = nvault_get(g_iVaultData, szKey)
if(nShowMenu)
{
g_ePlayerData[id][iShowMenu] = nShowMenu
}else{
g_ePlayerData[id][iShowMenu] = MENU_MAIN
}
formatex(szKey, charsmax(szKey), "%s_SpawnPistol", g_szAuthid[id][10]) // strip STEAM_0:0:
new nSpawnWeapon = nvault_get(g_iVaultData, szKey)
if(nSpawnWeapon)
{
g_ePlayerData[id][iPistolIndex] = nSpawnWeapon
if(nSpawnWeapon >= g_iPistolsTotal) // fix array error
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
}else{
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
}
formatex(szKey, charsmax(szKey), "%s_CloseMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
g_ePlayerData[id][bCloseMenu] = bool:nvault_get(g_iVaultData, szKey)
}else{
g_szAuthid[id][0] = 0
}
}
#endif
public plugin_end()
{
#if defined VAULT_EXPIRE_DAYS
nvault_close(g_iVaultData)
#endif
ArrayDestroy(g_aDataSpawnItems)
ArrayDestroy(g_aDataMenuItems)
ArrayDestroy(g_aDataBuyMenuItems)
ArrayDestroy(g_aDataPistols)
DestroyForward(g_iFwdSpawn)
DestroyForward(g_iFwdCfgReload)
DestroyForward(g_iFwdSetModel)
DestroyForward(g_iFwdKill)
}
// ================== Custom Natives ==================
public plugin_natives()
{
register_library("vip_environment")
register_native("RegisterCustomItem", "__add_custom_item")
register_native("GetUserAccess", "__get_user_access")
register_native("GetCurrentRound", "__get_round_counter")
register_native("GetUserSpawns", "__get_user_spawns")
register_native("IsAllowedMap", "__check_allowed_map")
register_native("GetCounterType", "__get_counter_type")
}
public __add_custom_item(iPlugin, iParams)
{
new eBuyData[BUYMENU_DATA], szHandler[64]
get_string(1, eBuyData[szItemName], charsmax(eBuyData[szItemName]))
get_string(2, eBuyData[szItemCmd], charsmax(eBuyData[szItemCmd]))
eBuyData[iPluginID] = iPlugin
get_string(3, szHandler, charsmax(szHandler))
if(!szHandler[0])
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Invalid callback specified for allowed!")
return 0
}
eBuyData[iFuncID] = get_func_id(szHandler, iPlugin)
if(eBuyData[iFuncID] < 0)
{
log_error(AMX_ERR_NOTFOUND, "[V.I.P] ERROR: Public function ^"%s^" was not found!", szHandler)
return 0
}
eBuyData[iItemCost] = get_param(4)
if(eBuyData[iItemCost] < FREE_ITEM)
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Wrong item price ^"%d^"", eBuyData[iItemCost])
return 0
}
eBuyData[iTeam] = get_param(5)
if(!(TEAM_TT <= eBuyData[iTeam] <= TEAM_ALL))
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Wrong team option ^"%d^"", eBuyData[iTeam])
return 0
}
ArrayPushArray(g_aDataBuyMenuItems, eBuyData)
g_iNumBuyMenuItems++
return (g_iNumBuyMenuItems - 1)
}
public __get_round_counter()
{
return g_iRoundCounter
}
public __get_counter_type()
{
return g_iCounterType
}
public __get_user_spawns()
{
new id = get_param(1)
if(!IsPlayer(id))
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Invalid index %d", id)
return 0
}
return g_ePlayerData[id][iSpawnCounter]
}
public __check_allowed_map()
{
return bool:g_bIsAllowedMap
}
public __get_user_access()
{
new id = get_param(1)
if(!IsPlayer(id))
{
log_error(AMX_ERR_NATIVE, "[V.I.P] ERROR: Invalid index %d", id)
return 0
}
if(is_user_connected(id))
{
new iAccess = 0, iFlags = get_user_flags(id)
iFlags & g_iAccessSpawnItems ? (iAccess |= ACCESS_SPAWN_ITEMS) : 0
iFlags & g_iAccessWeaponMenu ? (iAccess |= ACCESS_WEAPON_MENU) : 0
iFlags & g_iAccessBuyMenu ? (iAccess |= ACCESS_BUY_MENU) : 0
iFlags & g_iAccessOther ? (iAccess |= ACCESS_OTHER) : 0
return iAccess
}
return 0
}
public plugin_init()
{
LoadConfig()
#if defined VAULT_EXPIRE_DAYS
GetNvault()
#endif
register_plugin(PLUGIN_NAME, VERSION, "Vaqtincha")
register_cvar("vip_environment_version", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
register_concmd("vip_reloadcfg", "ConCmd_CfgReload", ADMIN_CFG, "< reload config >")
register_clcmd(MAIN_MENU_CMD, "ClCmd_MainMenu")
register_clcmd(WEAPON_MENU_CMD, "ClCmd_WeaponMenu")
register_clcmd(BUY_MENU_CMD, "ClCmd_BuyMenu")
register_clcmd(REBUY_CMD, "ClCmd_Rebuy")
register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
register_event("TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing")
#if defined CS_DEFAULT_BUY_SYSTEM
register_event("StatusIcon", "Event_HideStatusIcon", "b", "1=0", "2=buyzone")
#endif
RegisterHam(Ham_Spawn, "player", "PlayerSpawn_Pre", .Post = false)
RegisterHam(Ham_Spawn, "player", "PlayerSpawn_Post", .Post = true)
RegisterHam(Ham_Killed, "player", "PlayerKilled_Pre", .Post = false)
g_iFwdSpawn = CreateMultiForward("UserPostSpawn", ET_IGNORE, FP_CELL)
g_iFwdKill = CreateMultiForward("UserPreKilled", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL)
g_iFwdCfgReload = CreateMultiForward("ConfigReloaded", ET_IGNORE)
g_iFwdSetModel = CreateMultiForward("SetWeaponWorldModel", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_STRING)
g_bMapHasBombTarget = bool:IsBombDefuseMap()
g_iMaxPlayers = get_maxplayers()
g_iMsgIdBlinkAcct = get_user_msgid("BlinkAcct")
mp_buytime = get_cvar_pointer("mp_buytime")
mp_freezetime = get_cvar_pointer("mp_freezetime")
Event_NewRound()
}
public plugin_cfg()
{
BuildMenu() // build menu
if(g_iNumBuyMenuItems <= 1)
return
register_forward(FM_SetModel, "SetModel_Pre", false)
new eBuyData[BUYMENU_DATA]
for(new i = 1; i < g_iNumBuyMenuItems; i++)
{
ArrayGetArray(g_aDataBuyMenuItems, i, eBuyData)
#if defined DEBUG
server_print("BUY ITEMS (ItemName: ^"%s^" | ItemAlias: ^"%s^" | Cost: ^"%d^" | Team: ^"%d^")", eBuyData[szItemName], eBuyData[szItemCmd], eBuyData[iItemCost], eBuyData[iTeam])
#endif
if(eBuyData[szItemCmd][0] > 0) // skip ""
{
register_clcmd(eBuyData[szItemCmd], "ClCmd_Alias")
}
}
}
LoadConfig(bool:bReloadCfg = false)
{
new szConfigFile[CONFIG_PATH_LEN], szMsg[CONFIG_PATH_LEN+60], szMapName[32]
get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
// add(szConfigFile, charsmax(szConfigFile), CONFIG_FILE)
formatex(szConfigFile, charsmax(szConfigFile), "%s/%s", szConfigFile, CONFIG_FILE)
get_mapname(szMapName, charsmax(szMapName))
if(!file_exists(szConfigFile))
{
formatex(szMsg, charsmax(szMsg), "[V.I.P] ERROR: Config file ^"%s^" not found!", szConfigFile)
set_fail_state(szMsg)
return 0
}
new iFilePointer = fopen(szConfigFile, "rt")
if(!iFilePointer)
{
set_fail_state("[V.I.P] ERROR: Failed reading file!")
return 0
}
if(bReloadCfg) // reset
{
ArrayClear(g_aDataSpawnItems)
ArrayClear(g_aDataMenuItems)
ArrayClear(g_aDataPistols)
g_iNumSpawnItems = 0
g_iNumMenuItems = 0
g_iPistolsTotal = 0
g_iReloadWeaponFlags = 0
menu_destroy(g_iWeaponMenuID)
}
new szDatas[64], szKey[32], szSign[2], szValue[5], eItemData[WEAPON_DATA], iSection, i
new szClassName[MAX_WEAPON_NAME_LEN], szMenuText[MAX_MENU_TEXT_LEN], szAmount[4], szCounter[4]
new Trie:tCheckWeaponName = TrieCreate()
for(i = 1; i< sizeof(g_szWeaponName); i++)
{
TrieSetCell(tCheckWeaponName, g_szWeaponName, i)
}
TrieSetCell(tCheckWeaponName, "item_kevlar", i)
TrieSetCell(tCheckWeaponName, "item_assaultsuit", i)
TrieSetCell(tCheckWeaponName, "item_thighpack", i)
ArrayPushArray(g_aDataMenuItems, eItemData) // empty holder so id's start at 1
g_iNumMenuItems++
ArrayPushArray(g_aDataPistols, eItemData)
g_iPistolsTotal++
while(!feof(iFilePointer))
{
fgets(iFilePointer, szDatas, charsmax(szDatas))
trim(szDatas)
if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#')
continue
if(szDatas[0] == '[')
{
if(equali(szDatas, "[settings]")){
iSection = 1
}else if(equali(szDatas, "[weaponmenu]")){
iSection = 2
}else if(equali(szDatas, "[spawnitems]")){
iSection = 3
}else if(equali(szDatas, "[maps]")){
iSection = 4
}else iSection = 0
continue
}
switch(iSection)
{
case 1:{
parse(szDatas, szKey, charsmax(szKey), szSign, charsmax(szSign), szValue, charsmax(szValue))
if(szSign[0] == '=')
{
if(equali(szKey, "spawn_item_access_flags")){
g_iAccessSpawnItems = read_flags(szValue)
}else if(equali(szKey, "weapon_menu_access_flags")){
g_iAccessWeaponMenu = read_flags(szValue)
}else if(equali(szKey, "buy_menu_access_flags")){
g_iAccessBuyMenu = read_flags(szValue)
}else if(equali(szKey, "other_access_flags")){
g_iAccessOther = read_flags(szValue)
}else if(equali(szKey, "scoreboard_flag")){
g_bScoreBoardFlag = bool:(szValue[0] == '1')
}else if(equali(szKey, "reload_weapon_flags")){
if(containi(szValue, "a") != INVALID_HANDLE)
g_iReloadWeaponFlags |= REFILL_CLIP
if(containi(szValue, "b") != INVALID_HANDLE)
g_iReloadWeaponFlags |= GIVE_AMMO
}else if(equali(szKey, "counter_type")){
g_iCounterType = str_to_num(szValue)
}else if(equali(szKey, "intelligent_menu")){
g_iMenuAuto = str_to_num(szValue)
}else if(equali(szKey, "close_delay")){
g_iMenuCloseTime = str_to_num(szValue)
}else if(equali(szKey, "option_max_use")){
g_iMaxUse = str_to_num(szValue)
}else if(equali(szKey, "reset_type")){
g_iResetType = str_to_num(szValue)
}else if(equali(szKey, "reset_time")){
g_iResetTime = str_to_num(szValue)
}
}
}
case 2:{
parse(szDatas, szClassName, charsmax(szClassName), szMenuText, charsmax(szMenuText), szAmount, charsmax(szAmount), szCounter, charsmax(szCounter))
strtolower(szClassName) // AbC > to > abs
if(!szClassName[0] || !TrieGetCell(tCheckWeaponName, szClassName, i))
{
server_print("[V.I.P] WARNING: Invalid weapon name ^"%s^" will be skipped!", szClassName)
continue
}
copy(eItemData[szWeaponName], charsmax(eItemData[szWeaponName]), szClassName)
eItemData[iWeaponID] = get_weaponid(szClassName)
eItemData[iAmount] = str_to_num(szAmount)
eItemData[iCounter] = str_to_num(szCounter)
copy(eItemData[szMenuName], charsmax(eItemData[szMenuName]), szMenuText) // weapon_
#if defined DEBUG
server_print("MENU ITEMS (WeaponName: ^"%s^" | WeaponID: ^"%d^" | Amount: ^"%d^" | Counter: ^"%d^" | MenuName: ^"%s^")", eItemData[szWeaponName], eItemData[iWeaponID], eItemData[iAmount], eItemData[iCounter], eItemData[szMenuName])
#endif
ArrayPushArray(g_aDataMenuItems, eItemData)
g_iNumMenuItems++
}
case 3:{
parse(szDatas, szClassName, charsmax(szClassName), szValue, charsmax(szValue), szAmount, charsmax(szAmount), szCounter, charsmax(szCounter))
strtolower(szDatas) // AbC > to > abs
if(!szClassName[0] || !TrieGetCell(tCheckWeaponName, szClassName, i))
{
server_print("[V.I.P] WARNING: Invalid weapon/item name ^"%s^" will be skipped!", szClassName)
continue
}
copy(eItemData[szWeaponName], charsmax(eItemData[szWeaponName]), szClassName)
eItemData[iWeaponID] = get_weaponid(szClassName)
eItemData[iAmount] = str_to_num(szAmount)
eItemData[iCounter] = str_to_num(szCounter)
eItemData[iItemTeam] = szValue[0] == 't' ? TEAM_TT : szValue[0] == 'c' ? TEAM_CT : szValue[0] == 'a' ? TEAM_ALL : 0
#if defined DEBUG
server_print("SPAWN ITEMS (WeaponName: ^"%s^" | WeaponID: ^"%d^" | Amount: ^"%d^" | Counter: ^"%d^" | Team: ^"%d^")", eItemData[szWeaponName], eItemData[iWeaponID], eItemData[iAmount], eItemData[iCounter], eItemData[iItemTeam])
#endif
if(1<<eItemData[iWeaponID] & SECONDARY_WEAPONS_BIT_SUM || 1<<eItemData[iWeaponID] & PRIMARY_WEAPONS_BIT_SUM)
{
eItemData[iAmount] = str_to_num(szValue)
eItemData[iCounter] = str_to_num(szAmount)
strtoupper(szClassName)
copy(eItemData[szMenuName], charsmax(eItemData[szMenuName]), szClassName[7])
ArrayPushArray(g_aDataPistols, eItemData)
g_iPistolsTotal++
#if defined DEBUG
server_print("PISTOLS (PistolName ^"%s^" | PistolID ^"%d^" | PistolAmmo ^"%d^" | PistolCounter ^"%d^"", eItemData[szWeaponName], eItemData[iWeaponID], eItemData[iAmount], eItemData[iCounter])
#endif
}else{
ArrayPushArray(g_aDataSpawnItems, eItemData)
g_iNumSpawnItems++
}
}
case 4:{
if(!g_bIsAllowedMap && containi(szMapName, szDatas) != INVALID_HANDLE){
g_bIsAllowedMap = true
}else if(g_bIsAllowedMap && szDatas[0] == '@' && equali(szMapName, szDatas[1])){
g_bIsAllowedMap = false
}
}
}
}
fclose(iFilePointer)
TrieDestroy(tCheckWeaponName)
CheckRegisterMessage()
CheckConfigValues()
ArrayFixErrors()
return 1
}
// error fix "Invalid cellvector handle provided (4:2:2)"
ArrayFixErrors()
{
new id
for(id = 1; id < g_iMaxPlayers; id++)
{
if(g_ePlayerData[id][iPreviousItem] >= g_iNumMenuItems)
g_ePlayerData[id][iPreviousItem] = 0
if(g_ePlayerData[id][iPistolIndex] >= g_iPistolsTotal)
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
}
}
BuildMenu()
{
g_iMainMenuID = menu_create("Main Menu", "MainMenuHandler") // static menu
g_iMainMenuCB = menu_makecallback("MainMenuCallback")
// menu_setprop(g_iMainMenuID, MPROP_NUMBER_COLOR, "\y")
if(g_iNumBuyMenuItems > 1)
{
menu_additem(g_iMainMenuID, "Weapon Menu", "1", g_iAccessWeaponMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Buy Menu^n", "2", g_iAccessBuyMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Previous Item: [NONE]", "3", g_iAccessWeaponMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Previous Buy: [NONE]^n^n", "4", g_iAccessBuyMenu, g_iMainMenuCB)
}else{
menu_additem(g_iMainMenuID, "Weapon Menu^n", "1", g_iAccessWeaponMenu, g_iMainMenuCB)
menu_additem(g_iMainMenuID, "Previous Item: [NONE]^n^n", "3", g_iAccessWeaponMenu, g_iMainMenuCB)
}
if(g_iMenuAuto > 0)
menu_additem(g_iMainMenuID, "Show Menu: [DISABLED]", "5", g_iAccessWeaponMenu, g_iMainMenuCB)
if(g_iPistolsTotal > 1)
menu_additem(g_iMainMenuID, "Spawn Weapons: [DISABLED]", "6", g_iAccessSpawnItems, g_iMainMenuCB)
if(g_iMenuCloseTime > 0)
menu_additem(g_iMainMenuID, "Menu AutoClose: [DISABLED]", "7", g_iAccessWeaponMenu, g_iMainMenuCB)
new szMenuText[MAX_MENU_TEXT_LEN]
switch(g_iCounterType)
{
case COUNTER_ROUND: formatex(szMenuText, charsmax(szMenuText), "Weapons Menu\RRound^t")
case COUNTER_SPAWN: formatex(szMenuText, charsmax(szMenuText), "Weapons Menu\RSpawn^t")
case COUNTER_FRAG: formatex(szMenuText, charsmax(szMenuText), "Weapons Menu\RFrag^t")
default: formatex(szMenuText, charsmax(szMenuText), "\yWeapons Menu\RCounter^t")
}
g_iWeaponMenuID = menu_create(szMenuText, "WeaponMenuHandler") // static menu
// menu_setprop(g_iWeaponMenuID, MPROP_NUMBER_COLOR, "\y")
g_iWeaponMenuCB = menu_makecallback("WeaponMenuCallback")
if(g_iNumMenuItems <= 1)
return
new eMenuData[WEAPON_DATA], szNum[3], i
for(i = 1; i < g_iNumMenuItems; i++)
{
ArrayGetArray(g_aDataMenuItems, i, eMenuData)
formatex(szMenuText, charsmax(szMenuText), "%s\R\y%d%s", eMenuData[szMenuName], eMenuData[iCounter], g_iNumMenuItems > 8 ? "^t^t^t^t" : "^t")
num_to_str(i, szNum, charsmax(szNum))
menu_additem(g_iWeaponMenuID, szMenuText, szNum, 0, g_iWeaponMenuCB)
}
}
#if defined VAULT_EXPIRE_DAYS
SaveData(id)
{
if(!g_szAuthid[id][0]) // non vip
return
new szKey[MAX_AUTHID_LEN+15], szValue[3]
formatex(szKey, charsmax(szKey), "%s_ShowMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
num_to_str(g_ePlayerData[id][iShowMenu], szValue, charsmax(szValue))
nvault_set(g_iVaultData, szKey, szValue)
num_to_str(g_ePlayerData[id][iPistolIndex], szValue, charsmax(szValue))
formatex(szKey, charsmax(szKey), "%s_SpawnPistol", g_szAuthid[id][10]) // strip STEAM_0:0:
nvault_set(g_iVaultData, szKey, szValue)
formatex(szKey, charsmax(szKey), "%s_CloseMenu", g_szAuthid[id][10]) // strip STEAM_0:0:
nvault_set(g_iVaultData, szKey, g_ePlayerData[id][bCloseMenu] ? "1" : "0")
}
#endif
public client_putinserver(id)
{
ResetAll(id)
}
public client_disconnect(id)
{
#if defined VAULT_EXPIRE_DAYS
SaveData(id)
#endif
ResetAll(id)
}
// ================== Events & Messages ==================
public Event_HideStatusIcon(id)
{
CloseMenu(id, g_ePlayerData[id][iInBuyMenu])
}
public Event_MenuAutoClose(taskid)
{
new id = taskid - TASKID_MENUCLOSE
if(!g_ePlayerData[id][bCloseMenu])
CloseMenu(id, g_ePlayerData[id][iInMenu])
}
public Event_NewGame()
{
new id
for(id = 1; id < g_iMaxPlayers; id++)
{
g_ePlayerData[id][iUsedCounter] = 0
g_ePlayerData[id][iLastUsedTime] = 0
g_ePlayerData[id][iSpawnCounter] = 0
}
g_iRoundCounter = 0
}
public Event_NewRound()
{
if(g_iResetType == RESET_ROUND)
{
new id
for(id = 1; id < g_iMaxPlayers; id++)
{
g_ePlayerData[id][iUsedCounter] = 0
}
}
g_bBuyTime = true
new Float:flBuyTime = floatmax(get_pcvar_float(mp_buytime), 0.0) * 60
g_flEndOfBuyTime = get_gametime() + flBuyTime + get_pcvar_float(mp_freezetime)
num_to_str(floatround(flBuyTime), g_szBuyTime, charsmax(g_szBuyTime))
g_iRoundCounter++
}
public SetModel_Pre(iEnt, const szModel[])
{
if(/* pev_valid(iEnt) || */ (strlen(szModel) > MAX_WEAPON_NAME_LEN && (szModel[17] == 'x')))
return FMRES_IGNORED
new szClassName[MAX_WEAPON_NAME_LEN]
pev(iEnt, pev_classname, szClassName, charsmax(szClassName))
if(szClassName[8] != 'x') // checks for weaponbox
return FMRES_IGNORED
new wEnt, iSlot, iRet, iImpulse, iOwner = pev(iEnt, pev_owner)
for(iSlot = 1; iSlot<= 2; iSlot++) // only primary & secondary
{
wEnt = get_pdata_cbase(iEnt, m_rgpPlayerItems_CWeaponBox[iSlot], XO_WEAPON)
if(wEnt > 0 && IsPlayer(iOwner))
{
iImpulse = pev(wEnt, pev_impulse)
#if defined DEBUG
server_print("EntityID: ^"%d^" | WeaponEntityID: ^"%d^" | WeaponImpulse: ^"%d^" | OwnerID: ^"%d^" | Model: ^"%s^"", iEnt, wEnt, iImpulse, iOwner, szModel)
#endif
ExecuteForward(g_iFwdSetModel, iRet, iEnt, wEnt, iImpulse, iOwner, szModel)
return iRet
}
}
return FMRES_IGNORED
}
public Message_ScoreAttrib(MsgId, MsgType, MsgEnt)
{
if(get_msg_arg_int(ScoreAttrib_Flags) || ~get_user_flags(get_msg_arg_int(ScoreAttrib_PlayerID)) & g_iAccessOther)
return
set_msg_arg_int(ScoreAttrib_Flags, ARG_BYTE, SCOREATTRIB_VIP)
}
public PlayerKilled_Pre(id, killer)
{
if(g_iResetType == RESET_DEATH)
g_ePlayerData[id][iUsedCounter] = 0
new iRet
ExecuteForward(g_iFwdKill, iRet, id, IsPlayer(killer) ? killer : 0, get_user_last_hitgroup(id), cs_get_user_team(id) == cs_get_user_team(killer))
}
public PlayerSpawn_Pre(id)
{
if(/* pev_valid(id) == PDATA_SAFE && */ TEAM_TT <= cs_get_user_team(id) <= TEAM_CT)
get_pdata_int(id, m_fHasSurvivedLastRound) ? SetUserSurvived(id) : ClearUserSurvived(id)
}
public PlayerSpawn_Post(id)
{
set_task(0.1, "Spawned", id) // delay
}
public Spawned(id)
{
if(!is_user_alive(id))
return
new iRet
ExecuteForward(g_iFwdSpawn, iRet, id)
g_ePlayerData[id][iSpawnCounter]++
if(g_iResetType == RESET_SPAWN)
g_ePlayerData[id][iUsedCounter] = 0
new iFlags = get_user_flags(id)
if(iFlags & g_iAccessOther && g_iReloadWeaponFlags > 0)
WeaponsReload(id)
if(!g_bIsAllowedMap || !CheckConfigValues())
return
if(iFlags & g_iAccessWeaponMenu)
OpenWeaponMenu(id)
if(~iFlags & g_iAccessSpawnItems)
return
GivePistol(id)
if(!g_iNumSpawnItems)
return
new eItemData[WEAPON_DATA], i, iUserTeam = cs_get_user_team(id)
for(i = 0; i < g_iNumSpawnItems; i++)
{
ArrayGetArray(g_aDataSpawnItems, i, eItemData)
// except item_thighpack (defuser) non target maps
if(!g_bMapHasBombTarget && (eItemData[szWeaponName][0] == 'i' && eItemData[szWeaponName][5] == 't'))
continue
if(!eItemData[iItemTeam] || (iUserTeam != eItemData[iItemTeam] && eItemData[iItemTeam] != TEAM_ALL))
continue
if(GetItemAllowed(id, eItemData[iCounter]))
GiveItem(id, eItemData, .bNotify = false)
}
}
OpenWeaponMenu(id)
{
if(!g_iMenuAuto || g_ePlayerData[id][iShowMenu] == MENU_OFF || (g_iMenuAuto == 1 && IsUserSurvived(id)) || (g_iMenuAuto == 2 && cs_get_user_hasprim(id)))
return
new eItemData[WEAPON_DATA], i
for(i = 1; i < g_iNumMenuItems; i++)
{
ArrayGetArray(g_aDataMenuItems, i, eItemData)
if(GetItemAllowed(id, eItemData[iCounter]))
{
switch(g_ePlayerData[id][iShowMenu]) // always open
{
case MENU_NULL, MENU_OFF: return
case MENU_MAIN: ShowMainMenu(id)
case MENU_WEAPON: ShowWeaponMenu(id, .iPage = 0, .bNotify = false)
// default: return
}
}
break
}
}
// ================== Commands ==================
public ConCmd_CfgReload(id, level)
{
if(~get_user_flags(id) & level)
return PLUGIN_HANDLED
show_menu(0, 0, "^n", 1)
if(LoadConfig(.bReloadCfg = true))
{
BuildMenu() // rebuild menu
if(id)
client_print(id, print_console, "[V.I.P] Configuration reloaded successfully")
else
server_print("[V.I.P] Configuration reloaded successfully")
new iRet
ExecuteForward(g_iFwdCfgReload, iRet)
}
return PLUGIN_HANDLED
}
public ClCmd_Alias(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessBuyMenu)
return PLUGIN_HANDLED
#if defined CS_DEFAULT_BUY_SYSTEM
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "You are outside the buyzone!")
return PLUGIN_HANDLED
}
#endif
new eBuyData[BUYMENU_DATA], szCommand[MAX_COMMAND_LEN]
read_argv(0, szCommand, charsmax(szCommand))
for(new i = 1; i < g_iNumBuyMenuItems; i++)
{
ArrayGetArray(g_aDataBuyMenuItems, i, eBuyData)
if(equali(eBuyData[szItemCmd], szCommand))
{
if(cs_get_user_team(id) != eBuyData[iTeam] && eBuyData[iTeam] != TEAM_ALL)
{
client_print_center(id, "#Alias_Not_Avail", eBuyData[szItemName])
return PLUGIN_HANDLED
}
if(BuyItem(id, eBuyData))
g_ePlayerData[id][iPreviousBuy] = i
break
}
}
return PLUGIN_HANDLED
}
public ClCmd_Rebuy(id)
{
if(!g_bIsAllowedMap || !g_ePlayerData[id][iPreviousBuy] || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessBuyMenu)
return PLUGIN_HANDLED
PreviousBuy(id)
return PLUGIN_HANDLED
}
public ClCmd_MainMenu(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id))
return PLUGIN_HANDLED
new iFlags = get_user_flags(id)
if(iFlags & g_iAccessWeaponMenu || iFlags & g_iAccessBuyMenu || iFlags & g_iAccessSpawnItems)
ShowMainMenu(id)
return PLUGIN_HANDLED
}
public ClCmd_BuyMenu(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessBuyMenu)
return PLUGIN_HANDLED
ShowBuyMenu(id, .iPage = 0)
return PLUGIN_HANDLED
}
public ClCmd_WeaponMenu(id)
{
if(!g_bIsAllowedMap || !is_user_alive(id) || ~get_user_flags(id) & g_iAccessWeaponMenu)
return PLUGIN_HANDLED
ShowWeaponMenu(id, .iPage = 0)
return PLUGIN_HANDLED
}
// ================== Menus ==================
ShowMainMenu(id)
{
// menu fix
#if AMXX_VERSION_NUM < 183
cs_set_user_menu(id, 0)
#endif
menu_display(id, g_iMainMenuID, 0)
g_ePlayerData[id][iInMenu] = g_iMainMenuID
if(g_iMenuCloseTime > 0)
{
remove_task(TASKID_MENUCLOSE + id)
set_task(float(g_iMenuCloseTime), "Event_MenuAutoClose", TASKID_MENUCLOSE + id)
}
}
ShowBuyMenu(id, iPage)
{
if(g_iNumBuyMenuItems <= 1)
return
#if defined CS_DEFAULT_BUY_SYSTEM
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "You are outside the buyzone!")
return
}
#endif
iPage = clamp(iPage, 0, (g_iNumBuyMenuItems - 1) / 7)
new iBuyMenuID = menu_create("Buy Menu\R$^t^tCost", "BuyMenuHandler") // dynamic menu
// menu_setprop(iBuyMenuID, MPROP_NUMBER_COLOR, "\y")
new eBuyData[BUYMENU_DATA], szItem[MAX_MENU_TEXT_LEN], szNum[3]
new iMoney = cs_get_user_money(id), iUserTeam = cs_get_user_team(id)
for(new i = 1; i < g_iNumBuyMenuItems; i++)
{
ArrayGetArray(g_aDataBuyMenuItems, i, eBuyData)
if(iUserTeam != eBuyData[iTeam] && eBuyData[iTeam] != TEAM_ALL)
continue
if(eBuyData[iItemCost] == FREE_ITEM)
{
formatex(szItem, charsmax(szItem), "%s\R\yFREE%s", eBuyData[szItemName], g_iNumBuyMenuItems > 8 ? "^t^t^t^t" : "")
}else{
if((iMoney - eBuyData[iItemCost]) < 0)
{
formatex(szItem, charsmax(szItem), "\d%s\R\r%d%s", eBuyData[szItemName], eBuyData[iItemCost], g_iNumBuyMenuItems > 8 ? "^t^t^t^t" : "")
}else{
formatex(szItem, charsmax(szItem), "%s\R\y%d%s", eBuyData[szItemName], eBuyData[iItemCost], g_iNumBuyMenuItems > 8 ? "^t^t^t^t" : "")
}
}
num_to_str(i, szNum, charsmax(szNum))
menu_additem(iBuyMenuID, szItem, szNum)
}
// menu fix
#if AMXX_VERSION_NUM < 183
cs_set_user_menu(id, 0)
#endif
menu_display(id, iBuyMenuID, iPage)
g_ePlayerData[id][iInBuyMenu] = iBuyMenuID
}
ShowWeaponMenu(id, iPage, bool:bNotify = true)
{
if(!CheckConfigValues())
return
if(!g_iMaxUse || g_iNumMenuItems <= 1)
{
if(bNotify)
client_print(id, print_center, "Menu disabled!")
return
}
if(g_ePlayerData[id][iUsedCounter] >= g_iMaxUse && !CheckResetType(id, bool:bNotify))
return
iPage = clamp(iPage, 0, (g_iNumMenuItems - 1) / 7)
// menu fix
#if AMXX_VERSION_NUM < 183
cs_set_user_menu(id, 0)
#endif
menu_display(id, g_iWeaponMenuID, iPage)
g_ePlayerData[id][iInMenu] = g_iWeaponMenuID
if(g_iMenuCloseTime > 0)
{
remove_task(TASKID_MENUCLOSE + id)
set_task(float(g_iMenuCloseTime), "Event_MenuAutoClose", TASKID_MENUCLOSE + id)
}
}
public MainMenuHandler(id, iMenu, iItem)
{
g_ePlayerData[id][iInMenu] = NO_MENU
if(g_iMenuCloseTime > 0)
remove_task(TASKID_MENUCLOSE + id)
if(iItem == MENU_EXIT || iItem < 0)
return PLUGIN_HANDLED
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
switch(str_to_num(szNum))
{
case 1: ShowWeaponMenu(id, .iPage = 0)
case 2: ShowBuyMenu(id, .iPage = 0)
case 3: PreviousItem(id)
case 4: PreviousBuy(id)
case 5:{
if(g_ePlayerData[id][iShowMenu]++ == MENU_WEAPON)
g_ePlayerData[id][iShowMenu] = MENU_OFF
menu_display(id, g_iMainMenuID, 0)
}
case 6:{
if(g_ePlayerData[id][iPistolIndex]++ == g_iPistolsTotal-1)
g_ePlayerData[id][iPistolIndex] = DEFAULT_PISTOL
menu_display(id, g_iMainMenuID, 0)
}
case 7:{
g_ePlayerData[id][bCloseMenu] = g_ePlayerData[id][bCloseMenu] ? false : true
menu_display(id, g_iMainMenuID, 0)
}
}
return PLUGIN_HANDLED
}
public MainMenuCallback(id, iMenu, iItem)
{
if(iItem < 0)
return PLUGIN_HANDLED
new szNum[3], szMenuText[MAX_MENU_TEXT_LEN], iAccess, hCallback, iFlags = get_user_flags(id)
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), szMenuText, charsmax(szMenuText), hCallback)
new eMenuData[WEAPON_DATA], eBuyData[BUYMENU_DATA], eItemData[WEAPON_DATA]
switch(szNum[0])
{
case '1':{
if(!g_iMaxUse || g_iNumMenuItems <= 1 || ~iFlags & g_iAccessWeaponMenu)
return ITEM_DISABLED
}
case '2':{
if(~iFlags & g_iAccessBuyMenu)
return ITEM_DISABLED
}
case '3':{
if(!g_ePlayerData[id][iPreviousItem] || ~iFlags & g_iAccessWeaponMenu)
{
formatex(szMenuText, charsmax(szMenuText), (g_iNumBuyMenuItems > 1) ? "Previous Item: [NONE]" : "Previous Item: [NONE]^n^n")
menu_item_setname(iMenu, iItem, szMenuText)
return ITEM_DISABLED
}
ArrayGetArray(g_aDataMenuItems, g_ePlayerData[id][iPreviousItem], eMenuData)
formatex(szMenuText, charsmax(szMenuText), (g_iNumBuyMenuItems > 1) ? "Previous Item: \y[\w%s\y]" : "Previous Item: \y[\w%s\y]^n^n", eMenuData[szMenuName])
menu_item_setname(iMenu, iItem, szMenuText)
}
case '4':{
if(!g_ePlayerData[id][iPreviousBuy] || ~iFlags & g_iAccessBuyMenu)
{
formatex(szMenuText, charsmax(szMenuText), "Previous Buy: [NONE]^n^n")
menu_item_setname(iMenu, iItem, szMenuText)
return ITEM_DISABLED
}
ArrayGetArray(g_aDataBuyMenuItems, g_ePlayerData[id][iPreviousBuy], eBuyData)
formatex(szMenuText, charsmax(szMenuText), "Previous Buy: \y[\w%s\y]\R$^t%d^n^n", eBuyData[szItemName], eBuyData[iItemCost])
menu_item_setname(iMenu, iItem, szMenuText)
}
case '5':{
if(~iFlags & g_iAccessWeaponMenu)
return ITEM_DISABLED
formatex(szMenuText, charsmax(szMenuText), "Show Menu: \y[%s\y]", MENU_TEXT[g_ePlayerData[id][iShowMenu]])
menu_item_setname(iMenu, iItem, szMenuText)
}
case '6':{
if(~iFlags & g_iAccessSpawnItems)
return ITEM_DISABLED
if(g_ePlayerData[id][iPistolIndex] == DEFAULT_PISTOL)
{
formatex(szMenuText, charsmax(szMenuText), "Spawn Pistol: \y[\rDEFAULT\y]")
}else{
ArrayGetArray(g_aDataPistols, g_ePlayerData[id][iPistolIndex], eItemData)
formatex(szMenuText, charsmax(szMenuText), "Spawn Pistol: \y[\w%s\y]", eItemData[szMenuName])
}
menu_item_setname(iMenu, iItem, szMenuText)
}
case '7':{
if(~iFlags & g_iAccessWeaponMenu)
return ITEM_DISABLED
formatex(szMenuText, charsmax(szMenuText), "Menu Auto Close: \y[%s\y]", !g_ePlayerData[id][bCloseMenu] ? "\wYES" : "\rNO")
menu_item_setname(iMenu, iItem, szMenuText)
}
}
return ITEM_IGNORE
}
public BuyMenuHandler(id, iMenu, iItem)
{
g_ePlayerData[id][iInBuyMenu] = NO_MENU
if(iItem == MENU_EXIT || iItem < 0)
return menu_destroy(iMenu)
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
new iItemIndex = str_to_num(szNum)
new eBuyData[BUYMENU_DATA]
ArrayGetArray(g_aDataBuyMenuItems, iItemIndex, eBuyData)
if(BuyItem(id, eBuyData))
g_ePlayerData[id][iPreviousBuy] = iItemIndex
#if defined DONT_CLOSE_MENU
ShowBuyMenu(id, .iPage = (iItem / 7))
#endif
return menu_destroy(iMenu)
}
public WeaponMenuHandler(id, iMenu, iItem)
{
g_ePlayerData[id][iInMenu] = NO_MENU
if(g_iMenuCloseTime > 0)
remove_task(TASKID_MENUCLOSE + id)
if(iItem == MENU_EXIT || iItem < 0)
return PLUGIN_HANDLED
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
new iItemIndex = str_to_num(szNum)
new eMenuData[WEAPON_DATA]
ArrayGetArray(g_aDataMenuItems, iItemIndex, eMenuData)
if(GiveItem(id, eMenuData))
{
g_ePlayerData[id][iPreviousItem] = iItemIndex
g_ePlayerData[id][iUsedCounter]++
if(g_iResetType == RESET_TIME && g_iResetTime > 0)
g_ePlayerData[id][iLastUsedTime] = floatround(get_gametime())
}
#if defined DONT_CLOSE_MENU
ShowWeaponMenu(id, .iPage = (iItem / 7), .bNotify = false)
#endif
return PLUGIN_HANDLED
}
public WeaponMenuCallback(id, iMenu, iItem)
{
if(iItem < 0)
return PLUGIN_HANDLED
new szNum[3], iAccess, hCallback
menu_item_getinfo(iMenu, iItem, iAccess, szNum, charsmax(szNum), _, _, hCallback)
new eMenuData[WEAPON_DATA]
ArrayGetArray(g_aDataMenuItems, str_to_num(szNum), eMenuData)
if(!GetItemAllowed(id, eMenuData[iCounter]))
return ITEM_DISABLED
return ITEM_IGNORE
}
//================= Functions ================
WeaponsReload(id)
{
new iSlot, wEnt, iId
for(iSlot = 1; iSlot<= 2; iSlot++)
{
wEnt = get_pdata_cbase(id, m_rgpPlayerItems_CBasePlayer[iSlot])
while(wEnt > 0)
{
iId = cs_get_weapon_id(wEnt)
if(g_iReloadWeaponFlags & REFILL_CLIP && IsUserSurvived(id))
cs_set_weapon_ammo(wEnt, g_iMaxClip[iId])
if(g_iReloadWeaponFlags & GIVE_AMMO)
ExecuteHamB(Ham_GiveAmmo, id, g_iMaxBPAmmo[iId], g_szAmmoType[iId], g_iMaxBPAmmo[iId])
wEnt = get_pdata_cbase(wEnt, m_pNext, XO_WEAPON)
}
}
}
PreviousBuy(id)
{
#if defined CS_DEFAULT_BUY_SYSTEM
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "You are outside the buyzone!")
return
}
#endif
new eBuyData[BUYMENU_DATA]
ArrayGetArray(g_aDataBuyMenuItems, g_ePlayerData[id][iPreviousBuy], eBuyData)
if(cs_get_user_team(id) != eBuyData[iTeam] && eBuyData[iTeam] != TEAM_ALL)
{
client_print_center(id, "#Alias_Not_Avail", eBuyData[szItemName])
g_ePlayerData[id][iPreviousBuy] = 0
return
}
BuyItem(id, eBuyData)
}
PreviousItem(id)
{
if(g_ePlayerData[id][iUsedCounter] >= g_iMaxUse && !CheckResetType(id, .bNotify = true))
return
new eMenuData[WEAPON_DATA]
ArrayGetArray(g_aDataMenuItems, g_ePlayerData[id][iPreviousItem], eMenuData)
if(GiveItem(id, eMenuData))
{
g_ePlayerData[id][iUsedCounter]++
if(g_iResetType == RESET_TIME && g_iResetTime > 0)
g_ePlayerData[id][iLastUsedTime] = floatround(get_gametime())
}
}
ResetAll(id)
{
g_ePlayerData[id][iUsedCounter] = 0
g_ePlayerData[id][iLastUsedTime] = 0
g_ePlayerData[id][iSpawnCounter] = 0
g_ePlayerData[id][iInMenu] = NO_MENU
g_ePlayerData[id][iInBuyMenu] = NO_MENU
g_ePlayerData[id][iPreviousItem] = 0
g_ePlayerData[id][iPreviousBuy] = 0
if(g_iMenuCloseTime > 0)
remove_task(TASKID_MENUCLOSE + id)
ClearUserSurvived(id)
}
CloseMenu(id, iMenu)
{
if(is_user_connected(id) && !(Menu_Buy <= cs_get_user_menu(id) <= Menu_BuyItem))
{
new iOldMenu, iNewMenu
player_menu_info(id, iOldMenu, iNewMenu)
if(iNewMenu != NO_MENU && iNewMenu == iMenu)
{
menu_cancel(id)
show_menu(id, 0, "^n", 1)
}
}
}
CheckRegisterMessage()
{
static iMsgIdScoreAttrib
if(!iMsgIdScoreAttrib)
iMsgIdScoreAttrib = get_user_msgid("ScoreAttrib")
if(g_bScoreBoardFlag && !g_iMsgHookScoreAttrib)
{
g_iMsgHookScoreAttrib = register_message(iMsgIdScoreAttrib, "Message_ScoreAttrib")
}else{
unregister_message(iMsgIdScoreAttrib, g_iMsgHookScoreAttrib)
g_iMsgHookScoreAttrib = 0
}
}
GivePistol(id)
{
if(g_iPistolsTotal <= 1 || g_ePlayerData[id][iPistolIndex] == DEFAULT_PISTOL)
return
new eItemData[WEAPON_DATA]
ArrayGetArray(g_aDataPistols, g_ePlayerData[id][iPistolIndex], eItemData)
if(GetItemAllowed(id, eItemData[iCounter]))
GiveItem(id, eItemData,.bNotify = false)
}
GiveItem(id, Data[WEAPON_DATA], bool:bNotify = true)
{
new iId = Data[iWeaponID]
if(1<<iId & EXCP_WEAPONS_BIT_SUM || ~pev(id, pev_weapons) & 1<<iId)
{
DoDropWeapon(id, iId)
give_item(id, Data[szWeaponName])
if(Data[iAmount] > 0)
{
if(Data[szWeaponName][0] == 'w') // weapon_
ExecuteHamB(Ham_GiveAmmo, id, Data[iAmount], g_szAmmoType[iId], Data[iAmount])
// set armor value ( item_kevlar, item_assaultsuit )
if(Data[szWeaponName][0] == 'i' && (Data[szWeaponName][5] == 'a' || Data[szWeaponName][5] == 'k'))
set_user_armor(id, Data[iAmount])
}
return 1
}
if(bNotify)
client_print(id, print_center, "#Cstrike_Already_Own_Weapon")
return 0
}
BuyItem(id, eBuyData[BUYMENU_DATA])
{
#if defined CS_DEFAULT_BUY_SYSTEM
if(!CheckBuytime(id))
return 0
#endif
new iMoney = cs_get_user_money(id) - eBuyData[iItemCost]
if(iMoney < 0)
{
client_print(id, print_center, "You need $%d more to buy this item!", (iMoney * -1))
message_begin(MSG_ONE_UNRELIABLE, g_iMsgIdBlinkAcct, .player = id)
write_byte(2/*BlinkAmt*/)
message_end()
return 0
}
callfunc_begin_i(eBuyData[iFuncID], eBuyData[iPluginID])
callfunc_push_int(id)
if(callfunc_end() == BUY_SUCCESS)
{
cs_set_user_money(id, iMoney)
return 1
}
return 0
}
// ==================== Stocks ====================
stock bool:GetItemAllowed(id, iItemCounter)
{
switch(g_iCounterType)
{
case COUNTER_ROUND: return (g_iRoundCounter < iItemCounter) ? false : true
case COUNTER_SPAWN: return (g_ePlayerData[id][iSpawnCounter] < iItemCounter) ? false : true
case COUNTER_FRAG: return (get_user_frags(id) < iItemCounter) ? false : true
default: return false
}
return false
}
stock bool:CheckConfigValues()
{
if(!(COUNTER_ROUND <= g_iCounterType <= COUNTER_FRAG))
{
server_print("[V.I.P] WARNING: Invalid ^"counter_type^" value ^"%d^"", g_iCounterType)
return false
}
if(!(RESET_RESTART <= g_iResetType <= RESET_TIME))
{
server_print("[V.I.P] WARNING: Invalid ^"reset_type^" value ^"%d^"", g_iResetType)
return false
}
return true
}
stock bool:CheckResetType(id, bool:bNotify = false)
{
new bool:bReturn
switch(g_iResetType)
{
case RESET_RESTART:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per game", g_iMaxUse)
bReturn = false
}
case RESET_ROUND:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per round", g_iMaxUse)
bReturn = false
}
case RESET_DEATH:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per life", g_iMaxUse)
bReturn = false
}
case RESET_SPAWN:{
if(bNotify)
client_print(id, print_center, "You can take %d time(s) per spawn", g_iMaxUse)
bReturn = false
}
case RESET_TIME:{
new iCurTime = floatround(get_gametime())
new iTime = (g_ePlayerData[id][iLastUsedTime] + g_iResetTime)
if(iTime > iCurTime)
{
if(bNotify)
client_print(id, print_center, "Is available after %d second(s)", (iTime - iCurTime))
bReturn = false
}
else if(iTime <= iCurTime)
{
g_ePlayerData[id][iUsedCounter] = 0
bReturn = true
}
}
}
return bReturn
}
stock bool:CheckBuytime(id)
{
if(!g_bBuyTime || !(g_bBuyTime = get_gametime() < g_flEndOfBuyTime))
{
client_print_center(id, "#Cant_buy", g_szBuyTime)
return false
}
return true
}
И ещё бы прикрутить к этому плагину золотое оружие ак и эмку.Думал взять код с vip_custom ,но там не знаю как сделать.
// Copyright © 2015 Vaqtincha
/*********************** V.I.P Custom Weapons **********************
*
* Credits:
* ConnorMcLeod for cstrike_pdatas
* SISA for help
* AlejandroSk for plugin "Golden Ak-47"
*********************************************************************/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "V.I.P Custom AK-47" // don't change this!
#define PLUGIN_VERSION "1.0.0" // version for "V.I.P Custom Weapons"
#define PLUGIN_AUTHOR "Vaqtincha"
#define get_weapon_owner(%1) get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
#define fm_get_user_money(%1) get_pdata_int(%1, m_iAccount, XO_PLAYER)
#if AMXX_VERSION_NUM < 183
#define HasShield(%1) (get_pdata_int(%1, m_iUserPrefs, XO_PLAYER) & m_bHasShield)
#else
#define HasShield(%1) get_pdata_bool(%1, m_bHasShield)
#endif
#define IsPlayer(%1) ( 1 <= (%1) <= giMaxPlayers )
#define MAX_PLAYERS 32
/*-----------------------------------------------------------------*/
#define WP 8496
new const weapon_name[] = "weapon_ak47"
new const ammo_type[] = "762nato"
new const max_bpammo[] = 90
new const buy_cmd[] = "say /ak"
new const weapon_id = CSW_AK47
new const V_MODEL[] = "models/custom/v_ak47.mdl" // view weapon model
new const P_MODEL[] = "models/custom/p_ak47.mdl" // player weapon model
new const W_MODEL[] = "models/custom/w_ak47.mdl" // world weapon model
new const W_DEF_MODEL[] = "models/w_ak47.mdl" // default world model
/*-----------------------------------------------------------------*/
static buyaccess
new weapcost, droptype, alw_round_buy, accuracy_fix
new Float:damage, inbuyzone, buytime
new Float:g_GameTime
new bool:g_HasWeap[MAX_PLAYERS + 1] = false
new bool:g_buyzone[MAX_PLAYERS + 1]
new giCounter, giMaxPlayers
const PRIMARY_WEAPONS_BIT_SUM = 1<<CSW_SCOUT|1<<CSW_XM1014|1<<CSW_MAC10|1<<CSW_AUG|1<<CSW_UMP45
|1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_MP5NAVY|1<<CSW_M249|1<<CSW_M3
|1<<CSW_M4A1|1<<CSW_TMP|1<<CSW_G3SG1|1<<CSW_SG552|1<<CSW_AK47|1<<CSW_P90
const SECONDARY_WEAPONS_BIT_SUM = 1<<CSW_P228|1<<CSW_ELITE|1<<CSW_FIVESEVEN|1<<CSW_USP|1<<CSW_GLOCK18|1<<CSW_DEAGLE
// Offsets
#if AMXX_VERSION_NUM < 183
const m_bHasShield = 1<<24
const m_iUserPrefs = 510
#else
const m_bHasShield = 2043
#endif
const m_flAccuracy = 62
const m_pPlayer = 41
const XO_PLAYER = 5
const XO_WEAPON = 4
const m_pActiveItem = 373
// const m_rgpPlayerItems_wpnbx_slot2 = 36 // secondary weapon slot
const m_rgpPlayerItems_wpnbx_slot1 = 35 // primary weapon slot
#if cellbits == 32
const m_iAccount = 115
#else
const m_iAccount = 140
#endif
public plugin_init()
{
new mapname[4]
get_mapname(mapname, charsmax(mapname))
if(equali(mapname, "de_") || equali(mapname, "cs_"))
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_dictionary ( "vip_custom.txt" )
loadconfig()
giMaxPlayers = get_maxplayers()
register_clcmd( buy_cmd, "buyCMD") // don't change this!
if(inbuyzone) register_event("StatusIcon", "event_buyzone_icon", "b", "2=buyzone")
// Events
register_event( "TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event("DeathMsg", "Death", "a")
register_forward(FM_SetModel, "fw_SetModel")
RegisterHam(Ham_Item_Deploy, weapon_name, "fw_ItemDeploy_Weap_Post", 1)
RegisterHam(Ham_Item_AttachToPlayer, weapon_name, "fw_Item_AttachToPlayer_Pre", 0)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Pre", 0)
if(accuracy_fix) RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Pre", 0)
}
else
pause("a")
}
public loadconfig()
{
new ConfigFile[64], szMsg[128] // "addons/amxmodx/configs/vip_custom.ini" 37
get_localinfo("amxx_configsdir", ConfigFile, charsmax(ConfigFile))
add(ConfigFile, charsmax(ConfigFile), "/vip_custom.ini")
if( !file_exists(ConfigFile) )
{
formatex( szMsg, charsmax(szMsg), "%s Config File Not Found!", PLUGIN_NAME )
set_fail_state(szMsg)
return
}
new fp = fopen(ConfigFile, "rt")
if( fp )
{
new Datas[86], Setting[24], Value[15]
while( !feof(fp) )
{
fgets(fp, Datas, charsmax(Datas))
trim(Datas)
if(!Datas[0] || Datas[0] == ';' || Datas[0] == '#' || Datas[0] == '/'|| Datas[0] == '[')
{
continue
}
new Sign[3]
parse(Datas, Setting, charsmax(Setting), Sign, charsmax(Sign), Value, charsmax(Value))
if( equali(Setting, "buy_access")){
buyaccess = read_flags(Value)
}else if( equali(Setting, "drop_type")){
droptype = str_to_num(Value)
}else if( equali(Setting, "allowed_round_buymenu")){
alw_round_buy = str_to_num(Value)
}else if( equali(Setting, "buyzone_check")){
inbuyzone = str_to_num(Value) ? true : false
}else if( equali(Setting, "buytime_check")){
buytime = str_to_num(Value) ? true : false
}else if( equali(Setting, "ak47_cost")){
weapcost = str_to_num(Value)
}else if( equali(Setting, "ak47_damage")){
damage = str_to_float(Value)
}else if( equali(Setting, "ak47_accuracy_fix")){
accuracy_fix = str_to_num(Value) ? true : false
}
}
formatex( szMsg, charsmax(szMsg), "%s Config Successfully Loaded!", PLUGIN_NAME )
server_print(szMsg)
}
}
public plugin_precache()
{
precache_model(V_MODEL)
precache_model(P_MODEL)
precache_model(W_MODEL)
}
public event_buyzone_icon(id)
{
g_buyzone[id] = bool:read_data(1)
}
public client_putinserver(id)
{
g_HasWeap[id] = false
}
public client_disconnect(id)
{
g_HasWeap[id] = false
if(inbuyzone)
{
g_buyzone[id] = false
}
}
public Event_NewGame()
{
giCounter = 0
new iPlayers[32], iNum
get_players(iPlayers, iNum )
for ( --iNum; iNum >= 0; --iNum )
{
g_HasWeap[iPlayers[iNum]] = false
}
}
public Event_NewRound()
{
giCounter++
if(buytime)
{
g_GameTime = get_gametime()
}
}
public Death()
{
g_HasWeap[read_data(2)] = false
}
public buyCMD(id)
{
if(!is_user_alive(id))
{
client_print(id, print_center, "%L", LANG_SERVER,"ONLY_ALIVE")
return PLUGIN_HANDLED
}
// Check if the player is in the buyzone
if(inbuyzone)
{
if(!g_buyzone[id])
{
client_print(id, print_center, "%L", LANG_SERVER,"OUTSIDE_BUYZONE")
return PLUGIN_HANDLED
}
}
// Check buying time
if(buytime)
{
new Float:buytime = get_cvar_float("mp_buytime") * 60.0
new Float:timepassed = get_gametime() - g_GameTime
if(floatcmp(timepassed , buytime) == 1)
{
client_print(id, print_center, "%L", LANG_SERVER,"SECONDS_HAVE_PASSED",buytime)
return PLUGIN_HANDLED
}
}
if(giCounter < alw_round_buy)
{
client_print(id, print_center, "%L", LANG_SERVER,"NOT_AVAILABLE")
return PLUGIN_HANDLED
}
if(!(get_user_flags(id) & buyaccess ))
{
client_print(id, print_center, "%L", LANG_SERVER,"NO_ACC_CMD")
return PLUGIN_HANDLED
}
if(fm_get_user_money(id) < weapcost )
{
client_print(id, print_center, "%L", LANG_SERVER,"INSUFFICIENT_FUNDS")
return PLUGIN_HANDLED
}
else{
fm_set_user_money(id, fm_get_user_money(id) - weapcost , 1)
GiveWeapon(id)
}
return PLUGIN_CONTINUE
}
public GiveWeapon(id)
{
drop_weapons(id, 1)
g_HasWeap[id] = true
fm_give_item(id, weapon_name)
ExecuteHamB(Ham_GiveAmmo, id, max_bpammo, ammo_type, max_bpammo)
engclient_cmd(id, weapon_name)
}
public fw_ItemDeploy_Weap_Post(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pev(iPlayer, pev_viewmodel2, V_MODEL)
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
}
return HAM_IGNORED
}
public fw_Weapon_PrimaryAttack_Pre(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pdata_float(ent, m_flAccuracy, 0.0, XO_WEAPON)
}
}
public fw_Item_AttachToPlayer_Pre(ent, id)
{
if ( pev (ent, pev_impulse)==WP)
g_HasWeap[id] = true
if( get_pdata_cbase(id, m_pActiveItem) != ent)
{
return HAM_IGNORED
}
fw_ItemDeploy_Weap_Post(ent)
return HAM_IGNORED
}
public fw_SetModel(ent, model[])
{
new id = pev (ent, pev_owner)
if( pev_valid(ent))
{
if( equal(model, W_DEF_MODEL))
{
new weapon = get_pdata_cbase(ent, m_rgpPlayerItems_wpnbx_slot1, XO_WEAPON)
if(weapon > 0 && pev(weapon, pev_impulse)==WP)
{
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL )
return FMRES_SUPERCEDE
}
}
}
return FMRES_IGNORED
}
public fw_TakeDamage_Pre(victim, inflictor, attacker, Float:fdamage, damage_bits)
{
if(!(damage_bits & DMG_BULLET)||!IsPlayer(attacker)|| get_user_weapon(attacker) != weapon_id)
return HAM_IGNORED
if(g_HasWeap[attacker] && attacker == inflictor )
{
SetHamParamFloat(4, fdamage * damage)
return HAM_HANDLED
}
return HAM_IGNORED
}
//================================ STOCKS ==============================//
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons
if((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM || HasShield(id)))
|| (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
switch(droptype)
{
case 0: ham_strip_weapon(id, wname)
case 1: engclient_cmd(id, "drop", wname)
}
}
}
}
stock fm_give_item(index, const item[])
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
return 0
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent))
return 0
new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
set_pev(ent, pev_impulse, WP)
dllfunc(DLLFunc_Spawn, ent)
new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent
engfunc(EngFunc_RemoveEntity, ent)
return -1
}
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0
new wId = get_weaponid(weapon)
if(!wId) return 0
new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
if(!wEnt) return 0
new iTmp
if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt)
if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0
ExecuteHamB(Ham_Item_Kill, wEnt)
set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))
return 1
}
stock fm_set_user_money(client, money, flash=1)
{
set_pdata_int(client, m_iAccount, money, XO_PLAYER)
static Money
if( Money || (Money = get_user_msgid("Money")) )
{
emessage_begin(MSG_ONE_UNRELIABLE, Money, _, client)
ewrite_long(money)
ewrite_byte(flash ? 1 : 0)
emessage_end()
}
}
/*********************** V.I.P Custom Weapons **********************
*
* Credits:
* ConnorMcLeod for cstrike_pdatas
* SISA for help
* AlejandroSk for plugin "Golden Ak-47"
*********************************************************************/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "V.I.P Custom AK-47" // don't change this!
#define PLUGIN_VERSION "1.0.0" // version for "V.I.P Custom Weapons"
#define PLUGIN_AUTHOR "Vaqtincha"
#define get_weapon_owner(%1) get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
#define fm_get_user_money(%1) get_pdata_int(%1, m_iAccount, XO_PLAYER)
#if AMXX_VERSION_NUM < 183
#define HasShield(%1) (get_pdata_int(%1, m_iUserPrefs, XO_PLAYER) & m_bHasShield)
#else
#define HasShield(%1) get_pdata_bool(%1, m_bHasShield)
#endif
#define IsPlayer(%1) ( 1 <= (%1) <= giMaxPlayers )
#define MAX_PLAYERS 32
/*-----------------------------------------------------------------*/
#define WP 8496
new const weapon_name[] = "weapon_ak47"
new const ammo_type[] = "762nato"
new const max_bpammo[] = 90
new const buy_cmd[] = "say /ak"
new const weapon_id = CSW_AK47
new const V_MODEL[] = "models/custom/v_ak47.mdl" // view weapon model
new const P_MODEL[] = "models/custom/p_ak47.mdl" // player weapon model
new const W_MODEL[] = "models/custom/w_ak47.mdl" // world weapon model
new const W_DEF_MODEL[] = "models/w_ak47.mdl" // default world model
/*-----------------------------------------------------------------*/
static buyaccess
new weapcost, droptype, alw_round_buy, accuracy_fix
new Float:damage, inbuyzone, buytime
new Float:g_GameTime
new bool:g_HasWeap[MAX_PLAYERS + 1] = false
new bool:g_buyzone[MAX_PLAYERS + 1]
new giCounter, giMaxPlayers
const PRIMARY_WEAPONS_BIT_SUM = 1<<CSW_SCOUT|1<<CSW_XM1014|1<<CSW_MAC10|1<<CSW_AUG|1<<CSW_UMP45
|1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_MP5NAVY|1<<CSW_M249|1<<CSW_M3
|1<<CSW_M4A1|1<<CSW_TMP|1<<CSW_G3SG1|1<<CSW_SG552|1<<CSW_AK47|1<<CSW_P90
const SECONDARY_WEAPONS_BIT_SUM = 1<<CSW_P228|1<<CSW_ELITE|1<<CSW_FIVESEVEN|1<<CSW_USP|1<<CSW_GLOCK18|1<<CSW_DEAGLE
// Offsets
#if AMXX_VERSION_NUM < 183
const m_bHasShield = 1<<24
const m_iUserPrefs = 510
#else
const m_bHasShield = 2043
#endif
const m_flAccuracy = 62
const m_pPlayer = 41
const XO_PLAYER = 5
const XO_WEAPON = 4
const m_pActiveItem = 373
// const m_rgpPlayerItems_wpnbx_slot2 = 36 // secondary weapon slot
const m_rgpPlayerItems_wpnbx_slot1 = 35 // primary weapon slot
#if cellbits == 32
const m_iAccount = 115
#else
const m_iAccount = 140
#endif
public plugin_init()
{
new mapname[4]
get_mapname(mapname, charsmax(mapname))
if(equali(mapname, "de_") || equali(mapname, "cs_"))
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_dictionary ( "vip_custom.txt" )
loadconfig()
giMaxPlayers = get_maxplayers()
register_clcmd( buy_cmd, "buyCMD") // don't change this!
if(inbuyzone) register_event("StatusIcon", "event_buyzone_icon", "b", "2=buyzone")
// Events
register_event( "TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event("DeathMsg", "Death", "a")
register_forward(FM_SetModel, "fw_SetModel")
RegisterHam(Ham_Item_Deploy, weapon_name, "fw_ItemDeploy_Weap_Post", 1)
RegisterHam(Ham_Item_AttachToPlayer, weapon_name, "fw_Item_AttachToPlayer_Pre", 0)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Pre", 0)
if(accuracy_fix) RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Pre", 0)
}
else
pause("a")
}
public loadconfig()
{
new ConfigFile[64], szMsg[128] // "addons/amxmodx/configs/vip_custom.ini" 37
get_localinfo("amxx_configsdir", ConfigFile, charsmax(ConfigFile))
add(ConfigFile, charsmax(ConfigFile), "/vip_custom.ini")
if( !file_exists(ConfigFile) )
{
formatex( szMsg, charsmax(szMsg), "%s Config File Not Found!", PLUGIN_NAME )
set_fail_state(szMsg)
return
}
new fp = fopen(ConfigFile, "rt")
if( fp )
{
new Datas[86], Setting[24], Value[15]
while( !feof(fp) )
{
fgets(fp, Datas, charsmax(Datas))
trim(Datas)
if(!Datas[0] || Datas[0] == ';' || Datas[0] == '#' || Datas[0] == '/'|| Datas[0] == '[')
{
continue
}
new Sign[3]
parse(Datas, Setting, charsmax(Setting), Sign, charsmax(Sign), Value, charsmax(Value))
if( equali(Setting, "buy_access")){
buyaccess = read_flags(Value)
}else if( equali(Setting, "drop_type")){
droptype = str_to_num(Value)
}else if( equali(Setting, "allowed_round_buymenu")){
alw_round_buy = str_to_num(Value)
}else if( equali(Setting, "buyzone_check")){
inbuyzone = str_to_num(Value) ? true : false
}else if( equali(Setting, "buytime_check")){
buytime = str_to_num(Value) ? true : false
}else if( equali(Setting, "ak47_cost")){
weapcost = str_to_num(Value)
}else if( equali(Setting, "ak47_damage")){
damage = str_to_float(Value)
}else if( equali(Setting, "ak47_accuracy_fix")){
accuracy_fix = str_to_num(Value) ? true : false
}
}
formatex( szMsg, charsmax(szMsg), "%s Config Successfully Loaded!", PLUGIN_NAME )
server_print(szMsg)
}
}
public plugin_precache()
{
precache_model(V_MODEL)
precache_model(P_MODEL)
precache_model(W_MODEL)
}
public event_buyzone_icon(id)
{
g_buyzone[id] = bool:read_data(1)
}
public client_putinserver(id)
{
g_HasWeap[id] = false
}
public client_disconnect(id)
{
g_HasWeap[id] = false
if(inbuyzone)
{
g_buyzone[id] = false
}
}
public Event_NewGame()
{
giCounter = 0
new iPlayers[32], iNum
get_players(iPlayers, iNum )
for ( --iNum; iNum >= 0; --iNum )
{
g_HasWeap[iPlayers[iNum]] = false
}
}
public Event_NewRound()
{
giCounter++
if(buytime)
{
g_GameTime = get_gametime()
}
}
public Death()
{
g_HasWeap[read_data(2)] = false
}
public buyCMD(id)
{
if(!is_user_alive(id))
{
client_print(id, print_center, "%L", LANG_SERVER,"ONLY_ALIVE")
return PLUGIN_HANDLED
}
// Check if the player is in the buyzone
if(inbuyzone)
{
if(!g_buyzone[id])
{
client_print(id, print_center, "%L", LANG_SERVER,"OUTSIDE_BUYZONE")
return PLUGIN_HANDLED
}
}
// Check buying time
if(buytime)
{
new Float:buytime = get_cvar_float("mp_buytime") * 60.0
new Float:timepassed = get_gametime() - g_GameTime
if(floatcmp(timepassed , buytime) == 1)
{
client_print(id, print_center, "%L", LANG_SERVER,"SECONDS_HAVE_PASSED",buytime)
return PLUGIN_HANDLED
}
}
if(giCounter < alw_round_buy)
{
client_print(id, print_center, "%L", LANG_SERVER,"NOT_AVAILABLE")
return PLUGIN_HANDLED
}
if(!(get_user_flags(id) & buyaccess ))
{
client_print(id, print_center, "%L", LANG_SERVER,"NO_ACC_CMD")
return PLUGIN_HANDLED
}
if(fm_get_user_money(id) < weapcost )
{
client_print(id, print_center, "%L", LANG_SERVER,"INSUFFICIENT_FUNDS")
return PLUGIN_HANDLED
}
else{
fm_set_user_money(id, fm_get_user_money(id) - weapcost , 1)
GiveWeapon(id)
}
return PLUGIN_CONTINUE
}
public GiveWeapon(id)
{
drop_weapons(id, 1)
g_HasWeap[id] = true
fm_give_item(id, weapon_name)
ExecuteHamB(Ham_GiveAmmo, id, max_bpammo, ammo_type, max_bpammo)
engclient_cmd(id, weapon_name)
}
public fw_ItemDeploy_Weap_Post(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pev(iPlayer, pev_viewmodel2, V_MODEL)
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
}
return HAM_IGNORED
}
public fw_Weapon_PrimaryAttack_Pre(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pdata_float(ent, m_flAccuracy, 0.0, XO_WEAPON)
}
}
public fw_Item_AttachToPlayer_Pre(ent, id)
{
if ( pev (ent, pev_impulse)==WP)
g_HasWeap[id] = true
if( get_pdata_cbase(id, m_pActiveItem) != ent)
{
return HAM_IGNORED
}
fw_ItemDeploy_Weap_Post(ent)
return HAM_IGNORED
}
public fw_SetModel(ent, model[])
{
new id = pev (ent, pev_owner)
if( pev_valid(ent))
{
if( equal(model, W_DEF_MODEL))
{
new weapon = get_pdata_cbase(ent, m_rgpPlayerItems_wpnbx_slot1, XO_WEAPON)
if(weapon > 0 && pev(weapon, pev_impulse)==WP)
{
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL )
return FMRES_SUPERCEDE
}
}
}
return FMRES_IGNORED
}
public fw_TakeDamage_Pre(victim, inflictor, attacker, Float:fdamage, damage_bits)
{
if(!(damage_bits & DMG_BULLET)||!IsPlayer(attacker)|| get_user_weapon(attacker) != weapon_id)
return HAM_IGNORED
if(g_HasWeap[attacker] && attacker == inflictor )
{
SetHamParamFloat(4, fdamage * damage)
return HAM_HANDLED
}
return HAM_IGNORED
}
//================================ STOCKS ==============================//
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons
if((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM || HasShield(id)))
|| (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
switch(droptype)
{
case 0: ham_strip_weapon(id, wname)
case 1: engclient_cmd(id, "drop", wname)
}
}
}
}
stock fm_give_item(index, const item[])
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
return 0
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent))
return 0
new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
set_pev(ent, pev_impulse, WP)
dllfunc(DLLFunc_Spawn, ent)
new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent
engfunc(EngFunc_RemoveEntity, ent)
return -1
}
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0
new wId = get_weaponid(weapon)
if(!wId) return 0
new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
if(!wEnt) return 0
new iTmp
if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt)
if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0
ExecuteHamB(Ham_Item_Kill, wEnt)
set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))
return 1
}
stock fm_set_user_money(client, money, flash=1)
{
set_pdata_int(client, m_iAccount, money, XO_PLAYER)
static Money
if( Money || (Money = get_user_msgid("Money")) )
{
emessage_begin(MSG_ONE_UNRELIABLE, Money, _, client)
ewrite_long(money)
ewrite_byte(flash ? 1 : 0)
emessage_end()
}
}
// Copyright © 2015 Vaqtincha
/*********************** V.I.P Custom Weapons **********************
*
* Credits:
* ConnorMcLeod for cstrike_pdatas and "Nosil" plugin
* SISA for help
* AlejandroSk for plugin "Golden Ak-47"
*********************************************************************/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "V.I.P Custom M4A1" // don't change this!
#define PLUGIN_VERSION "1.0.0" // version for "V.I.P Custom Weapons"
#define PLUGIN_AUTHOR "Vaqtincha"
#define get_weapon_owner(%1) get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
#define fm_get_user_money(%1) get_pdata_int(%1, m_iAccount, XO_PLAYER)
#define get_weapon_state(%1) get_pdata_int(%1, m_fWeaponState, XO_WEAPON)
#if AMXX_VERSION_NUM < 183
#define HasShield(%1) (get_pdata_int(%1, m_iUserPrefs, XO_PLAYER) & m_bHasShield)
#else
#define HasShield(%1) get_pdata_bool(%1, m_bHasShield)
#endif
#define IsPlayer(%1) ( 1 <= (%1) <= giMaxPlayers )
#define MAX_PLAYERS 32
/*-----------------------------------------------------------------*/
#define WP 9147
// #define NOSIL_SUPPORT
new const weapon_name[] = "weapon_m4a1"
new const ammo_type[] = "556nato"
new const max_bpammo[] = 90
new const buy_cmd[] = "say /m4"
new const weapon_id = CSW_M4A1
new const V_MODEL[] = "models/custom/v_m4a1.mdl" // view weapon model
new const P_MODEL[] = "models/custom/p_m4a1.mdl" // player weapon model
new const W_MODEL[] = "models/custom/w_m4a1.mdl" // world weapon model
new const W_DEF_MODEL[] = "models/w_m4a1.mdl" // default world model
#if defined NOSIL_SUPPORT
new P_MODEL_NOSIL[] = "models/custom/p_m4a1_nosil.mdl"// player weapon nosil model
new W_MODEL_NOSIL[] = "models/custom/w_m4a1_nosil.mdl"// world weapon nosil model
#endif
/*-----------------------------------------------------------------*/
static buyaccess
new weapcost, droptype, alw_round_buy, accuracy_fix
new Float:damage, inbuyzone, buytime
new Float:g_GameTime
new bool:g_HasWeap[MAX_PLAYERS + 1] = false
new bool:g_buyzone[MAX_PLAYERS + 1]
new giCounter, giMaxPlayers
const PRIMARY_WEAPONS_BIT_SUM = 1<<CSW_SCOUT|1<<CSW_XM1014|1<<CSW_MAC10|1<<CSW_AUG|1<<CSW_UMP45
|1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_MP5NAVY|1<<CSW_M249|1<<CSW_M3
|1<<CSW_M4A1|1<<CSW_TMP|1<<CSW_G3SG1|1<<CSW_SG552|1<<CSW_AK47|1<<CSW_P90
const SECONDARY_WEAPONS_BIT_SUM = 1<<CSW_P228|1<<CSW_ELITE|1<<CSW_FIVESEVEN|1<<CSW_USP|1<<CSW_GLOCK18|1<<CSW_DEAGLE
// Offsets
#if AMXX_VERSION_NUM < 183
const m_bHasShield = 1<<24
const m_iUserPrefs = 510
#else
const m_bHasShield = 2043
#endif
const m_flAccuracy = 62
const m_pPlayer = 41
const XO_PLAYER = 5
const XO_WEAPON = 4
const m_pActiveItem = 373
// const m_rgpPlayerItems_wpnbx_slot2 = 36 // secondary weapon slot
const m_rgpPlayerItems_wpnbx_slot1 = 35 // primary weapon slot
#if defined NOSIL_SUPPORT
const m_fWeaponState = 74
const WEAPONSTATE_M4A1_SILENCED = 1<<2
#endif
#if cellbits == 32
const m_iAccount = 115
#else
const m_iAccount = 140
#endif
public plugin_init()
{
new mapname[4]
get_mapname(mapname, charsmax(mapname))
if(equali(mapname, "de_") || equali(mapname, "cs_"))
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_dictionary ( "vip_custom.txt" )
loadconfig()
giMaxPlayers = get_maxplayers()
register_clcmd( buy_cmd, "buyCMD") // don't change this!
if(inbuyzone) register_event("StatusIcon", "event_buyzone_icon", "b", "2=buyzone")
// Events
register_event( "TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event("DeathMsg", "Death", "a")
register_forward(FM_SetModel, "fw_SetModel")
RegisterHam(Ham_Item_Deploy, weapon_name, "fw_ItemDeploy_Weap_Post", 1)
RegisterHam(Ham_Item_AttachToPlayer, weapon_name, "fw_Item_AttachToPlayer_Pre", 0)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Pre", 0)
if(accuracy_fix) RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Pre", 0)
#if defined NOSIL_SUPPORT
RegisterHam(Ham_Weapon_SecondaryAttack, weapon_name, "fw_Weapon_SecondaryAttack_Post" ,1)
#endif
}
else
pause("a")
}
public loadconfig()
{
new ConfigFile[64], szMsg[128] // "addons/amxmodx/configs/vip_custom.ini" 37
get_localinfo("amxx_configsdir", ConfigFile, charsmax(ConfigFile))
add(ConfigFile, charsmax(ConfigFile), "/vip_custom.ini")
if( !file_exists(ConfigFile) )
{
formatex( szMsg, charsmax(szMsg), "%s Config File Not Found!", PLUGIN_NAME )
set_fail_state(szMsg)
return
}
new fp = fopen(ConfigFile, "rt")
if( fp )
{
new Datas[86], Setting[24], Value[15]
while( !feof(fp) )
{
fgets(fp, Datas, charsmax(Datas))
trim(Datas)
if(!Datas[0] || Datas[0] == ';' || Datas[0] == '#' || Datas[0] == '/'|| Datas[0] == '[')
{
continue
}
new Sign[3]
parse(Datas, Setting, charsmax(Setting), Sign, charsmax(Sign), Value, charsmax(Value))
if( equali(Setting, "buy_access")){
buyaccess = read_flags(Value)
}else if( equali(Setting, "drop_type")){
droptype = str_to_num(Value)
}else if( equali(Setting, "allowed_round_buymenu")){
alw_round_buy = str_to_num(Value)
}else if( equali(Setting, "buyzone_check")){
inbuyzone = str_to_num(Value) ? true : false
}else if( equali(Setting, "buytime_check")){
buytime = str_to_num(Value) ? true : false
}else if( equali(Setting, "m4a1_cost")){
weapcost = str_to_num(Value)
}else if( equali(Setting, "m4a1_damage")){
damage = str_to_float(Value)
}else if( equali(Setting, "m4a1_accuracy_fix")){
accuracy_fix = str_to_num(Value) ? true : false
}
}
formatex( szMsg, charsmax(szMsg), "%s Config Successfully Loaded!", PLUGIN_NAME )
server_print(szMsg)
}
}
public plugin_precache()
{
precache_model(V_MODEL)
precache_model(P_MODEL)
precache_model(W_MODEL)
#if defined NOSIL_SUPPORT
precache_model(P_MODEL_NOSIL)
precache_model(W_MODEL_NOSIL)
#endif
}
public event_buyzone_icon(id)
{
g_buyzone[id] = bool:read_data(1)
}
public client_putinserver(id)
{
g_HasWeap[id] = false
}
public client_disconnect(id)
{
g_HasWeap[id] = false
if(inbuyzone)
{
g_buyzone[id] = false
}
}
public Event_NewGame()
{
giCounter = 0
new iPlayers[32], iNum
get_players(iPlayers, iNum )
for ( --iNum; iNum >= 0; --iNum )
{
g_HasWeap[iPlayers[iNum]] = false
}
}
public Event_NewRound()
{
giCounter++
if(buytime)
{
g_GameTime = get_gametime()
}
}
public Death()
{
g_HasWeap[read_data(2)] = false
}
public buyCMD(id)
{
if(!is_user_alive(id))
{
client_print(id, print_center, "%L", LANG_SERVER,"ONLY_ALIVE")
return PLUGIN_HANDLED
}
// Check if the player is in the buyzone
if(inbuyzone)
{
if(!g_buyzone[id])
{
client_print(id, print_center, "%L", LANG_SERVER,"OUTSIDE_BUYZONE")
return PLUGIN_HANDLED
}
}
// Check buying time
if(buytime)
{
new Float:buytime = get_cvar_float("mp_buytime") * 60.0
new Float:timepassed = get_gametime() - g_GameTime
if(floatcmp(timepassed , buytime) == 1)
{
client_print(id, print_center, "%L", LANG_SERVER,"SECONDS_HAVE_PASSED",buytime)
return PLUGIN_HANDLED
}
}
if(giCounter < alw_round_buy)
{
client_print(id, print_center, "%L", LANG_SERVER,"NOT_AVAILABLE")
return PLUGIN_HANDLED
}
if(!(get_user_flags(id) & buyaccess ))
{
client_print(id, print_center, "%L", LANG_SERVER,"NO_ACC_CMD")
return PLUGIN_HANDLED
}
if(fm_get_user_money(id) < weapcost )
{
client_print(id, print_center, "%L", LANG_SERVER,"INSUFFICIENT_FUNDS")
return PLUGIN_HANDLED
}
else{
fm_set_user_money(id, fm_get_user_money(id) - weapcost , 1)
GiveWeapon(id)
}
return PLUGIN_CONTINUE
}
public GiveWeapon(id)
{
drop_weapons(id, 1)
g_HasWeap[id] = true
fm_give_item(id, weapon_name)
ExecuteHamB(Ham_GiveAmmo, id, max_bpammo, ammo_type, max_bpammo)
engclient_cmd(id, weapon_name)
}
public fw_ItemDeploy_Weap_Post(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pev(iPlayer, pev_viewmodel2, V_MODEL)
#if defined NOSIL_SUPPORT
if( ~get_weapon_state(ent) & WEAPONSTATE_M4A1_SILENCED)
{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL_NOSIL)
}
else{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
}
#else
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
#endif
}
return HAM_IGNORED
}
#if defined NOSIL_SUPPORT
public fw_Weapon_SecondaryAttack_Post(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
if( ~get_weapon_state(ent) & WEAPONSTATE_M4A1_SILENCED)
{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL_NOSIL)
}
else{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
}
}
}
#endif
public fw_Weapon_PrimaryAttack_Pre(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pdata_float(ent, m_flAccuracy, 0.0, XO_WEAPON)
}
}
public fw_Item_AttachToPlayer_Pre(ent, id)
{
if ( pev (ent, pev_impulse)==WP)
g_HasWeap[id] = true
if( get_pdata_cbase(id, m_pActiveItem) != ent)
{
return HAM_IGNORED
}
fw_ItemDeploy_Weap_Post(ent)
return HAM_IGNORED
}
public fw_SetModel(ent, model[])
{
new id = pev (ent, pev_owner)
if( pev_valid(ent))
{
if( equal(model, W_DEF_MODEL))
{
new weapon = get_pdata_cbase(ent, m_rgpPlayerItems_wpnbx_slot1, XO_WEAPON)
if(weapon > 0 && pev(weapon, pev_impulse)==WP)
{
#if defined NOSIL_SUPPORT
if( ~get_weapon_state(weapon) & WEAPONSTATE_M4A1_SILENCED)
{
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL_NOSIL)
return FMRES_SUPERCEDE
}else{
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL)
return FMRES_SUPERCEDE
}
#else
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL)
return FMRES_SUPERCEDE
#endif
}
}
}
return FMRES_IGNORED
}
public fw_TakeDamage_Pre(victim, inflictor, attacker, Float:fdamage, damage_bits)
{
if(!(damage_bits & DMG_BULLET)||!IsPlayer(attacker)|| get_user_weapon(attacker) != weapon_id)
return HAM_IGNORED
if(g_HasWeap[attacker] && attacker == inflictor )
{
SetHamParamFloat(4, fdamage * damage)
return HAM_HANDLED
}
return HAM_IGNORED
}
//================================ STOCKS ==============================//
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons
if((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM || HasShield(id)))
|| (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
switch(droptype)
{
case 0: ham_strip_weapon(id, wname)
case 1: engclient_cmd(id, "drop", wname)
}
}
}
}
stock fm_give_item(index, const item[])
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
return 0
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent))
return 0
new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
set_pev(ent, pev_impulse, WP)
dllfunc(DLLFunc_Spawn, ent)
new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent
engfunc(EngFunc_RemoveEntity, ent)
return -1
}
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0
new wId = get_weaponid(weapon)
if(!wId) return 0
new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
if(!wEnt) return 0
new iTmp
if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt)
if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0
ExecuteHamB(Ham_Item_Kill, wEnt)
set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))
return 1
}
stock fm_set_user_money(client, money, flash=1)
{
set_pdata_int(client, m_iAccount, money, XO_PLAYER)
static Money
if( Money || (Money = get_user_msgid("Money")) )
{
emessage_begin(MSG_ONE_UNRELIABLE, Money, _, client)
ewrite_long(money)
ewrite_byte(flash ? 1 : 0)
emessage_end()
}
}
/*********************** V.I.P Custom Weapons **********************
*
* Credits:
* ConnorMcLeod for cstrike_pdatas and "Nosil" plugin
* SISA for help
* AlejandroSk for plugin "Golden Ak-47"
*********************************************************************/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "V.I.P Custom M4A1" // don't change this!
#define PLUGIN_VERSION "1.0.0" // version for "V.I.P Custom Weapons"
#define PLUGIN_AUTHOR "Vaqtincha"
#define get_weapon_owner(%1) get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
#define fm_get_user_money(%1) get_pdata_int(%1, m_iAccount, XO_PLAYER)
#define get_weapon_state(%1) get_pdata_int(%1, m_fWeaponState, XO_WEAPON)
#if AMXX_VERSION_NUM < 183
#define HasShield(%1) (get_pdata_int(%1, m_iUserPrefs, XO_PLAYER) & m_bHasShield)
#else
#define HasShield(%1) get_pdata_bool(%1, m_bHasShield)
#endif
#define IsPlayer(%1) ( 1 <= (%1) <= giMaxPlayers )
#define MAX_PLAYERS 32
/*-----------------------------------------------------------------*/
#define WP 9147
// #define NOSIL_SUPPORT
new const weapon_name[] = "weapon_m4a1"
new const ammo_type[] = "556nato"
new const max_bpammo[] = 90
new const buy_cmd[] = "say /m4"
new const weapon_id = CSW_M4A1
new const V_MODEL[] = "models/custom/v_m4a1.mdl" // view weapon model
new const P_MODEL[] = "models/custom/p_m4a1.mdl" // player weapon model
new const W_MODEL[] = "models/custom/w_m4a1.mdl" // world weapon model
new const W_DEF_MODEL[] = "models/w_m4a1.mdl" // default world model
#if defined NOSIL_SUPPORT
new P_MODEL_NOSIL[] = "models/custom/p_m4a1_nosil.mdl"// player weapon nosil model
new W_MODEL_NOSIL[] = "models/custom/w_m4a1_nosil.mdl"// world weapon nosil model
#endif
/*-----------------------------------------------------------------*/
static buyaccess
new weapcost, droptype, alw_round_buy, accuracy_fix
new Float:damage, inbuyzone, buytime
new Float:g_GameTime
new bool:g_HasWeap[MAX_PLAYERS + 1] = false
new bool:g_buyzone[MAX_PLAYERS + 1]
new giCounter, giMaxPlayers
const PRIMARY_WEAPONS_BIT_SUM = 1<<CSW_SCOUT|1<<CSW_XM1014|1<<CSW_MAC10|1<<CSW_AUG|1<<CSW_UMP45
|1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_MP5NAVY|1<<CSW_M249|1<<CSW_M3
|1<<CSW_M4A1|1<<CSW_TMP|1<<CSW_G3SG1|1<<CSW_SG552|1<<CSW_AK47|1<<CSW_P90
const SECONDARY_WEAPONS_BIT_SUM = 1<<CSW_P228|1<<CSW_ELITE|1<<CSW_FIVESEVEN|1<<CSW_USP|1<<CSW_GLOCK18|1<<CSW_DEAGLE
// Offsets
#if AMXX_VERSION_NUM < 183
const m_bHasShield = 1<<24
const m_iUserPrefs = 510
#else
const m_bHasShield = 2043
#endif
const m_flAccuracy = 62
const m_pPlayer = 41
const XO_PLAYER = 5
const XO_WEAPON = 4
const m_pActiveItem = 373
// const m_rgpPlayerItems_wpnbx_slot2 = 36 // secondary weapon slot
const m_rgpPlayerItems_wpnbx_slot1 = 35 // primary weapon slot
#if defined NOSIL_SUPPORT
const m_fWeaponState = 74
const WEAPONSTATE_M4A1_SILENCED = 1<<2
#endif
#if cellbits == 32
const m_iAccount = 115
#else
const m_iAccount = 140
#endif
public plugin_init()
{
new mapname[4]
get_mapname(mapname, charsmax(mapname))
if(equali(mapname, "de_") || equali(mapname, "cs_"))
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_dictionary ( "vip_custom.txt" )
loadconfig()
giMaxPlayers = get_maxplayers()
register_clcmd( buy_cmd, "buyCMD") // don't change this!
if(inbuyzone) register_event("StatusIcon", "event_buyzone_icon", "b", "2=buyzone")
// Events
register_event( "TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event("DeathMsg", "Death", "a")
register_forward(FM_SetModel, "fw_SetModel")
RegisterHam(Ham_Item_Deploy, weapon_name, "fw_ItemDeploy_Weap_Post", 1)
RegisterHam(Ham_Item_AttachToPlayer, weapon_name, "fw_Item_AttachToPlayer_Pre", 0)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Pre", 0)
if(accuracy_fix) RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Pre", 0)
#if defined NOSIL_SUPPORT
RegisterHam(Ham_Weapon_SecondaryAttack, weapon_name, "fw_Weapon_SecondaryAttack_Post" ,1)
#endif
}
else
pause("a")
}
public loadconfig()
{
new ConfigFile[64], szMsg[128] // "addons/amxmodx/configs/vip_custom.ini" 37
get_localinfo("amxx_configsdir", ConfigFile, charsmax(ConfigFile))
add(ConfigFile, charsmax(ConfigFile), "/vip_custom.ini")
if( !file_exists(ConfigFile) )
{
formatex( szMsg, charsmax(szMsg), "%s Config File Not Found!", PLUGIN_NAME )
set_fail_state(szMsg)
return
}
new fp = fopen(ConfigFile, "rt")
if( fp )
{
new Datas[86], Setting[24], Value[15]
while( !feof(fp) )
{
fgets(fp, Datas, charsmax(Datas))
trim(Datas)
if(!Datas[0] || Datas[0] == ';' || Datas[0] == '#' || Datas[0] == '/'|| Datas[0] == '[')
{
continue
}
new Sign[3]
parse(Datas, Setting, charsmax(Setting), Sign, charsmax(Sign), Value, charsmax(Value))
if( equali(Setting, "buy_access")){
buyaccess = read_flags(Value)
}else if( equali(Setting, "drop_type")){
droptype = str_to_num(Value)
}else if( equali(Setting, "allowed_round_buymenu")){
alw_round_buy = str_to_num(Value)
}else if( equali(Setting, "buyzone_check")){
inbuyzone = str_to_num(Value) ? true : false
}else if( equali(Setting, "buytime_check")){
buytime = str_to_num(Value) ? true : false
}else if( equali(Setting, "m4a1_cost")){
weapcost = str_to_num(Value)
}else if( equali(Setting, "m4a1_damage")){
damage = str_to_float(Value)
}else if( equali(Setting, "m4a1_accuracy_fix")){
accuracy_fix = str_to_num(Value) ? true : false
}
}
formatex( szMsg, charsmax(szMsg), "%s Config Successfully Loaded!", PLUGIN_NAME )
server_print(szMsg)
}
}
public plugin_precache()
{
precache_model(V_MODEL)
precache_model(P_MODEL)
precache_model(W_MODEL)
#if defined NOSIL_SUPPORT
precache_model(P_MODEL_NOSIL)
precache_model(W_MODEL_NOSIL)
#endif
}
public event_buyzone_icon(id)
{
g_buyzone[id] = bool:read_data(1)
}
public client_putinserver(id)
{
g_HasWeap[id] = false
}
public client_disconnect(id)
{
g_HasWeap[id] = false
if(inbuyzone)
{
g_buyzone[id] = false
}
}
public Event_NewGame()
{
giCounter = 0
new iPlayers[32], iNum
get_players(iPlayers, iNum )
for ( --iNum; iNum >= 0; --iNum )
{
g_HasWeap[iPlayers[iNum]] = false
}
}
public Event_NewRound()
{
giCounter++
if(buytime)
{
g_GameTime = get_gametime()
}
}
public Death()
{
g_HasWeap[read_data(2)] = false
}
public buyCMD(id)
{
if(!is_user_alive(id))
{
client_print(id, print_center, "%L", LANG_SERVER,"ONLY_ALIVE")
return PLUGIN_HANDLED
}
// Check if the player is in the buyzone
if(inbuyzone)
{
if(!g_buyzone[id])
{
client_print(id, print_center, "%L", LANG_SERVER,"OUTSIDE_BUYZONE")
return PLUGIN_HANDLED
}
}
// Check buying time
if(buytime)
{
new Float:buytime = get_cvar_float("mp_buytime") * 60.0
new Float:timepassed = get_gametime() - g_GameTime
if(floatcmp(timepassed , buytime) == 1)
{
client_print(id, print_center, "%L", LANG_SERVER,"SECONDS_HAVE_PASSED",buytime)
return PLUGIN_HANDLED
}
}
if(giCounter < alw_round_buy)
{
client_print(id, print_center, "%L", LANG_SERVER,"NOT_AVAILABLE")
return PLUGIN_HANDLED
}
if(!(get_user_flags(id) & buyaccess ))
{
client_print(id, print_center, "%L", LANG_SERVER,"NO_ACC_CMD")
return PLUGIN_HANDLED
}
if(fm_get_user_money(id) < weapcost )
{
client_print(id, print_center, "%L", LANG_SERVER,"INSUFFICIENT_FUNDS")
return PLUGIN_HANDLED
}
else{
fm_set_user_money(id, fm_get_user_money(id) - weapcost , 1)
GiveWeapon(id)
}
return PLUGIN_CONTINUE
}
public GiveWeapon(id)
{
drop_weapons(id, 1)
g_HasWeap[id] = true
fm_give_item(id, weapon_name)
ExecuteHamB(Ham_GiveAmmo, id, max_bpammo, ammo_type, max_bpammo)
engclient_cmd(id, weapon_name)
}
public fw_ItemDeploy_Weap_Post(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pev(iPlayer, pev_viewmodel2, V_MODEL)
#if defined NOSIL_SUPPORT
if( ~get_weapon_state(ent) & WEAPONSTATE_M4A1_SILENCED)
{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL_NOSIL)
}
else{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
}
#else
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
#endif
}
return HAM_IGNORED
}
#if defined NOSIL_SUPPORT
public fw_Weapon_SecondaryAttack_Post(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
if( ~get_weapon_state(ent) & WEAPONSTATE_M4A1_SILENCED)
{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL_NOSIL)
}
else{
set_pev(iPlayer, pev_weaponmodel2, P_MODEL)
}
}
}
#endif
public fw_Weapon_PrimaryAttack_Pre(ent)
{
new iPlayer = get_weapon_owner(ent)
if(iPlayer > 0 && g_HasWeap[iPlayer])
{
set_pdata_float(ent, m_flAccuracy, 0.0, XO_WEAPON)
}
}
public fw_Item_AttachToPlayer_Pre(ent, id)
{
if ( pev (ent, pev_impulse)==WP)
g_HasWeap[id] = true
if( get_pdata_cbase(id, m_pActiveItem) != ent)
{
return HAM_IGNORED
}
fw_ItemDeploy_Weap_Post(ent)
return HAM_IGNORED
}
public fw_SetModel(ent, model[])
{
new id = pev (ent, pev_owner)
if( pev_valid(ent))
{
if( equal(model, W_DEF_MODEL))
{
new weapon = get_pdata_cbase(ent, m_rgpPlayerItems_wpnbx_slot1, XO_WEAPON)
if(weapon > 0 && pev(weapon, pev_impulse)==WP)
{
#if defined NOSIL_SUPPORT
if( ~get_weapon_state(weapon) & WEAPONSTATE_M4A1_SILENCED)
{
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL_NOSIL)
return FMRES_SUPERCEDE
}else{
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL)
return FMRES_SUPERCEDE
}
#else
g_HasWeap[id] = false
engfunc(EngFunc_SetModel, ent, W_MODEL)
return FMRES_SUPERCEDE
#endif
}
}
}
return FMRES_IGNORED
}
public fw_TakeDamage_Pre(victim, inflictor, attacker, Float:fdamage, damage_bits)
{
if(!(damage_bits & DMG_BULLET)||!IsPlayer(attacker)|| get_user_weapon(attacker) != weapon_id)
return HAM_IGNORED
if(g_HasWeap[attacker] && attacker == inflictor )
{
SetHamParamFloat(4, fdamage * damage)
return HAM_HANDLED
}
return HAM_IGNORED
}
//================================ STOCKS ==============================//
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons
if((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM || HasShield(id)))
|| (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
switch(droptype)
{
case 0: ham_strip_weapon(id, wname)
case 1: engclient_cmd(id, "drop", wname)
}
}
}
}
stock fm_give_item(index, const item[])
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
return 0
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent))
return 0
new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
set_pev(ent, pev_impulse, WP)
dllfunc(DLLFunc_Spawn, ent)
new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent
engfunc(EngFunc_RemoveEntity, ent)
return -1
}
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0
new wId = get_weaponid(weapon)
if(!wId) return 0
new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
if(!wEnt) return 0
new iTmp
if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt)
if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0
ExecuteHamB(Ham_Item_Kill, wEnt)
set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))
return 1
}
stock fm_set_user_money(client, money, flash=1)
{
set_pdata_int(client, m_iAccount, money, XO_PLAYER)
static Money
if( Money || (Money = get_user_msgid("Money")) )
{
emessage_begin(MSG_ONE_UNRELIABLE, Money, _, client)
ewrite_long(money)
ewrite_byte(flash ? 1 : 0)
emessage_end()
}
}
Помогите пожалуйста.