Jump to content

radio3d и URL


Yashann

Recommended Posts

https://community.multitheftauto.com/in ... ils&id=532

Помогите вставить сюда вставить URL ссылки на радио, не как не получается...как быть с плейлистом, обычные мп3 легко поставить а вот поставить ссылки на радио не выходит.

Заранее благодарен!

Link to comment
  • Scripting Moderators

Так, для начала откроем radio3d_playlist/playlist.xml, впишем туда например такое:

<playlist> 
    <song url="http://online.radiorecord.ru:8101/rr_128" name="Radio Record" /> 
    <song filename="test.mp3" /> 
</playlist> 

Далее идем в radio3d/radio3d_client.lua

1) Находим функцию getLocalPlaylist() и заменяем ее на:

function getLocalPlaylist() 
    local theSongs = {} 
    local xml = xmlLoadFile(":radio3d_playlist/playlist.xml") 
    if xml then 
        local i = 0 
        while (xmlFindChild(xml, "song", i)) do  
            local filename = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "filename") 
            if filename then 
                table.insert(theSongs, ":radio3d_playlist/music/"..filename) 
            end 
            local url = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "url") 
            local name = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "name") 
            if url then 
                table.insert(theSongs, url.."|"..name) 
            end 
            i = i + 1; 
        end 
    xmlUnloadFile(xml)     
    end 
     
    return theSongs 
end 

2) Находим createPlaylist() и заменяем на:

function createPlaylist()    
    playlist = {} 
     
    -- 1. Fill the playlist with placeholders 
    for number, letter in ipairs (playlistLetters) do 
        local filePath = "music/placeholder.mp3" 
        -- local songTitle = "Placeholder" 
        local songTitle = settings.placeholder 
        -- local songTitle = string.sub(filePath, 7, -5) 
         
        local song = {filePath, songTitle} 
  
        table.insert(playlist, song)     
    end 
  
    -- 2. Change the beginning of playlist to local playlist 
    local localPlaylist = getLocalPlaylist() 
     
    for key, filePath in pairs(localPlaylist) do 
        if string.find(filePath, "http://") then 
            filePath, songTitle = split(filePath, "|")[1], split(filePath, "|")[2] 
        else 
            songTitle = string.sub(filePath, 25, -5) 
        end 
        local song = {filePath, songTitle} 
        playlist[key] = song 
    end 
     
end 

В принципе все просто, думаю разберетесь.

Link to comment
Так, для начала откроем radio3d_playlist/playlist.xml, впишем туда например такое:

<playlist> 
    <song url="http://online.radiorecord.ru:8101/rr_128" name="Radio Record" /> 
    <song filename="test.mp3" /> 
</playlist> 

Далее идем в radio3d/radio3d_client.lua

1) Находим функцию getLocalPlaylist() и заменяем ее на:

function getLocalPlaylist() 
    local theSongs = {} 
    local xml = xmlLoadFile(":radio3d_playlist/playlist.xml") 
    if xml then 
        local i = 0 
        while (xmlFindChild(xml, "song", i)) do  
            local filename = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "filename") 
            if filename then 
                table.insert(theSongs, ":radio3d_playlist/music/"..filename) 
            end 
            local url = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "url") 
            local name = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "name") 
            if url then 
                table.insert(theSongs, url.."|"..name) 
            end 
            i = i + 1; 
        end 
    xmlUnloadFile(xml)     
    end 
     
    return theSongs 
end 

2) Находим createPlaylist() и заменяем на:

function createPlaylist()    
    playlist = {} 
     
    -- 1. Fill the playlist with placeholders 
    for number, letter in ipairs (playlistLetters) do 
        local filePath = "music/placeholder.mp3" 
        -- local songTitle = "Placeholder" 
        local songTitle = settings.placeholder 
        -- local songTitle = string.sub(filePath, 7, -5) 
         
        local song = {filePath, songTitle} 
  
        table.insert(playlist, song)     
    end 
  
    -- 2. Change the beginning of playlist to local playlist 
    local localPlaylist = getLocalPlaylist() 
     
    for key, filePath in pairs(localPlaylist) do 
        if string.find(filePath, "http://") then 
            filePath, songTitle = split(filePath, "|")[1], split(filePath, "|")[2] 
        else 
            songTitle = string.sub(filePath, 25, -5) 
        end 
        local song = {filePath, songTitle} 
        playlist[key] = song 
    end 
     
end 

В принципе все просто, думаю разберетесь.

ГИГАНТСКОЕ СПАСИБО

Link to comment
ГИГАНТСКОЕ СПАСИБО

Пожалуйста)

есть ещё вопрос, Это скрипт на зарепление игрока на месте

Это клиент сторона

function glue() 
    local player = getLocalPlayer() 
    if not getPlayerOccupiedVehicle(player) then 
        local vehicle = getPlayerContactElement(player) 
        if getElementType(vehicle) == "vehicle" then 
             
            local px, py, pz = getElementPosition(player) 
            local vx, vy, vz = getElementPosition(vehicle) 
            local sx = px - vx 
            local sy = py - vy 
            local sz = pz - vz 
             
            local rotpX = 0 
            local rotpY = 0 
            local rotpZ = getPlayerRotation(player) 
             
            local rotvX,rotvY,rotvZ = getVehicleRotation(vehicle) 
             
            local t = math.rad(rotvX) 
            local p = math.rad(rotvY) 
            local f = math.rad(rotvZ) 
             
            local ct = math.cos(t) 
            local st = math.sin(t) 
            local cp = math.cos(p) 
            local sp = math.sin(p) 
            local cf = math.cos(f) 
            local sf = math.sin(f) 
             
            local z = ct*cp*sz + (sf*st*cp + cf*sp)*sx + (-cf*st*cp + sf*sp)*sy 
            local x = -ct*sp*sz + (-sf*st*sp + cf*cp)*sx + (cf*st*sp + sf*cp)*sy 
            local y = st*sz - sf*ct*sx + cf*ct*sy 
             
            local rotX = rotpX - rotvX 
            local rotY = rotpY - rotvY 
            local rotZ = rotpZ - rotvZ 
             
            local slot = getPlayerWeaponSlot(player) 
             
            --outputDebugString("gluing ".. getPlayerName(player) .." to " .. getVehicleName(vehicle) .. "(offset: "..tostring(x)..","..tostring(y)..","..tostring(z).."; rotation:"..tostring(rotX)..","..tostring(rotY)..","..tostring(rotZ)..")") 
             
            triggerServerEvent("gluePlayer", player, slot, vehicle, x, y, z, rotX, rotY, rotZ) 
             
            unbindKey("x","down",glue) 
            bindKey("x","down",unglue) 
            bindKey("jump","down",unglue) 
        end 
    end 
end 
  
addCommandHandler("glue",glue) 
  
function unglue () 
    local player = getLocalPlayer() 
    triggerServerEvent("ungluePlayer", player) 
    unbindKey("jump","down",unglue) 
    unbindKey("x","down",unglue) 
    bindKey("x","down",glue) 
end 
  
addCommandHandler("unglue",unglue) 
  
bindKey("x","down",glue) 

Это серверная

function gluePlayer(slot, vehicle, x, y, z, rotX, rotY, rotZ) 
    attachElementToElement(source, vehicle, x, y, z, rotX, rotY, rotZ) 
    setPlayerWeaponSlot(source, slot) 
end 
addEvent("gluePlayer",true) 
addEventHandler("gluePlayer",getRootElement(),gluePlayer) 
  
function ungluePlayer() 
    detachElementFromElement(source) 
end 
addEvent("ungluePlayer",true) 
addEventHandler("ungluePlayer",getRootElement(),ungluePlayer) 

В чём может быть ошибка? Иногда некоторые игроки не могут прикрепиться нажимая на X только после рестарта ресурса.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...