Difference between revisions of "GetLocalPlayerEntityId"

From Nomad DB
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This functions return the [[EntityId|Entity Id]] of the local player. The returned id should be checked against the Invalid Entity Id.
+
This functions return the [[EntityId|Entity ID]] of the local player. Under some circumstances it's possible for the returned ID to be invalid, thus should be checked against [[GetInvalidEntityId]].
  
 
== Syntax ==
 
== Syntax ==
<pre>
+
<syntaxhighlight lang="lua">
 
GetLocalPlayerEntityId()
 
GetLocalPlayerEntityId()
</pre>
+
</syntaxhighlight>
 +
 
 +
* '''Returns''': [[EntityId]]
  
 
== Example ==
 
== Example ==
The example below checks to see if the [[EntityId|Entity Id]] for the player is valid.
+
The example below checks whether the [[EntityId|Entity ID]] of the local player is valid or not.
<pre>
+
<syntaxhighlight lang="lua" highlight="1">
 
local lplayerId = GetLocalPlayerEntityId()
 
local lplayerId = GetLocalPlayerEntityId()
 
if lplayerId == GetInvalidEntityId() then
 
if lplayerId == GetInvalidEntityId() then
print("Local Player is valid")
+
print("Invalid local player")
 
else
 
else
print("Invalid Local Player")
+
print("Got the local player ID")
 
end
 
end
</pre>
+
</syntaxhighlight>
  
 
== Related Pages ==
 
== Related Pages ==
 
* [[EntityId]]
 
* [[EntityId]]
  
[[Category:WD2 Lua]]
+
[[Category:WD2 Lua]] [[Category: WD2 Entity]] [[Category: WD2 Player]]

Latest revision as of 19:05, 14 April 2020

This functions return the Entity ID of the local player. Under some circumstances it's possible for the returned ID to be invalid, thus should be checked against GetInvalidEntityId.

Syntax

GetLocalPlayerEntityId()

Example

The example below checks whether the Entity ID of the local player is valid or not.

local lplayerId = GetLocalPlayerEntityId()
if lplayerId == GetInvalidEntityId() then
	print("Invalid local player")
else
	print("Got the local player ID")
end

Related Pages