IsElementStreamedIn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(OOP)
 
(One intermediate revision by one other user not shown)
Line 10: Line 10:
bool isElementStreamedIn ( element theElement )
bool isElementStreamedIn ( element theElement )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[element]]:isStreamedIn|streamedIn}}


===Required Arguments===
===Required Arguments===
Line 18: Line 19:


==Example==
==Example==
This command shows you how many objects you have streamed in.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkTheObjects ( cmd )
local amount = 0 -- When starting the command, we don't have any objects looped.
for k,v in ipairs ( getElementsByType ( "object" ) ) do -- Looping all the objects in the server
if isElementStreamedIn ( v ) then -- If the object is streamed in
amount = amount + 1 -- It's an object more streamed in
end
end
outputChatBox ( "You have currently " ..amount.. " objects streamed in." ) -- Send the player the amount of objects that are streamed in
end
addCommandHandler ( "checkobjects", checkTheObjects )
</syntaxhighlight>
</syntaxhighlight>
Note: Objects can already stream from a very long distance, so even when you can't see some objects, they can still be returned.


==See Also==
==See Also==
{{Client element functions}}
{{Client element functions}}
[[Category:Needs Example]]

Latest revision as of 19:30, 17 September 2023

This function checks whether an element is currently streamed in (not virtualized) and are actual GTA objects in the world. You can force an element to be streamed in using setElementStreamable.

Syntax

bool isElementStreamedIn ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:isStreamedIn(...)
Variable: .streamedIn


Required Arguments

  • theElement: The element to check whether is streamed in or not.

Returns

Returns true if the passed element is currently streamed in, false if it is virtualized.

Example

This command shows you how many objects you have streamed in.

function checkTheObjects ( cmd )
	local amount = 0 -- When starting the command, we don't have any objects looped.
	for k,v in ipairs ( getElementsByType ( "object" ) ) do -- Looping all the objects in the server
		if isElementStreamedIn ( v ) then -- If the object is streamed in
			amount = amount + 1 -- It's an object more streamed in
		end
	end
	outputChatBox ( "You have currently " ..amount.. " objects streamed in." ) -- Send the player the amount of objects that are streamed in
end
addCommandHandler ( "checkobjects", checkTheObjects )

Note: Objects can already stream from a very long distance, so even when you can't see some objects, they can still be returned.

See Also