Person8880 / Shine

An administration mod for Natural Selection 2.
53 stars 23 forks source link

Error: lua/shine/core/shared/hook.lua:1071: attempt to index local 'Player' (a nil value) #891

Closed Hitman4 closed 1 year ago

Hitman4 commented 1 year ago

i saw server had 1 error

[Server] Script Error #1: lua/shine/core/shared/hook.lua:1071: attempt to index local 'Player' (a nil value) Call stack:

1: Spectate lua/shine/core/shared/hook.lua:1071

    OldFunc = function
    self = NS2Gamerules-3884 { }
    Player = nil
    NewTeam = 3
    Force = nil
    ShineForce = nil
    Override = nil
    OverrideTeam = nil
#2: lua/NS2ConsoleCommands_Server.lua:101
    client = ServerClient { }
    player = nil
Person8880 commented 1 year ago

The error is caused by a nil value being passed down from NS2ConsoleCommands_Server.lua. Looks like a client that has no player assigned to it trying to join the spectator team, which shouldn't normally happen and indicates something else is going wrong, possibly when the client connected.

While I could add a check to ensure the player is not nil, the bug really is in the console command(s) not first checking the client they're acting on has a player entity and/or the client not being assigned a player entity. Even with the check, the command would still end up doing nothing anyway, so this is a fairly harmless error.