Jump to content

Music script


Recommended Posts

Hello, i need help with this script i want add

getPlayerName 

Function here is the lua

function cmdPlaySound(cmd, file) 
    if not file then 
        return outputChatBox("[uSAGE] /startmusic [name]", getLocalPlayer()); 
    end 
     
    if playSound("sounds/" .. file .. ".mp3") then 
        outputChatBox(Is Playing "  .. file,255,255,255); 
    end 
end 
  
addCommandHandler("startmusic", cmdPlaySound); 
 

i want when player start music it show on chatbox like example

    if playSound("sounds/" .. file .. ".mp3") then 
        outputChatBox(..getPlayerName..#0096FFIs Playing "  .. file,255,255,255); 
    end 
  
 

Link to comment

To output the message to every one in chat, You'll have to send a trigger to the server-side, Because outputChatBox client-side dosn't have a element argument .

I'v fixed the code, The trigger is on you ;) :

function cmdPlaySound( cmd, file ) 
    if not file then 
        return outputChatBox( "[uSAGE] /startmusic [name]" ) 
    end 
    
    if playSound ( "sounds/" .. file .. ".mp3" ) then 
        outputChatBox( "Is Playing "  .. file, 255, 255, 255 ) 
    end 
end 
addCommandHandler( "startmusic", cmdPlaySound ) 

Link to comment

i have server side here is it

  
function cmdInstallSound(player, cmd, file) 
    if not file then 
        outputChatBox("[uSAGE] /installsound [sound name]", player); 
    end 
     
    local xml, soundNode; 
     
    xml = xmlLoadFile(":soundplayer/meta.xml"); 
    soundNode = xmlCreateChild(xml, "file"); 
     
    xmlNodeSetAttribute(soundNode, "src", "sounds/" .. file .. ".mp3"); 
     
    xmlSaveFile(xml); 
    xmlUnloadFile(xml); 
     
    if restartResource(getThisResource()) then 
        outputChatBox("The sound file is installed, use /playsound " .. file, player); 
    else 
        outputChatBox("Restart this resource please", player); 
    end 
end 
  
addCommandHandler("installsound", cmdInstallSound); 

can you do it to me please

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...