繁体   English   中英

lua - garry 的 mod - 尝试调用全局“Player”(表值)

[英]lua - garry's mod - attempt to call global 'Player' (a table value)

尝试启动 Garry 的 Mod 服务器时出现错误:

[错误] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:227:尝试调用全局“玩家”(表值)

  1. 未知 - 游戏模式/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

请帮忙。

改变这一行

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

local owner = ent :GetOwner()

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

问题不在这部分代码中。 有些东西用表格覆盖了Player全局变量。

您需要找到发生这种情况的原因。

如果修复后 Player 无法正常工作,请尝试Entity(ent.SID or 0) ,也许它是 EntityIndex 而不是 UserID。

Entity:GetOwner (正如 Doyousketch2 所建议的那样)不会帮助你,因为它用于育儿而不是所有权。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM