-- server side:
local gRoot = getRootElement();
local sounds = { }
addEvent( "serverLoadMusicTable", true );
addEventHandler( "serverLoadMusicTable", gRoot,
function ()
local res, mTable, xml = getThisResource(), {}, xmlLoadFile( "meta.xml", res );
local nameTable = {}
if xml then
local i = 0;
while ( xmlFindChild( xml, "stream", i ) ) do
local dir = xmlNodeGetAttribute( xmlFindChild( xml, "stream", i ), "url" );
local streamname = xmlNodeGetAttribute( xmlFindChild( xml, "stream", i ), "name" );
table.insert( mTable, dir..";"..streamname );
i = i + 1;
end;
end;
triggerClientEvent( source, "clientReceiveMusicTable", gRoot, mTable );
end
)
addEvent ( "createSound", true )
addEventHandler ( "createSound", root,
function ( id, theVehicle )
if ( theVehicle ) then
triggerClientEvent(root, "createSoundClient", root, id, theVehicle)
sounds [ theVehicle ] = id -- Store in the table the music ID using theVehicle as table index.
end
end
)
addEvent ( "destroySound", true )
addEventHandler ( "destroySound", root,
function ( theVehicle )
if ( theVehicle ) then
triggerClientEvent(root, "destroySoundClient", root, theVehicle)
sounds [ theVehicle ] = nil -- Remove the entry from the table.
end
end
)
Like that, now you have to trigger a event from the client side to request the content of 'sounds' table, then in the client side, loop that table and create the sounds.