alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
499 stars 203 forks source link

cs_set_user_bpammo bug #612

Closed justgo97 closed 1 year ago

justgo97 commented 6 years ago

Code :

#include <amxmodx>
#include <fun>
#include <cstrike>

public plugin_init()
{
    register_clcmd("say /test", "cmd_test")
}

public cmd_test(id)
{
    give_item(id, "weapon_hegrenade")
    cs_set_user_bpammo(id, CSW_HEGRENADE, 2)
}

Error :

L 10/02/2018 - 11:05:22: [CSTRIKE] Invalid weapon id 4
L 10/02/2018 - 11:05:22: [AMXX] Displaying debug trace (plugin "ammo_test.amxx", version "unknown")
L 10/02/2018 - 11:05:22: [AMXX] Run time error 10: native error (native "cs_set_user_bpammo")
L 10/02/2018 - 11:05:22: [AMXX]    [0] ammo_test.sma::cmd_test (line 13)

Versions :

meta version
Metamod-r v1.3.0.128, API (5:13)
Metamod-r build: 17:47:54 Aug 24 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/0cf2f70
amxx version
AMX Mod X 1.10.0.5233 (http://www.amxmodx.org)
Authors:
        David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
        Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
        Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
        Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Sep 28 2018 09:32:57
Built from: https://github.com/alliedmodders/amxmodx/commit/0b5584a
Build ID: 5233:0b5584a
Core mode: JIT+ASM32

ReGameDLL version: 5.7.0.313-dev

version
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.4.0.668-dev
Build date: 09:47:42 Sep 29 2018 (1631)
Build from: https://github.com/dreamstalker/rehlds/commit/89be216

this happens randomly, i m not using any other plugin.

Arkshine commented 6 years ago

Randomly? You mean this above code, sometimes works, sometimes not?

justgo97 commented 6 years ago

@Arkshine Yes exactly.

Arkshine commented 6 years ago

The changes related to this native is this: https://github.com/alliedmodders/amxmodx/pull/356/commits/da2abb9c3b7d68e5a6e926a4fcc58f4fe1345561; the ammo index retrieval is now based on WeaponList message. But, I'm not sure how this would fail.

HamletEagle commented 6 years ago

It happened once to me too, but I can't remember what plugin I was testing. What I remember is that the plugin was hooking WeaponList message, but it wasn't blocking or altering it. It was used only to retrieve data.

justgo97 commented 6 years ago

can you make a unique error log for this check and if possible with more info about what did go wrong :

(ammoIndex = WeaponsList[weaponId].ammoIndex1) < 0

for exemple :

L 10/02/2018 - 11:05:22: [CSTRIKE] Invalid ammo index :%d
L 10/02/2018 - 11:05:22: [AMXX] Displaying debug trace (plugin "ammo_test.amxx", version "unknown")
L 10/02/2018 - 11:05:22: [AMXX] Run time error 10: native error (native "cs_set_user_bpammo")
L 10/02/2018 - 11:05:22: [AMXX]    [0] ammo_test.sma::cmd_test (line 13)
Arkshine commented 6 years ago

Just tried a little, and I can't reproduce. No idea when this happens?

Do you have a plugin messing with WeaponList message?

justgo97 commented 6 years ago

No, i m not using other plugins expect for this one + default amxx plugins.

Arkshine commented 6 years ago

Hmm, it might be related to the code which disables the forwards (pfnMessageBegin, etc.)

In the game, WeaponList messages are sent from pfnServerActivate. Cstrike module enables the forwards at this point and disables them in pfnServerActivate as post.

Would be it possible the server lagged at this point, making the messages be sent a little later, and at this point, the forwards are already disabled? This would mean WeaponList would not be filled with data.

I can't see others reasons. This code should be removed https://github.com/alliedmodders/amxmodx/blob/master/modules/cstrike/cstrike/CstrikeMain.cpp#L110-L115 ; the forwards will be anyway disabled once WeaponList is fully catched.

justgo97 commented 6 years ago

maybe add a check to see if the forwards are disabled and output an error message so we can be sure that the problem is there

justgo97 commented 5 years ago

Again this happend to me today, and this time not randomly :

Code:

#include <amxmodx>
#include <fun>
#include <cstrike>

public plugin_init()
{
    register_clcmd("get_famas", "GiveFamas")
}

public GiveFamas(id)
{
    give_item(id, "weapon_famas")
    cs_set_user_bpammo(id, CSW_FAMAS, 100)
}

Error log:

L 07/01/2019 - 08:56:12: [CSTRIKE] Invalid weapon id 15
L 07/01/2019 - 08:56:12: [AMXX] Run time error 10 (plugin "ammo.amxx") (native "cs_set_user_bpammo") - debug not enabled!
L 07/01/2019 - 08:56:12: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
justgo97 commented 5 years ago

@Arkshine This time not using rehlds :

version
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
Exe build: 17:35:12 Jul  5 2017 (7559)
meta version
Metamod v1.21p37  2013/05/30 (5:13)
by Will Day
   http://www.metamod.org/
 Patch: Metamod-P (mm-p) v37
 by Jussi Kivilinna
    http://metamod-p.sourceforge.net/
compiled: Jun 13 2017, 23:20:55 EET (optimized)
amxx version
AMX Mod X 1.10.0.5257 (http://www.amxmodx.org)
Authors:
        David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
        Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
        Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
        Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: May 16 2019 06:12:10
Built from: https://github.com/alliedmodders/amxmodx/commit/486da2f
Build ID: 5257:486da2f
Core mode: JIT+ASM32
justgo97 commented 5 years ago

Update :

seems restarting the server / changing map will fix it it seems to happen because of some delay / lag in loading

justgo97 commented 1 year ago

Not sure if this is fixed but closing it anyway, this bug doesn't happen when using ReAPI natives