簡體   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