![](/img/trans.png)
[英]Attempt to call global 'localPlayer' (a nil value) error in Garry's Mod
[英]lua - garry's mod - attempt to call global 'Player' (a table value)
嘗試啟動 Garry 的 Mod 服務器時出現錯誤:
[錯誤] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:227:嘗試調用全局“玩家”(表值)
- 未知 - 游戲模式/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.