amxmodx
amxmodx copied to clipboard
get_weaponid() returns 0 when used in plugin_precache() on server start
Similarly to get_user_msgid(), this function will also return 0 when used inside plugin_precache() when the server starts. If this cannot be fixed, I suggest adding a note in the API just like we did with the other function.
On first server start, this function will return 0 if used inside
plugin_precache(). Consider hooking RegUserMsg in order to retrieve
the correct message id.
I'm assuming there are more functions that have the same issue, so adding a note in all of them would be apprecaited.
plugin_precache() is called before LinkUserMessages(), so WeaponList hasn't an msgid yet...
After a little it of testing, get_weaponid/get_weaponname uses WeaponList message to populate its data, on CS is sent right after LinkUserMessages(), but on HL it's sent on the first UpdateClientData() call of each player, after putinserver, so isn't populated before a player fully enters the server.
So it is quite unreliable to use it before those cases, that should be added as a note too.