FPtje / DarkRP

DarkRP, a non-serious roleplay gamemode for Garry's Mod.
https://darkrp.miraheze.org
MIT License
463 stars 710 forks source link

bad argument #1 to 'SetModel' #2271

Closed alotlikebirds closed 8 years ago

alotlikebirds commented 8 years ago

This started happening after I updated to the lastest github version

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:504: bad argument #1 to 'SetModel' (string expected, got nil)

  1. SetModel - [C]:-1
    1. Call - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:504
    2. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:670

When I run: rcon lua_run PrintTable(hook.GetTable().PlayerSetModel) I get:

PrintTable ( hook.GetTable ( ) .PlayerSetModel )... L 01/02/2016 - 18:29:37: Lua Error: [ERROR] lua/includes/extensions/table.lua:711: bad argument #1 to 'pairs' (table expected, got nil)

  1. pairs - [C]:-1
    1. GetKeys - lua/includes/extensions/table.lua:711
    2. PrintTable - lua/includes/util.lua:42
      1. unknown - lua_run:1

[ERROR] lua/includes/extensions/table.lua:711: bad argument #1 to 'pairs' (table expected, got nil)

  1. pairs - [C]:-1
    1. GetKeys - lua/includes/extensions/table.lua:711
    2. PrintTable - lua/includes/util.lua:42
      1. unknown - lua_run:1

Btw this only occurs when 1 specific player joins. Which is weird to me.

Bo98 commented 8 years ago

This has been reported a few times now. It was fixed for one person but seemingly no one else.

What job does said player appear as when they get this error?

alotlikebirds commented 8 years ago

Joining/Connecting

Bo98 commented 8 years ago

That'll be the cause of the error. It can't find the job table for "Connecting/Joining" as there is no such job (it's the default GMod assigned team) and thus the model for the job is nil.

First thing to check is if there is any error in the server console when the affected player joins. If not, then it could be an addon blocking DarkRP's PlayerInitialSpawn from working.

lua_run local ply = player.GetBySteamID([[STEAM_ID_HERE]]) for k,v in pairs(hook.GetTable().PlayerInitialSpawn) do if v(ply) ~= nil then print(k) end end

That snippet could help find what's causing it. This should print out any suspect hooks. You'll have to replace STEAM_ID_HERE with the affected player's Steam ID. You'll also need to have them connected to the server at the time of running it.

alotlikebirds commented 8 years ago

rcon lua_run local ply = player.GetBySteamID("STEAM_0:1:26091510") for k,v in pairs(hook.GetTable().PlayerInitialSpawn) do if v(ply) ~= nil then print(k) end end

local ply = player.GetBySteamID ( STEAM_0:1:26091510 ) for k,v in pairs ( hook.GetTable ( ) .PlayerInitialSpawn ) do if v ( ply ) ~= nil then print ( k ) end end... L 01/03/2016 - 16:49:10: Lua Error: [ERROR] lua_run:1: '' expected near '1'

  1. unknown - lua_run:0

[ERROR] lua_run:1: '' expected near '1'

  1. unknown - lua_run:0
alotlikebirds commented 8 years ago

The first post I made show the errors when the player joins.

Bo98 commented 8 years ago

Switch the " with [[ and ]] (see above edit).

I forgot rcon hates quote marks.

The first post I made show the errors when the player joins.

Sorry, I meant if there was any just before that.

alotlikebirds commented 8 years ago

Not sure if he's gonna get back on tonight, I'll reply once he does.

FPtje commented 8 years ago

This bug can finally be understood, once you figure out that ply:getJobTable() returns {} by default. Can't believe I've looked at the problem for so long without figuring that out.

alotlikebirds commented 8 years ago

I know this is closed but I finally got the chance to run

lua_run local ply = player.GetBySteamID([[STEAM_0:1:26091510]]) for k,v in pairs(hook.GetTable().PlayerInitialSpawn) do if v(ply) ~= nil then print(k) end end

Here's the error -

01/05/2016 - 15:26:49: Lua Error: [ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:296: attempt to index local 'ply' (a boolean value)

  1. v - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:296
    1. unknown - lua_run:1

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:296: attempt to index local 'ply' (a boolean value)

  1. v - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:296
    1. unknown - lua_run:1
Bo98 commented 8 years ago

Apparently player.GetBySteamID likes to return booleans instead of nil when it can't find a player.

Are you running this at the wrong time perhaps? Ensure the player is actually on the server and has spawned in as it won't work in the stage where they have "joined" but not spawned in yet.

alotlikebirds commented 8 years ago

Ya he was on, spawned and everything. Still the base model with the Joining/Connecting job.

Bo98 commented 8 years ago

That's really odd as that error you posted should only happen when there is no such player with the given Steam ID (see here if you know Lua).

I guess you can go the more manual approach of:

lua_run PrintTable(hook.GetTable().PlayerInitialSpawn)

and check any hooks that look suspicious (or post the list here and I'll have a look).

You can ignore:

alotlikebirds commented 8 years ago

Ok, ill reply when he's back online

Bo98 commented 8 years ago

Don't need to have him online for that one as it doesn't involve a player object.

alotlikebirds commented 8 years ago

PrintTable ( hook.GetTable ( ) .PlayerInitialSpawn )... Arrested = function: 0x1d4f8080 DarkRPCanHearVoice = function: 0x1d053a68 DarkRP_Simplerr = function: 0x1d6ddda0 EGP_ScrHW_Request = function: 0x29d98cd8 EGP_SpawnFunc = function: 0x29d8f748 FAdmin_ChangelevelInfo = function: 0x0f012c70 FAdmin_GlobalSettings = function: 0x1d4f17d0 FAdmin_Log = function: 0x1a8a2080 FAdmin_SetAccess = function: 0x0ba77a28 FPP.PlayerInitialSpawn = function: 0x1d6d2778 FPP_SendSettings = function: 0x1d6bfbc0 FullUpdateEntityNetworkBeamVars = function: 0x1c9b2408 GPUPlayerRespawn = function: 0x2a682430 GivePlayerLaws = function: 0x0fac7610 HMPlayerInitialSpawn = function: 0x1d6dfb70 PlayerSpawnSendReports = function: 0x0be787d8 SPUPlayerRespawn = function: 0x2a5e69e0 SW.PlayerInitialSpawn = function: 0x1519f218 SendConnectLog = function: 0x152c8338 SendLaws = function: 0x29c02428 SendMOTDSite = function: 0x1cf9b550 ULXLogInitialSpawn = function: 0x1a898e28 ULXWelcome = function: 0x1c8d3bd8 ULibSendAuthToClients = function: 0x152c4528 ULibSendRegisteredPlugins = function: 0x1518cec0 UTeamInitialSpawn = function: 0x1a89e558 WireLib.GetServerUUID = function: 0x1c95e9b8 WireMapInterface_PlayerInitialSpawn = function: 0x2a12d1d0 WirePlayerInitSpawn = function: 0x1a8a94c8 sendAutoCompletes = function: 0x15192c70 showMotd = function: 0x1c8fd440 th_Networking = function: 0x1d1b3380 wire_expression2_updateClientsideExtensions = function: 0x29dd05c8 wire_holograms_set_vars = function: 0x2a26bde8 wire_ports = function: 0x1c95f0e0

nothing out of the ordinary, I do wonder if its wire tho.

Bo98 commented 8 years ago

No idea about:

The reset seem ok. Wire looks fine to me but if you're unsure then you can always try temporarily removing it.

alotlikebirds commented 8 years ago

I log almost everything XD, ya ill just remove all of those and see if the problem continues.

alotlikebirds commented 8 years ago

I removed all my custom files, and tested again. The issue is still there for the same player.. Its only one player that creates these errors. I have no idea how to find the issue thats causing this since its only one player, so I'm just going to move on.