In my application I'm trying to track all player's purchases. For this purpose I use ItemPickup event, its WeaponTraceable() method and my own internal structure that maps every weapon's ID to its owner:
app.parser.RegisterEventHandler(func(e events.ItemPickup) {
var weaponTraceable *common.Equipment
weaponTraceable = e.WeaponTraceable()
prevOwner, ok := app.weaponOwner[weaponTraceable.UniqueID()]
if !ok {
// bought an item
} else {
// actually picked it up
app.weaponOwner[weaponTraceable.UniqueID()] = e.Player
}
})
This works perfectly for any weapon except flashbang. When a player buys a second flashbang, they already have this weapon and therefore weaponOwner[weaponTraceable.UniqueID()] stores a value for it. Currently I use a separate rule for second flashbang which looks like this:
if player.IsInBuyZone() && (app.freezetime || app.parser.CurrentTime() - app.roundBeginTime < app.buyTime) {
// bought a flashbang
} else {
// picked it up
}
where app.freezetime is binded to "cs_gamerules_data.m_bFreezePeriod" property of "CCSGameRulesProxy" server class on entity creation, app.roundBeginTime gets updated every time a freezetime ends and app.buyTime is accuired from app.parser.GameState().ConVars()["mp_buytime"].
This seems to be working but still could possibly be the cause of some bugs later on. So my question is -- what is a proper way to determine if a player actually bought a second flashbang?
In my application I'm trying to track all player's purchases. For this purpose I use
ItemPickupevent, itsWeaponTraceable()method and my own internal structure that maps every weapon's ID to its owner:This works perfectly for any weapon except flashbang. When a player buys a second flashbang, they already have this weapon and therefore
weaponOwner[weaponTraceable.UniqueID()]stores a value for it. Currently I use a separate rule for second flashbang which looks like this:where
app.freezetimeis binded to"cs_gamerules_data.m_bFreezePeriod"property of"CCSGameRulesProxy"server class on entity creation,app.roundBeginTimegets updated every time a freezetime ends andapp.buyTimeis accuired fromapp.parser.GameState().ConVars()["mp_buytime"].This seems to be working but still could possibly be the cause of some bugs later on. So my question is -- what is a proper way to determine if a player actually bought a second flashbang?