1
votes

When trying start Garry's Mod server i get an error:

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:227: attempt to call global 'Player' (a table value)

  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:227

sv_gamemode_functions.lua:217-230

function GM:EntityRemoved(ent)

self.Sandbox.EntityRemoved(self, ent)
if ent:IsVehicle() then
    local found = ent:CPPIGetOwner()
    if IsValid(found) then
        found.Vehicles = found.Vehicles or 1
        found.Vehicles = found.Vehicles - 1
    end
end
local owner = ent.Getowning_ent and ent:Getowning_ent() or Player(ent.SID or 0)
if ent.DarkRPItem and IsValid(owner) then owner:removeCustomEntity(ent.DarkRPItem) end
if ent.isKeysOwnable and ent:isKeysOwnable() then ent:removeDoorData() end end

please help.

2

2 Answers

-1
votes

change this line

local owner = ent.Getowning_ent and ent:Getowning_ent() or Player(ent.SID or 0)

to

local owner = ent :GetOwner()

https://wiki.facepunch.com/gmod/Entity:GetOwner
https://wiki.facepunch.com/gmod/Player:UserID

-1
votes

The problem is not in this part of code. Something overrode Player global variable with a table.

You need to find why this happened.

If after the fix Player won't work, try Entity(ent.SID or 0), maybe it's a EntityIndex not UserID.

Entity:GetOwner (as Doyousketch2 suggested) won't help you because it's used for parenting not ownability.