[code]10/02/2010 - 23:03:04: Lua Error: Timer Error: [@gamemodes\darkrp\gamemode\player.lua:359] bad argument #1 to 'floor' (number expected, got nil)[/code]
[lua]
function meta:PayDay()
if ValidEntity(self) and self:GetTable().Pay == 1 then
if not RPArrestedPlayers[self:SteamID()] then
**** local amount = math.floor(DB.RetrieveSalary(self)) ****
if amount == 0 then
Notify(self, 4, 4, LANGUAGE.payday_unemployed)
else
self:AddMoney(amount)
Notify(self, 4, 4, string.format(LANGUAGE.payday_message, CUR .. amount))
end
else
Notify(self, 4, 4, LANGUAGE.payday_missed)
end
end
end[/lua]
Spams ALOT making the server lag...
[highlight]Error #2[/highlight]
[code]20:03:04 L 10/02/2010 - 23:03:06: Lua Error: Timer Error: [lua\includes\modules\hook.lua:105] attempt to index local 'gm' (a number value)[/code]
Spams ALOT!!!!
[lua] if ( gm ) then
local GamemodeFunction = gm[ name ]
if ( GamemodeFunction == nil ) then return nil end
if ( type( GamemodeFunction ) != "function" ) then
Msg( "Calling Non Function!? ", GamemodeFunction, "\n" )
end
// This calls the actual gamemode function - after all the hooks have had chance to override
b, rA, rB, rC, rD, rE, rF, rG, rH = pcall( GamemodeFunction, gm, ... )
if (!b) then
gm[ name .. "_ERRORCOUNT" ] = gm[ name .. "_ERRORCOUNT" ] or 0
gm[ name .. "_ERRORCOUNT" ] = gm[ name .. "_ERRORCOUNT" ] + 1
ErrorNoHalt( tostring(rA) .. "(Hook: "..tostring(name)..")\n" )
return nil
end
return rA, rB, rC, rD, rE, rF, rG, rH
end[/lua]
[QUOTE=mikeym;25213939][code]10/02/2010 - 23:03:04: Lua Error: Timer Error: [@gamemodes\darkrp\gamemode\player.lua:359] bad argument #1 to 'floor' (number expected, got nil)[/code]
[lua]
function meta:PayDay()
if ValidEntity(self) and self:GetTable().Pay == 1 then
if not RPArrestedPlayers[self:SteamID()] then
**** local amount = math.floor(DB.RetrieveSalary(self)) ****
if amount == 0 then
Notify(self, 4, 4, LANGUAGE.payday_unemployed)
else
self:AddMoney(amount)
Notify(self, 4, 4, string.format(LANGUAGE.payday_message, CUR .. amount))
end
else
Notify(self, 4, 4, LANGUAGE.payday_missed)
end
end
end[/lua]
[/quote]
DB.RetrieveSalary(self) is not returning a number. It is probably trying to get a networked value or a normal value from the player object, and it isn't initialized.
[QUOTE=mikeym;25213939]
[highlight]Error #2[/highlight]
[code]20:03:04 L 10/02/2010 - 23:03:06: Lua Error: Timer Error: [lua\includes\modules\hook.lua:105] attempt to index local 'gm' (a number value)[/code]
Spams ALOT!!!!
[lua] if ( gm ) then
local GamemodeFunction = gm[ name ]
if ( GamemodeFunction == nil ) then return nil end
if ( type( GamemodeFunction ) != "function" ) then
Msg( "Calling Non Function!? ", GamemodeFunction, "\n" )
end
// This calls the actual gamemode function - after all the hooks have had chance to override
b, rA, rB, rC, rD, rE, rF, rG, rH = pcall( GamemodeFunction, gm, ... )
if (!b) then
gm[ name .. "_ERRORCOUNT" ] = gm[ name .. "_ERRORCOUNT" ] or 0
gm[ name .. "_ERRORCOUNT" ] = gm[ name .. "_ERRORCOUNT" ] + 1
ErrorNoHalt( tostring(rA) .. "(Hook: "..tostring(name)..")\n" )
return nil
end
return rA, rB, rC, rD, rE, rF, rG, rH
end[/lua][/QUOTE]
Some code somewhere is using [b][url=http://wiki.garrysmod.com/?title=Hook.Call]Hook.Call [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] improperly. The second argument is supposed to be the gamemode table, or nothing at all (nil). Whoever wrote the script that is doing this is trying to pass an argument to a hook, but failed to account for the second argument to [b][url=http://wiki.garrysmod.com/?title=Hook.Call]Hook.Call [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
That is all I can say with the code you showed me.
Is there an easy fix for either of them?
[QUOTE=mikeym;25219421]Is there an easy fix for either of them?[/QUOTE]
It's hard to say. The second one would probably be easy. Search all your Lua files for any references to [b][url=http://wiki.garrysmod.com/?title=Hook.Call]Hook.Call [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] ([url=http://www.prgrep.com/]PRGrep[/url] is useful for this kind of thing) and see which one is passing a bad second argument. Then, insert nil as a second argument.
As for the first one, you need to find the script that defines DB.RetrieveSalary(), figure out what variable it is trying to use, and then hunt down the script that is supposed to initialize it. Then make sure it always gets initialized properly before a call to DB.RetrieveSalary() can be made.
I'm gonna try to find it :P
[QUOTE=Jcw87;25219497]It's hard to say. The second one would probably be easy. Search all your Lua files for any references to [b][url=http://wiki.garrysmod.com/?title=Hook.Call]Hook.Call [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] ([url=http://www.prgrep.com/]PRGrep[/url] is useful for this kind of thing) and see which one is passing a bad second argument. Then, insert nil as a second argument.
As for the first one, you need to find the script that defines DB.RetrieveSalary(), figure out what variable it is trying to use, and then hunt down the script that is supposed to initialize it. Then make sure it always gets initialized properly before a call to DB.RetrieveSalary() can be made.[/QUOTE]
I fixed it by going into hook.lua, and searching for the line, then I read another thread about how GM. has to be capital, I changed it to capital and haven't received an error within the past 10 minutes.
[QUOTE=mikeym;25337631]I fixed it by going into hook.lua, and searching for the line, then I read another thread about how GM. has to be capital, I changed it to capital and haven't received an error within the past 10 minutes.[/QUOTE]
That's not a proper fix. hook.lua is a standard gmod file and SHOULD NOT BE EDITED!!! gm needs to be lowercase as it is the function argument being passed. Find the code that is calling it wrong, and fix that.
EDIT:
If you want to make it easier, TEMPORARILY add this to the top of the hook.Call function:
[lua]
if gm && type(gm) != "table" then error("hook.Call used incorrectly!!!", 2) end
[/lua]
That will cause the game to report an error at the offending script, instead of Garry's function.
Can that script be anywhere or does it have to be near the hook.call that is passing a bad arguement
What the hell happened to the lua tags.
[lua]Oh god[/lua]
Please please please dont be broken...
[code]Code work[/code]
Humm?
[QUOTE=mikeym;25342927]Can that script be anywhere or does it have to be near the hook.call that is passing a bad arguement[/QUOTE]
Read my post again.
[QUOTE=Jcw87;25340015]
TEMPORARILY add this to the [b]top of the hook.Call function[/b]:
[/QUOTE]
Example:
[lua]
function Call( name, gm, ... )
if gm && type(gm) != "table" then error("hook.Call used incorrectly!!!", 2) end -- This is the new line in hook.lua
local b, rA, rB, rC, rD, rE, rF, rG, rH
local HookTable = Hooks[ name ]
[/lua]
Sorry, you need to Log In to post a reply to this thread.