annoying spawn lua error

How do i fix this?




[ERROR] gamemodes/base/gamemode/cl_hudpickup.lua:17: attempt to call method 'GetPrintName' (a nil value)
  1. unknown - gamemodes/base/gamemode/cl_hudpickup.lua:17


weapon:GetPrintName() returns the .PrintName member variable of the weapon.

if you have picked up a weapon that doesnt have .PrintName set it wont come up with anything, and it will error.

just do some debugging. for example you could add in an override function to catch the class of the weapon, then when you pick it up, find it in your weapons and add a SWEP.PrintName = “my weapon”.

the override would look something like
[lua]
local _R = debug.getregistry();
local oldWepGetPrintName = _R.Weapon.GetPrintName;
function _R.Weapon:GetPrintName()
print(self:GetClass());
oldWepGetPrintName(self);
end
[/lua]

if you REALLY wanted to, you would pcall the old print name to stop the error, but thats no fun and you wouldnt know which one is erroring.

in theory this should print the weapon class BEFORE it errors (if its going to error)

this probably has nothing to do with your actual problem, but its worth a shot :slight_smile:

its an error in the base gamemode that was installed with my gmod dedicated server

The error is as described above the base gamemode is trying to draw text of the weapon’s name, the weapons PrintName variable must be nil in an addon you’ve installed.

[editline]7th January 2013[/editline]

you forgot a return statement. :wink:

where do i put that?