Fix error when building RuntimeContext with invalid player (#3063)

* Fix E2Lib NULL error

* Apply suggestions
This commit is contained in:
Redox 2024-05-13 06:35:05 +02:00 committed by GitHub
parent a32066ce90
commit 4079111f68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1072,7 +1072,7 @@ end
---@param ply userdata
function RuntimeContextBuilder:withOwner(ply)
self.player = assert(ply)
self.uid = (self.player.UniqueID and self.player:UniqueID()) or "World"
self.uid = (ply:IsValid() and ply.UniqueID and ply:UniqueID()) or "World"
return self
end
@ -1258,4 +1258,4 @@ function E2Lib.compileScript(code, owner)
end
end
end
end
end