#PickupCreated Event call conditions

1 messages · Page 1 of 1 (latest)

atomic bane
#

I was really wondering, when is the LabApi.Events.Handlers.ServerEvents.PickupCreated called. Because from my testing, which lead to inconsistent results at best, I couldn't figure it out.
Testing (Code):

LabApi.Events.Handlers.ServerEvents.PickupCreated += (ev) => Logger.Info($"Type: {ev.Pickup.Type} | Position: {ev.Pickup.Position}");

Testing Results:
Dropping items -> No event invocation
Upgrading items in 914 -> Sometimes the event is invoked, incosnistent results at best

  • Upgrading keycards (tested on the setting Fine) -> No invoke
  • Upgrading weapons (tested on the setting Fine) -> Invoked when upgrading a weapon with when the weapon on the input side contained Ammo
    • Com18 with ammo -> WAS called
    • Fsp9 without ammo -> wasn't called
    • Crossvec with ammo -> WAS called
  • Dropping items on death -> event was invoked
  • Swapping items (picking up armor which replaces the one in the player's inventory) -> event was invoked
  • Map item spawning (lockers, armories, etc.) -> event was invoked
    After the above I tried dropping ammo which didn't cause an invocation of the event either.

[NOTE]: No errors in console or the text log file either

young eagle
#

What is LabAPI even about bro 😭

atomic bane
atomic bane
atomic bane
cold hound
#

it only runs when Pickup.AddPickup has been ran

#

which should run when ItemPickupBase.OnPickupAdded gets called

#

which runs in ItemPickupBase.Start so whenever the item started it should send the event

atomic bane
#

It runs for about 33% of them from what it looks like when generating the map, as for dropped items, it doesn't run ever even tho the ItemPickupBase.Start does run

#

i'll give you my log, I've set up a prefix for the Start function in ItemPickupBase that logs the item type+serial

deft locust
atomic bane
#

MAP GEN

[2025-11-20 19:01:27.146 +01:00] [INFO] [CustomItemLib] Type: SCP1509 | Position: (68.03, 101.54, 57.58)
[2025-11-20 19:01:27.156 +01:00] [INFO] [CustomItemLib] START -> SCP500:[361]
[2025-11-20 19:01:27.166 +01:00] [INFO] [CustomItemLib] Type: SCP500 | Position: (78.64, -98.54, 94.09)
[2025-11-20 19:01:27.177 +01:00] [INFO] [CustomItemLib] START -> Medkit:[363]
[2025-11-20 19:01:27.187 +01:00] [INFO] [CustomItemLib] Type: Medkit | Position: (108.30, -98.59, 109.53)
[2025-11-20 19:01:27.197 +01:00] [INFO] [CustomItemLib] START -> Adrenaline:[364]
[2025-11-20 19:01:27.207 +01:00] [INFO] [CustomItemLib] Type: Adrenaline | Position: (108.30, -98.44, 109.53)
[2025-11-20 19:01:27.217 +01:00] [INFO] [CustomItemLib] START -> Medkit:[366]
[2025-11-20 19:01:27.227 +01:00] [INFO] [CustomItemLib] Type: Medkit | Position: (42.13, -98.59, 77.11)
[2025-11-20 19:01:27.237 +01:00] [INFO] [CustomItemLib] START -> Adrenaline:[367]
[2025-11-20 19:01:27.248 +01:00] [INFO] [CustomItemLib] Type: Adrenaline | Position: (42.14, -98.44, 77.11)
[2025-11-20 19:01:27.258 +01:00] [INFO] [CustomItemLib] START -> Medkit:[369]
[2025-11-20 19:01:27.267 +01:00] [INFO] [CustomItemLib] Type: Medkit | Position: (30.75, 101.41, 94.30)
[2025-11-20 19:01:27.277 +01:00] [INFO] [CustomItemLib] START -> Adrenaline:[370]
[2025-11-20 19:01:27.287 +01:00] [INFO] [CustomItemLib] Type: Adrenaline | Position: (30.75, 101.56, 94.30)
[2025-11-20 19:01:27.297 +01:00] [INFO] [CustomItemLib] START -> ParticleDisruptor:[372]
[2025-11-20 19:01:27.308 +01:00] [INFO] [CustomItemLib] Type: ParticleDisruptor | Position: (86.87, -99.04, 103.12)
[2025-11-20 19:01:27.318 +01:00] [INFO] [CustomItemLib] START -> SCP2176:[373]
[2025-11-20 19:01:27.328 +01:00] [INFO] [CustomItemLib] Type: SCP2176 | Position: (108.56, -103.07, 72.55)
[2025-11-20 19:01:27.338 +01:00] [INFO] [CustomItemLib] START -> SCP2176:[375]
[2025-11-20 19:01:27.348 +01:00] [INFO] [CustomItemLib] Type: SCP2176 | Position: (102.44, -98.56, 128.41)
cold hound
#

if you can, prefix patch AddPickup showing that the Dictionary already containts the key

ie:

$"Has: {Dictionary.ContainsKey(pickup)} oriPickup: {pickup}"

cold hound
#

ye

atomic bane
# cold hound ye

it doesn't call the event for ones that are in the dict as expected by the code

#
[2025-11-20 19:04:35.229 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[224]
[2025-11-20 19:04:35.239 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.249 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[225]
[2025-11-20 19:04:35.259 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.269 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[226]
[2025-11-20 19:04:35.280 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.290 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[227]
[2025-11-20 19:04:35.300 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.310 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[228]
[2025-11-20 19:04:35.320 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.330 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[229]
[2025-11-20 19:04:35.340 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.351 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[230]
[2025-11-20 19:04:35.361 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
[2025-11-20 19:04:35.371 +01:00] [INFO] [CustomItemLib] START -> Ammo9x19:[231]
[2025-11-20 19:04:35.380 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: Ammo9mmPickup(Clone) (InventorySystem.Items.Firearms.Ammo.AmmoPickup)
#

it doesn't seem to be failing because of a matching item type tho...?

[2025-11-20 19:04:37.804 +01:00] [INFO] [CustomItemLib] START -> KeycardScientist:[386]
[2025-11-20 19:04:37.815 +01:00] [INFO] [CustomItemLib] Has: False oriPickup: KeycardPickup(Clone) (InventorySystem.Items.Keycards.KeycardPickup)
[2025-11-20 19:04:37.825 +01:00] [INFO] [CustomItemLib] Type: KeycardScientist | Position: (76.56, 112.14, 114.32)
[2025-11-20 19:04:37.835 +01:00] [INFO] [CustomItemLib] START -> KeycardScientist:[387]
[2025-11-20 19:04:37.845 +01:00] [INFO] [CustomItemLib] Has: False oriPickup: KeycardPickup(Clone) (InventorySystem.Items.Keycards.KeycardPickup)
[2025-11-20 19:04:37.855 +01:00] [INFO] [CustomItemLib] Type: KeycardScientist | Position: (76.49, 112.17, 113.93)
#

and it's not dependant on previous items that spawned...? (latern doesn't spawn right?)

[2025-11-20 19:07:02.769 +01:00] [INFO] [CustomItemLib] START -> Lantern:[393]
[2025-11-20 19:07:02.779 +01:00] [INFO] [CustomItemLib] Has: True oriPickup: LanternPickup(Clone) (InventorySystem.Items.Pickups.CollisionDetectionPickup)
cold hound
#

can you edit the print format as
x.GetType() x.Serial ?

atomic bane
#

number in []

cold hound
#

ye but it would be easier to show both of the thing

atomic bane
#
[2025-11-20 19:10:02.498 +01:00] [INFO] [CustomItemLib] START -> GrenadeHE:[136]
[2025-11-20 19:10:02.508 +01:00] [INFO] [CustomItemLib] Has: True serial: 136 type: InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup netId: HegPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 136
[2025-11-20 19:10:02.518 +01:00] [INFO] [CustomItemLib] START -> GrenadeHE:[137]
[2025-11-20 19:10:02.529 +01:00] [INFO] [CustomItemLib] Has: True serial: 137 type: InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup netId: HegPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 137
[2025-11-20 19:10:02.539 +01:00] [INFO] [CustomItemLib] START -> GrenadeHE:[138]
[2025-11-20 19:10:02.549 +01:00] [INFO] [CustomItemLib] Has: True serial: 138 type: InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup netId: HegPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 138
[2025-11-20 19:10:02.559 +01:00] [INFO] [CustomItemLib] START -> GrenadeFlash:[139]
[2025-11-20 19:10:02.569 +01:00] [INFO] [CustomItemLib] Has: True serial: 139 type: InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup netId: FlashbangPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 139
[2025-11-20 19:10:02.579 +01:00] [INFO] [CustomItemLib] START -> GrenadeFlash:[140]
[2025-11-20 19:10:02.589 +01:00] [INFO] [CustomItemLib] Has: True serial: 140 type: InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup netId: FlashbangPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 140
[2025-11-20 19:10:02.600 +01:00] [INFO] [CustomItemLib] START -> GrenadeFlash:[141]
[2025-11-20 19:10:02.610 +01:00] [INFO] [CustomItemLib] Has: True serial: 141 type: InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup netId: FlashbangPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 141
atomic bane
#

Dropping item

[2025-11-20 19:11:56.683 +01:00] [INFO] [CustomItemLib] START -> GunCOM18:[418]
[2025-11-20 19:11:56.694 +01:00] [INFO] [CustomItemLib] Has: True serial: 418 type: InventorySystem.Items.Firearms.FirearmPickup netId: FirearmPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 418
cold hound
#

hmm, can you also log RemovePickup. I think it doesnt remove the pickup from the dictionary and thats why | nvm it should remove from the dictionary

atomic bane
#

same fields?

cold hound
#

$"{pickup.GetType().FullName} {pickup.Info.Serial}"

atomic bane
#

also when do you exptect them to be deleted? like they are still on the map

atomic bane
#

excpet

cold hound
atomic bane
#

for picking up items

#
[2025-11-20 19:17:05.511 +01:00] [INFO] [CustomItemLib] START -> GunCOM18:[418]
[2025-11-20 19:17:05.521 +01:00] [WARN] [CustomItemLib] Has: True serial: 418 type: InventorySystem.Items.Firearms.FirearmPickup netId: FirearmPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 418
[2025-11-20 19:17:09.323 +01:00] [ERROR] [CustomItemLib] REMOVAL Has: True serial: 418 type: InventorySystem.Items.Firearms.FirearmPickup netId: FirearmPickup(Clone) (Mirror.NetworkIdentity) ItemIDHASH: 418
cold hound
#

yes, picking them up should remove it

atomic bane
#

maybe there is like a wrong Equality check for them?

#

cos for dict find you need both Hash and Equal right?

#

*find

#

ALSO: some ID's are being skipped somehow (serials)

#

I can send over the whole log if it helps

#

wait i'll do console cos this is not really readable or?

#

should I make a bug report in LabAPI github? @cold hound

#

or just leave it here?

cold hound
#

yes, you should since this is not indended

atomic bane
#

alr I will

cold hound
#

if you can please change logging all for this:

TypeFullName, Serial, GetHashCode()

cold hound
#

all of them not just some

#

Start -> Log
Add -> Log
Remove ->Log

as like this so can ultimately check

atomic bane
#

I'm doing {(Pickup.Dictionary.ContainsKey(__instance) ? "PRESENT" : "ABSENT ")} TYPE: {__instance.GetType().FullName} [SERIAL:{__instance.Info.Serial}/{__instance.ItemId.SerialNumber}] [#{__instance.GetHashCode()}] so it's not too long

cold hound
#

kk

atomic bane
#

@cold hound

cold hound
#

you didnt replace it all places, do it please. also test when u pickup an item, drop it, pickup use it (ie: medkit)

cold hound
#

lel

atomic bane
#

give me a sec

#

random item pickups / drops including 1 armor switch

#

@cold hound (if you don't want me to ping each time, please say so)

cold hound
#

can you share the plugin to me?

atomic bane
#

It's one file cos I was gonna upload it to the bug report

cold hound
#

@atomic bane figured out why some of them isnt saying when starting the round.