Senior Member
|
03-24-2013
, 11:53
Anti Furien Weapon menu
|
#1
|
PHP Code:
/****************************************************************************\
==============================
= Anti-Furien Weapons =
==============================
---------------------
- Description -
---------------------
This menu include all primary and secondary weapons of CS
** Choose Weapons
** Last Weapons choosen
** Last Weapons choosen + save
----------------------
- Requirements -
----------------------
** AMXX: Version 1.8.1
** AMXX Modules: Cstrike, Fun and Hamsandwich modules
----------------------
- Installation -
----------------------
1- Download and compile the plugin from:
2- Upload the amxx file to your server (cstrike>addons>amxmodx>plugins).
3- Edit the config file and add the plugin (cstrike>addons>amxmodx>configs>plugins.ini).
----------------------
- Contact Info -
----------------------
For reporting bugs or post your feedback visit:
http://forums.alliedmods.net/showthread.php?p=1757094
If you want some private job pm me on alliedmodders forum's or send me and email to:
[email protected]
-----------------
- Credits -
-----------------
** Freestyle
- Main/Inicial Code
------------------
- Updates Logs -
------------------
** v1.0 [Jul 2012]
- Added Original Options.
\************************************************************************************/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include "furien.inc"
#define PLUGIN "Anti-Furien Weapons"
#define VERSION "1.0"
#define AUTHOR "Freestyle"
// Weapons Stuff
#define PISTOL_WEAPONS_BIT (1<<CSW_GLOCK18|1<<CSW_USP|1<<CSW_DEAGLE|)
#define SHOTGUN_WEAPONS_BIT (1<<CSW_M3|1<<CSW_XM1014)
#define SUBMACHINE_WEAPONS_BIT (1<<CSW_MP5NAVY)
#define RIFLE_WEAPONS_BIT (1<<CSW_AK47|1<<CSW_M4A1)
#define MACHINE_WEAPONS_BIT (1<<CSW_M249)
#define PRIMARY_WEAPONS_BIT (SHOTGUN_WEAPONS_BIT|SUBMACHINE_WEAPONS_BIT|RIFLE_WEAPONS_BIT|MACHINE_WEAPONS_BIT)
#define SECONDARY_WEAPONS_BIT (PISTOL_WEAPONS_BIT)
#define IsPrimaryWeapon(%1) ( (1<<%1) & PRIMARY_WEAPONS_BIT )
#define IsSecondaryWeapon(%1) ( (1<<%1) & PISTOL_WEAPONS_BIT )
#define MIN_WEAPON CSW_P228
#define MAX_WEAPON CSW_P90
new const g_iMaxBPAmmo[ MAX_WEAPON + 1 ] =
{
0, 52, 0, 90, 1, 32, 0, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120, 30,
120, 200, 32, 90, 120, 90, 2, 35, 90, 90, 0, 100
}
new const g_szWeaponClassnames[ MAX_WEAPON + 1 ][ ] =
{
"", "weapon_hegrenade",
"weapon_xm1014", "weapon_c4",
"weapon_smokegrenade",
"weapon_usp", "weapon_glock18", "weapon_mp5navy",
"weapon_m3", "weapon_m4a1",
"weapon_flashbang", "weapon_deagle",
"weapon_knife"
}
new const g_szWeaponNames[ MAX_WEAPON + 1 ][ ] =
{
"", "", "XM1014 (Auto-Shotgun)", "",
"", "USP", "Glock-18", "MP5-Navy",
"M3 (Pump-Shotgun)", "M4A1", "", "Deagle",
""
}
new g_hWeaponMenu
new g_hPrimaryWeaponMenu
new g_hSecondaryWeaponMenu
new bool:g_bRememberGuns[ 33 ]
new g_iPrimaryWeapon[ 33 ];
new g_iSecondaryWeapon[ 33 ];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "player", "Ham_CBasePlayer_Spawn_Post", 1)
register_clcmd( "say /guns", "CmdGunsEnable" );
}
public Ham_CBasePlayer_Spawn_Post( id )
{
if( is_user_alive(id) )
{
if( furien_get_user_team(id) == AntiFurien )
{
if( g_bRememberGuns[ id ] )
GiveWeapons( id );
else if( g_iPrimaryWeapon[ id ] == 0 || g_iSecondaryWeapon[ id ] == 0 )
{
menu_display( id, g_hPrimaryWeaponMenu );
}
else menu_display( id, g_hWeaponMenu );
}
}
}
public CmdEnableGuns( id )
{
if( g_bRememberGuns[ id ] )
{
client_print(id, print_chat, "Your Anti-Furien WeaponsMenu it's now activate." );
g_bRememberGuns[ id ] = false;
}
else
client_print(id, print_chat, "Your Anti-Furien WeaponsMenu it's already activate." );
}
public client_putinserver( id )
{
g_bRememberGuns[ id ] = false;
g_iPrimaryWeapon[ id ] = 0;
g_iSecondaryWeapon[ id ] = 0;
}
public GunsMenu()
{
g_hWeaponMenu = menu_create( "\rWeapons Menu\w", "WeaponMainMenu_Handler" );
menu_additem( g_hWeaponMenu, "New Weapons", "0" );
menu_additem( g_hWeaponMenu, "Last Weapons", "1" );
menu_additem( g_hWeaponMenu, "2 + Dont ask again", "2" );
g_hPrimaryWeaponMenu = menu_create( "\rWeapons Menu^n\yChoose your Primary Weapon:\w", "PrimaryWeapons_Handler" );
g_hSecondaryWeaponMenu = menu_create( "\rWeapons Menu^n\yChoose your Secondary Weapon:\w", "SecondaryWeapons_Handler" );
new szInfo[ 3 ];
for( new i = MIN_WEAPON; i <= MAX_WEAPON; i++ )
{
if( IsPrimaryWeapon( i ) )
{
num_to_str( i, szInfo, charsmax( szInfo ) );
menu_additem( g_hPrimaryWeaponMenu, g_szWeaponNames[ i ], szInfo );
}
else if( IsSecondaryWeapon( i ) )
{
num_to_str( i, szInfo, charsmax( szInfo ) );
menu_additem( g_hSecondaryWeaponMenu, g_szWeaponNames[ i ], szInfo );
}
else continue;
}
}
public WeaponMainMenu_Handler( id, hMenu, iItem )
{
switch( iItem )
{
case 0: menu_display( id, g_hPrimaryWeaponMenu, 0 );
case 1:
{
GiveWeapons( id );
}
case 2:
{
GiveWeapons( id );
g_bRememberGuns[ id ] = true;
client_print(id, print_chat, "Weapons choice has been save, for this menu open again type in chat /guns" );
}
}
}
public PrimaryWeapons_Handler( id, hMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy(hMenu);
return PLUGIN_HANDLED;
}
new iAccess, hCallback;
new szData[ 6 ];
menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), _, _, hCallback );
g_iPrimaryWeapon[ id ] = str_to_num( szData );
menu_display( id, g_hSecondaryWeaponMenu, 0 );
return PLUGIN_HANDLED;
}
public SecondaryWeapons_Handler( id, hMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy(hMenu);
return PLUGIN_HANDLED;
}
new iAccess, hCallback;
new szData[ 6 ];
menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), _, _, hCallback );
g_iSecondaryWeapon[ id ] = str_to_num( szData );
GiveWeapons( id );
return PLUGIN_HANDLED;
}
GiveWeapons( id )
{
new iPrimary = g_iPrimaryWeapon[ id ];
new iSecondary = g_iSecondaryWeapon[ id ];
give_item( id, g_szWeaponClassnames[ iPrimary ] );
give_item( id, g_szWeaponClassnames[ iSecondary ] );
cs_set_user_bpammo( id, iPrimary, g_iMaxBPAmmo[ iPrimary ] );
cs_set_user_bpammo( id, iSecondary, g_iMaxBPAmmo[ iSecondary ] );
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2070\\ f0\\ fs16 \n\\ par }
*/
What it's wrong on this plugin?I tried to delete some gun but doesn't work.
This is the original .sma:
PHP Code:
/****************************************************************************\
==============================
= Anti-Furien Weapons =
==============================
---------------------
- Description -
---------------------
This menu include all primary and secondary weapons of CS
** Choose Weapons
** Last Weapons choosen
** Last Weapons choosen + save
----------------------
- Requirements -
----------------------
** AMXX: Version 1.8.1
** AMXX Modules: Cstrike, Fun and Hamsandwich modules
----------------------
- Installation -
----------------------
1- Download and compile the plugin from:
2- Upload the amxx file to your server (cstrike>addons>amxmodx>plugins).
3- Edit the config file and add the plugin (cstrike>addons>amxmodx>configs>plugins.ini).
----------------------
- Contact Info -
----------------------
For reporting bugs or post your feedback visit:
http://forums.alliedmods.net/showthread.php?p=1757094
If you want some private job pm me on alliedmodders forum's or send me and email to:
[email protected]
-----------------
- Credits -
-----------------
** Freestyle
- Main/Inicial Code
------------------
- Updates Logs -
------------------
** v1.0 [Jul 2012]
- Added Original Options.
\************************************************************************************/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include "furien.inc"
#define PLUGIN "Anti-Furien Weapons"
#define VERSION "1.0"
#define AUTHOR "Freestyle"
// Weapons Stuff
#define PISTOL_WEAPONS_BIT (1<<CSW_GLOCK18|1<<CSW_USP|1<<CSW_DEAGLE|1<<CSW_P228|1<<CSW_FIVESEVEN|1<<CSW_ELITE)
#define SHOTGUN_WEAPONS_BIT (1<<CSW_M3|1<<CSW_XM1014)
#define SUBMACHINE_WEAPONS_BIT (1<<CSW_TMP|1<<CSW_MAC10|1<<CSW_MP5NAVY|1<<CSW_UMP45|1<<CSW_P90)
#define RIFLE_WEAPONS_BIT (1<<CSW_FAMAS|1<<CSW_GALIL|1<<CSW_AK47|1<<CSW_SCOUT|1<<CSW_M4A1|1<<CSW_SG550|1<<CSW_SG552|1<<CSW_AUG|1<<CSW_AWP|1<<CSW_G3SG1)
#define MACHINE_WEAPONS_BIT (1<<CSW_M249)
#define PRIMARY_WEAPONS_BIT (SHOTGUN_WEAPONS_BIT|SUBMACHINE_WEAPONS_BIT|RIFLE_WEAPONS_BIT|MACHINE_WEAPONS_BIT)
#define SECONDARY_WEAPONS_BIT (PISTOL_WEAPONS_BIT)
#define IsPrimaryWeapon(%1) ( (1<<%1) & PRIMARY_WEAPONS_BIT )
#define IsSecondaryWeapon(%1) ( (1<<%1) & PISTOL_WEAPONS_BIT )
#define MIN_WEAPON CSW_P228
#define MAX_WEAPON CSW_P90
new const g_iMaxBPAmmo[ MAX_WEAPON + 1 ] =
{
0, 52, 0, 90, 1, 32, 0, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120, 30,
120, 200, 32, 90, 120, 90, 2, 35, 90, 90, 0, 100
}
new const g_szWeaponClassnames[ MAX_WEAPON + 1 ][ ] =
{
"", "weapon_p228", "", "weapon_scout", "weapon_hegrenade",
"weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug",
"weapon_smokegrenade", "weapon_elite", "weapon_fiveseven",
"weapon_ump45", "weapon_sg550", "weapon_galil", "weapon_famas",
"weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy",
"weapon_m249", "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1",
"weapon_flashbang", "weapon_deagle", "weapon_sg552", "weapon_ak47",
"weapon_knife", "weapon_p90"
}
new const g_szWeaponNames[ MAX_WEAPON + 1 ][ ] =
{
"", "P228", "", "Schmidt Scout", "", "XM1014 (Auto-Shotgun)", "",
"Mac-10", "AUG", "", "Dual Elites", "Five-Seven", "UMP-45", "SG-550",
"Galil", "Famas", "USP", "Glock-18", "AWP", "MP5-Navy", "M249 (Para)",
"M3 (Pump-Shotgun)", "M4A1", "TMP", "G3SG1", "", "Deagle", "SG-552",
"AK-47", "", "P90"
}
new g_hWeaponMenu
new g_hPrimaryWeaponMenu
new g_hSecondaryWeaponMenu
new bool:g_bRememberGuns[ 33 ]
new g_iPrimaryWeapon[ 33 ];
new g_iSecondaryWeapon[ 33 ];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "player", "Ham_CBasePlayer_Spawn_Post", 1)
register_clcmd( "say /guns", "CmdGunsEnable" );
}
public Ham_CBasePlayer_Spawn_Post( id )
{
if( is_user_alive(id) )
{
if( furien_get_user_team(id) == AntiFurien )
{
if( g_bRememberGuns[ id ] )
GiveWeapons( id );
else if( g_iPrimaryWeapon[ id ] == 0 || g_iSecondaryWeapon[ id ] == 0 )
{
menu_display( id, g_hPrimaryWeaponMenu );
}
else menu_display( id, g_hWeaponMenu );
}
}
}
public CmdEnableGuns( id )
{
if( g_bRememberGuns[ id ] )
{
client_print(id, print_chat, "Your Anti-Furien WeaponsMenu it's now activate." );
g_bRememberGuns[ id ] = false;
}
else
client_print(id, print_chat, "Your Anti-Furien WeaponsMenu it's already activate." );
}
public client_putinserver( id )
{
g_bRememberGuns[ id ] = false;
g_iPrimaryWeapon[ id ] = 0;
g_iSecondaryWeapon[ id ] = 0;
}
public GunsMenu()
{
g_hWeaponMenu = menu_create( "\rWeapons Menu\w", "WeaponMainMenu_Handler" );
menu_additem( g_hWeaponMenu, "New Weapons", "0" );
menu_additem( g_hWeaponMenu, "Last Weapons", "1" );
menu_additem( g_hWeaponMenu, "2 + Dont ask again", "2" );
g_hPrimaryWeaponMenu = menu_create( "\rWeapons Menu^n\yChoose your Primary Weapon:\w", "PrimaryWeapons_Handler" );
g_hSecondaryWeaponMenu = menu_create( "\rWeapons Menu^n\yChoose your Secondary Weapon:\w", "SecondaryWeapons_Handler" );
new szInfo[ 3 ];
for( new i = MIN_WEAPON; i <= MAX_WEAPON; i++ )
{
if( IsPrimaryWeapon( i ) )
{
num_to_str( i, szInfo, charsmax( szInfo ) );
menu_additem( g_hPrimaryWeaponMenu, g_szWeaponNames[ i ], szInfo );
}
else if( IsSecondaryWeapon( i ) )
{
num_to_str( i, szInfo, charsmax( szInfo ) );
menu_additem( g_hSecondaryWeaponMenu, g_szWeaponNames[ i ], szInfo );
}
else continue;
}
}
public WeaponMainMenu_Handler( id, hMenu, iItem )
{
switch( iItem )
{
case 0: menu_display( id, g_hPrimaryWeaponMenu, 0 );
case 1:
{
GiveWeapons( id );
}
case 2:
{
GiveWeapons( id );
g_bRememberGuns[ id ] = true;
client_print(id, print_chat, "Weapons choice has been save, for this menu open again type in chat /guns" );
}
}
}
public PrimaryWeapons_Handler( id, hMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy(hMenu);
return PLUGIN_HANDLED;
}
new iAccess, hCallback;
new szData[ 6 ];
menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), _, _, hCallback );
g_iPrimaryWeapon[ id ] = str_to_num( szData );
menu_display( id, g_hSecondaryWeaponMenu, 0 );
return PLUGIN_HANDLED;
}
public SecondaryWeapons_Handler( id, hMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy(hMenu);
return PLUGIN_HANDLED;
}
new iAccess, hCallback;
new szData[ 6 ];
menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), _, _, hCallback );
g_iSecondaryWeapon[ id ] = str_to_num( szData );
GiveWeapons( id );
return PLUGIN_HANDLED;
}
GiveWeapons( id )
{
new iPrimary = g_iPrimaryWeapon[ id ];
new iSecondary = g_iSecondaryWeapon[ id ];
give_item( id, g_szWeaponClassnames[ iPrimary ] );
give_item( id, g_szWeaponClassnames[ iSecondary ] );
cs_set_user_bpammo( id, iPrimary, g_iMaxBPAmmo[ iPrimary ] );
cs_set_user_bpammo( id, iSecondary, g_iMaxBPAmmo[ iSecondary ] );
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2070\\ f0\\ fs16 \n\\ par }
*/
But i want to keep in menu just Golck,USP,DEAGLE,MP5,M3,XM1014,AK47 and M4A1.
Also...how can I add in shop "Buy 50 health" ?
PHP Code:
/* Formatright © 2010, ConnorMcLeod
Furien Shop is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Furien Shop; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <cstrike>
#include "furien.inc"
#include "furien_shop.inc"
new const szPickAmmoSound[] = "items/9mmclip1.wav"
enum _:ItemDatas
{
m_szItemName[32],
m_iItemCost,
m_iItemForwardIndex,
m_iItemExtraArg
}
enum ( <<= 1 )
{
ShouldBeInBuyZone = 1,
ShouldBeInBuyTime
}
#define HUD_PRINTCENTER 4
new g_iBlinkAcct, g_iTextMsg
new g_iBuyType, g_pCvarBuyTime
new Array:g_aItems[2]
new g_iMenuId[2] = {-1, -1}
new bool:g_bFreezeTime = true, bool:g_bBuyTime = true
new bool:g_bSwitchTime
new Float:g_flRoundStartGameTime
public plugin_init()
{
register_plugin("Furien Shop", FURIEN_VERSION, "ConnorMcLeod")
register_dictionary("common.txt")
new pCvar = register_cvar("furien_shop_version", FURIEN_VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
set_pcvar_string(pCvar, FURIEN_VERSION)
ReadCfgFile()
if( g_iBuyType & ShouldBeInBuyZone )
{
register_event("StatusIcon", "Event_StatusIcon_OutOfBuyZone", "b", "1=0", "2=buyzone")
}
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
register_logevent("LogEvent_Round_Start", 2, "1=Round_Start")
register_clcmd("shop", "ClientCommand_Shop")
register_clcmd("say shop", "ClientCommand_Shop")
register_clcmd("say_team shop", "ClientCommand_Shop")
register_clcmd("buy", "ClientCommand_Shop")
g_iBlinkAcct = get_user_msgid("BlinkAcct")
g_iTextMsg = get_user_msgid("TextMsg")
g_pCvarBuyTime = get_cvar_pointer("mp_buytime")
}
ReadCfgFile()
{
new szConfigFile[128]
get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
format(szConfigFile, charsmax(szConfigFile), "%s/furien/shop.ini", szConfigFile);
new fp = fopen(szConfigFile, "rt")
if( !fp )
{
return
}
new szDatas[32], szKey[16], szValue[16]
while( !feof(fp) )
{
fgets(fp, szDatas, charsmax(szDatas))
trim(szDatas)
if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#' || (szDatas[0] == '/' && szDatas[1] == '/'))
{
continue
}
parse(szDatas, szKey, charsmax(szKey), szValue, charsmax(szValue))
switch( szKey[0] )
{
case 'B':
{
if( equal(szKey, "BUY_TYPE" ) )
{
g_iBuyType = str_to_num(szValue)
}
}
}
}
fclose( fp )
}
public plugin_precache()
{
precache_sound(szPickAmmoSound)
}
public Event_HLTV_New_Round()
{
g_bFreezeTime = true
g_bBuyTime = true
g_bSwitchTime = false
}
public LogEvent_Round_Start()
{
g_bFreezeTime = false
g_bBuyTime = true
g_bSwitchTime = false
g_flRoundStartGameTime = get_gametime()
}
bool:bIsBuyTime( id = 0 )
{
new Float:flBuyTime
if( !g_bFreezeTime
&& ( !g_bBuyTime || !(g_bBuyTime = get_gametime() < g_flRoundStartGameTime + (flBuyTime = get_buytime_value() * 60.0)) ) )
{
if( id )
{
new szBuyTime[3]
float_to_str(flBuyTime, szBuyTime, charsmax(szBuyTime))
Util_ClientPrint(id, HUD_PRINTCENTER, "#Cant_buy", szBuyTime)
}
return false
}
return true
}
Float:get_buytime_value()
{
new Float:flBuyTime = get_pcvar_float(g_pCvarBuyTime)
if( flBuyTime < 0.25 )
{
set_pcvar_float(g_pCvarBuyTime, 0.25)
flBuyTime = 0.25
}
if( flBuyTime > 1.5 )
{
set_pcvar_float(g_pCvarBuyTime, 1.5)
flBuyTime = 1.5
}
return flBuyTime
}
public furien_team_change()
{
g_bSwitchTime = true
new iPlayers[32], iNum
get_players(iPlayers, iNum, "a")
for(new i; i<iNum; i++)
{
CheckMenuClose(iPlayers[i])
}
}
public Event_StatusIcon_OutOfBuyZone( id )
{
CheckMenuClose(id)
}
CheckMenuClose(id)
{
new iCrap, iMenuId
player_menu_info(id, iCrap, iMenuId)
if( iMenuId > -1 && (iMenuId == g_iMenuId[Furien] || iMenuId == g_iMenuId[AntiFurien]) )
{
menu_cancel(id)
}
}
public plugin_natives()
{
register_library("furien_shop")
register_native("furien_register_item", "fr_register_item")
}
public fr_register_item(iPlugin)
{
new mDatas[ItemDatas], szCallBack[32]
get_string(5, szCallBack, charsmax(szCallBack))
mDatas[m_iItemForwardIndex] = CreateOneForward(iPlugin, szCallBack, FP_CELL, FP_CELL)
mDatas[m_iItemExtraArg] = get_param(6)
if( (mDatas[m_iItemCost] = get_param(2)) > 0 )
{
get_string(1, mDatas[m_szItemName], charsmax(mDatas[m_szItemName]))
AddItemToMenu( Furien , mDatas )
}
if( (mDatas[m_iItemCost] = get_param(4)) > 0 )
{
get_string(3, mDatas[m_szItemName], charsmax(mDatas[m_szItemName]))
AddItemToMenu( AntiFurien , mDatas )
}
return mDatas[m_iItemForwardIndex]
}
AddItemToMenu( iTeam , mDatas[ItemDatas] )
{
new Array:iArray = g_aItems[iTeam]
if( iArray == Invalid_Array )
{
iArray = g_aItems[iTeam] = ArrayCreate(ItemDatas)
}
new iMenu = g_iMenuId[iTeam]
if( iMenu == -1 )
{
new szMenuNames[][] = {"Furien Shop", "AntiFurien Shop"}
new szHandlers[][] = {"FurienMenuHandler", "AntiMenuHandler"}
iMenu = g_iMenuId[iTeam] = menu_create(szMenuNames[iTeam], szHandlers[iTeam])
menu_setprop(iMenu, MPROP_NUMBER_COLOR, "\y")
}
ArrayPushArray(iArray, mDatas)
new szItemInformation[64]
formatex(szItemInformation, charsmax(szItemInformation), "%s\R\y$%d", mDatas[m_szItemName], mDatas[m_iItemCost])
menu_additem(iMenu, szItemInformation)
}
public ClientCommand_Shop( id )
{
if( !g_bSwitchTime && is_user_alive(id) )
{
if( !bCanBuy( id ) )
{
return PLUGIN_HANDLED_MAIN
}
ShowShopMenu(id)
return PLUGIN_CONTINUE
}
return PLUGIN_HANDLED_MAIN
}
bCanBuy( id )
{
if( ( g_iBuyType & ShouldBeInBuyZone && !cs_get_user_buyzone(id) )
|| ( g_iBuyType & ShouldBeInBuyTime && !bIsBuyTime(id) ) )
{
return false
}
return true
}
ShowShopMenu(id)
{
new iTeam = furien_get_user_team(id)
menu_display(id, g_iMenuId[iTeam])
}
public FurienMenuHandler(id, iMenu, iItem)
{
if( iItem > MENU_MORE && is_user_alive(id) && furien_get_user_team(id) == Furien && bCanBuy( id ) )
{
new mDatas[ItemDatas]
ArrayGetArray(Array:g_aItems[Furien], iItem, mDatas)
Function(mDatas, id)
}
}
public AntiMenuHandler(id, iMenu, iItem)
{
if( iItem > MENU_MORE && is_user_alive(id) && furien_get_user_team(id) == AntiFurien && bCanBuy( id ) )
{
new mDatas[ItemDatas]
ArrayGetArray(Array:g_aItems[AntiFurien], iItem, mDatas)
Function(mDatas, id)
}
}
Function(mDatas[ItemDatas], id)
{
new iRet
ExecuteForward(mDatas[m_iItemForwardIndex], iRet, id, mDatas[m_iItemExtraArg])
switch( iRet )
{
case ShopBought:
{
emit_sound(id, CHAN_ITEM, szPickAmmoSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
return 1
}
case ShopTeamNotAvail:
{
Util_ClientPrint
(
id,
HUD_PRINTCENTER,
"#Alias_Not_Avail",
mDatas[ m_szItemName ]
)
}
case ShopNotEnoughMoney:
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Not_Enough_Money")
message_begin(MSG_ONE_UNRELIABLE, g_iBlinkAcct, .player=id)
{
write_byte(2)
}
message_end()
}
case ShopAlreadyHaveOne:
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Already_Have_One")
}
case ShopCantCarryAnymore:
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Carry_Anymore")
}
case ShopCannotBuyThis:
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Buy_This")
}
case ShopCloseMenu:
{
return 1
}
}
return 0
}
// Only submessage1 is used but fully implemented for example.
// Based on HLSDK ClientPrint and UTIL_ClientPrintAll from util.cpp
Util_ClientPrint(id, iMsgDest, szMessage[], szSubMessage1[] = "", szSubMessage2[] = "", szSubMessage3[] = "", szSubMessage4[] = "")
{
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iTextMsg, .player=id)
{
write_byte(iMsgDest)
write_string(szMessage)
if( szSubMessage1[0] )
{
write_string(szSubMessage1)
}
if( szSubMessage2[0] )
{
write_string(szSubMessage2)
}
if( szSubMessage3[0] )
{
write_string(szSubMessage3)
}
if( szSubMessage4[0] )
{
write_string(szSubMessage4)
}
}
message_end()
}
////// client_print //////
// #Cstrike_TitlesTXT_Cannot_Buy_This "You cannot buy this item!"
// #Cstrike_TitlesTXT_Cannot_Carry_Anymore "You cannot carry anymore!"
// #Cstrike_Already_Own_Weapon "You already own that weapon."
// #Cstrike_TitlesTXT_Weapon_Not_Available "This weapon is not available to you!"
// #Cstrike_TitlesTXT_Not_Enough_Money "You have insufficient funds!"
// #Cstrike_TitlesTXT_CT_cant_buy "CTs aren't allowed to buy"
// #Cstrike_TitlesTXT_Terrorist_cant_buy "Terrorists aren't allowed to buy anything on this map!"
// #Cstrike_TitlesTXT_VIP_cant_buy "You are the VIP. You can't buy anything!"
////// Util_ClientPrint ///////
// #Cstrike_TitlesTXT_Alias_Not_Avail + szWeapon "The \"%s1\"is not available for your team to buy."
// #Cstrike_TitlesTXT_Cant_buy + szSeconds "%s1 seconds have passed. You can't buy anything now!"
Ty!
|
|