local tTeams =
{
tTeamBlue =
{
[46] =
{
[31] = 50;
[29] = 50;
};
};
tTeamRed =
{
[45] =
{
[28] = 50;
[26] = 50;
};
};
}
for sIndex, t in pairs( tTeams ) do
createTeam( sIndex )
end
function fTableGetIndexs( t )
local tTest = { }
for m, _ in pairs( t ) do table.insert( tTest, m ) end
return tTest
end
addEventHandler( 'onResourceStart', resourceRoot,
function( )
for _, uPlayer in pairs( getElementsByType 'player' ) do
setTimer( setPlayerTeam, 100, 1,
uPlayer,
getTeamFromName( fTableGetIndexs( tTeams )[ math.random( #fTableGetIndexs( tTeams ) ) ] )
) -- set random team for example
setTimer(
function( uPlayer, tTeams )
local sTeam = getTeamName( getPlayerTeam( uPlayer ) )
setElementModel(
uPlayer,
fTableGetIndexs( tTeams[ sTeam ] )[1]
)
for nIndex, nValue in pairs(
tTeams[ sTeam ][ fTableGetIndexs( tTeams[ sTeam ] )[1] ]
)
do
setTimer( giveWeapon, 100, 1, uPlayer, nIndex, nValue )
end
end,
200, 1, uPlayer, tTeams )
end
end
)
Updated