IterElements

This function is useful for for loops. You don't have to type ipairs( getElementsByType( "player" ) ) but simply iterElements( "player" ). It's very useful if you have many for loops in your code.

Syntax

iterator iterElements( string elementType )

Required Arguments

elementType: Type of the elements that you want to iterate through.

Code

function iterElements( elementType )
local i = 0;
local tab = getElementsByType( elementType );
return function( )
i = i + 1;
if tab[ i ] then
return i, tab[ i ];
end
end
end

Example

This example will iterate through all players and vehicles. It will heal the players, give them $1000, send them a message informing them about the action and fix all vehicles when the resource starts.