1

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.

lksmnd
  • 11
  • 5

2 Answers2

-1

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

Doyousketch2
  • 2,060
  • 1
  • 11
  • 11
-1

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.

Spar
  • 1,582
  • 9
  • 16
  • You're thinking of `ent:getParent()` https://wiki.facepunch.com/gmod/Entity:GetParent – Doyousketch2 Nov 14 '20 at 17:13
  • @Doyousketch2 > This function is generally used to disable physics interactions on projectiles being fired by their owner, but can also be used for normal ownership in case physics interactions are not involved at all. The Gravity gun will be able to pick up the entity even if the owner can't collide with it, the Physics gun however will not. https://wiki.facepunch.com/gmod/Entity:SetOwner – Spar Nov 14 '20 at 17:31
  • You're pointing out a function that isn't being used in this script. What's the relevance here? – Doyousketch2 Nov 14 '20 at 17:45
  • @Doyousketch2 But your answer mentions this functions as right decision, we don't use this function for ownership – Spar Nov 14 '20 at 17:50
  • 1
    I have already fixed this error, @Doyousketch2's answer is correct – lksmnd Nov 15 '20 at 08:03
  • @lksmnd If that fixed your problem that means someone's used SetOwner for ownership, I won't be impressed if your gamemode is doing this. – Spar Nov 15 '20 at 12:54