Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Add starter weapons (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
etojuice authored Jan 3, 2022
1 parent 318d109 commit f843d5d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
11 changes: 8 additions & 3 deletions cstrike/addons/amxmodx/configs/csdm/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ always_open_menu = 0
; Block default spawn items (usp, glock)
block_default_items = 0

; Starter weapons for players
; Can only put weapons available from Equip Menu
starter_secondary = "weapon_deagle"
starter_primary = "weapon_ak47"

; ========== Auto Items ===========
; Format for autoitems is:
; Format for autoitems is:
; "item_name" "team" "amount|ammo"
; 0 - default amount
; all - any
Expand All @@ -122,10 +127,10 @@ weapon_knife "all" 0
; weapon_hegrenade "all" 0
; weapon_deagle "all" 0

; ========== Equip Menu ==========
; ========== Equip Menu ==========
; Format for equip menus is:
; "WeaponName" "Display Name"
; Example:
; Example:
; weapon_m4a1 "Colt M4A1 Carbine"

[secondary]
Expand Down
11 changes: 8 additions & 3 deletions cstrike/addons/amxmodx/configs/csdm/extraconfigs/_de_dust2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ always_open_menu = 0
; Block default spawn items (usp, glock)
block_default_items = 0

; Starter weapons for players
; Can only put weapons available from Equip Menu
starter_secondary = "weapon_deagle"
starter_primary = "weapon_ak47"

; ========== Auto Items ===========
; Format for autoitems is:
; Format for autoitems is:
; "item_name" "team" "amount|ammo"
; 0 - default amount
; all - any
Expand All @@ -122,10 +127,10 @@ weapon_knife "all" 0
; weapon_hegrenade "all" 0
; weapon_deagle "all" 0

; ========== Equip Menu ==========
; ========== Equip Menu ==========
; Format for equip menus is:
; "WeaponName" "Display Name"
; Example:
; Example:
; weapon_m4a1 "Colt M4A1 Carbine"

[secondary]
Expand Down
11 changes: 8 additions & 3 deletions cstrike/addons/amxmodx/configs/csdm/extraconfigs/_prefix_de.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ always_open_menu = 0
; Block default spawn items (usp, glock)
block_default_items = 0

; Starter weapons for players
; Can only put weapons available from Equip Menu
starter_secondary = "weapon_deagle"
starter_primary = "weapon_ak47"

; ========== Auto Items ===========
; Format for autoitems is:
; Format for autoitems is:
; "item_name" "team" "amount|ammo"
; 0 - default amount
; all - any
Expand All @@ -122,10 +127,10 @@ weapon_knife "all" 0
; weapon_hegrenade "all" 0
; weapon_deagle "all" 0

; ========== Equip Menu ==========
; ========== Equip Menu ==========
; Format for equip menus is:
; "WeaponName" "Display Name"
; Example:
; Example:
; weapon_m4a1 "Colt M4A1 Carbine"

[secondary]
Expand Down
36 changes: 33 additions & 3 deletions cstrike/addons/amxmodx/scripting/CSDM_ReAPI/csdm_equip_manager.sma
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum EquipMenu_s

new HookChain:g_hGiveDefaultItems, HookChain:g_hBuyWeaponByWeaponID, HookChain:g_hHasRestrictItem
new Array:g_aArrays[arraylist_e], Trie:g_tCheckItemName
new g_iPreviousSecondary[MAX_CLIENTS + 1] = { 2, ... }, g_iPreviousPrimary[MAX_CLIENTS + 1] = { 1, ... }, bool:g_bOpenMenu[MAX_CLIENTS + 1], bool:g_bAlwaysRandom[MAX_CLIENTS + 1]
new g_iPreviousSecondary[MAX_CLIENTS + 1] = {INVALID_INDEX, ...}, g_iPreviousPrimary[MAX_CLIENTS + 1] = {INVALID_INDEX, ...}, bool:g_bOpenMenu[MAX_CLIENTS + 1], bool:g_bAlwaysRandom[MAX_CLIENTS + 1]
new Float:g_flPlayerBuyTime[MAX_CLIENTS + 1]

new g_iSecondarySection, g_iPrimarySection, g_iBotSecondarySection, g_iBotPrimarySection
Expand All @@ -69,6 +69,8 @@ new EquipTypes:g_iEquipMode = EQUIP_MENU, bool:g_bBlockDefaultItems = true
new bool:g_bAlwaysOpenMenu, Float:g_flFreeBuyTime, g_iFreeBuyMoney
new bool:g_bHasMapParameters, mp_maxmoney

new g_szStarterPrimary[20], g_szStarterSecondary[20]
new g_iStarterPrimary = INVALID_INDEX, g_iStarterSecondary = INVALID_INDEX

public plugin_init()
{
Expand Down Expand Up @@ -97,6 +99,26 @@ public CSDM_Initialized(const szVersion[])

public plugin_cfg()
{
new eWeaponData[equip_data_s]

for(new i = 0; i < g_iNumPrimary; i++) {
ArrayGetArray(g_aArrays[Primary], i, eWeaponData)

if(equal(g_szStarterPrimary, eWeaponData[szWeaponName])) {
g_iStarterPrimary = i
break
}
}

for(new i = 0; i < g_iNumSecondary; i++) {
ArrayGetArray(g_aArrays[Secondary], i, eWeaponData)

if(equal(g_szStarterSecondary, eWeaponData[szWeaponName])) {
g_iStarterSecondary = i
break
}
}

CheckForwards()
}

Expand Down Expand Up @@ -180,8 +202,8 @@ public CSDM_RestartRound(const bool:bNewGame)

public client_putinserver(pPlayer)
{
g_iPreviousSecondary[pPlayer] = 2
g_iPreviousPrimary[pPlayer] = 1
g_iPreviousSecondary[pPlayer] = g_iStarterSecondary
g_iPreviousPrimary[pPlayer] = g_iStarterPrimary
g_bOpenMenu[pPlayer] = false
g_bAlwaysRandom[pPlayer] = false
g_flPlayerBuyTime[pPlayer] = 0.0
Expand Down Expand Up @@ -453,6 +475,14 @@ public ReadCfg_Settings(const szLineData[], const iSectionID)
{
g_bBlockDefaultItems = bool:(str_to_num(szValue))
}
else if(equali(szKey, "starter_primary"))
{
copy(g_szStarterPrimary, charsmax(g_szStarterPrimary), szValue)
}
else if(equali(szKey, "starter_secondary"))
{
copy(g_szStarterSecondary, charsmax(g_szStarterSecondary), szValue)
}
}
}

Expand Down

0 comments on commit f843d5d

Please sign in to comment.