TTT-2 / ttt2-role_siki

This is the "Sidekick" role for TTT2
4 stars 6 forks source link

Error when firing #10

Closed dok441 closed 5 years ago

dok441 commented 5 years ago

[ERROR] addons/ttt2-role_siki-master/lua/weapons/weapon_ttt2_sidekickdeagle.lua:98: attempt to index upvalue 'ttt2_sidekick_deagle_refill_conv' (a nil value)

  1. unknown - addons/ttt2-role_siki-master/lua/weapons/weapon_ttt2_sidekickdeagle.lua:98

When shooting a player

Alf21 commented 5 years ago

Do you have the newest version?

Alf21 commented 5 years ago

@lebroomer it could be possible that the sidekick deagle is loaded before the sidekick role is initialized. As a result, the ConVar isnt created at this moment. I think that this is leading to this issue (reasoned by the loading order). We should check this with a fallback. I suggest using CreateConVar function instead of GetConVar because it is doing the same. GetConVar makes sense if using in functions, sure. But to prevent initialization bugs, its not recommended.

TimGoll commented 5 years ago

But - correct me if I'm wrong - this error occured after firing the deagle. At that point everything should be loaded.

Alf21 commented 5 years ago

no. Not if the var isnt set because it is set while loading the script. This will lead to a nil initialization. Using :GetBool() after this will result in a nil error.

TimGoll commented 5 years ago

okay, my bad. I get it!