GetElementByIndex: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function returns an element of the specified type from index.


==Syntax==  
==Syntax==  
Line 10: Line 10:


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''type:''' the type of the element to be returned. Examples include "player", "vehicle", or a custom type.
 
*'''index:''' the element's index (0 for the first element, 1 for the second, etc).
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns the requested element, or false if it doesn't exist.


==Example==  
==Example==  
This example does...
This example does...
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
totalplayers = getPlayerCount () -- get the amount of players in the server
blabhalbalhb --abababa
local i = 0
--This line does this...
while ( i < totalplayers ) do -- step through the players, from 0 to total, and send each a greeting
mooo
  pyr = getElementByIndex ( "player", i ) -- get a player element from index and assign it to variable pyr
  outputChatBox ( "Hello " .. getPlayerName ( pyr ) .. "!", pyr )
  i = i + 1
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{FunctionArea_Functions}}

Revision as of 11:32, 2 June 2006


This function returns an element of the specified type from index.

Syntax

element getElementByIndex ( string type, int index )  

Required Arguments

  • type: the type of the element to be returned. Examples include "player", "vehicle", or a custom type.
  • index: the element's index (0 for the first element, 1 for the second, etc).

Returns

Returns the requested element, or false if it doesn't exist.

Example

This example does...

totalplayers = getPlayerCount () -- get the amount of players in the server
local i = 0
while ( i < totalplayers ) do -- step through the players, from 0 to total, and send each a greeting
  pyr = getElementByIndex ( "player", i ) -- get a player element from index and assign it to variable pyr
  outputChatBox ( "Hello " .. getPlayerName ( pyr ) .. "!", pyr )
  i = i + 1
end

See Also

Template:FunctionArea Functions