Jump to content

can anyone help plz


mrhamdy

Recommended Posts

Posted

hello every body,

i download a script call ipod from here

https://community.multitheftauto.com/ind ... ils&id=330

it work fine and no problems it's server side.

my problem i need it client side that can everyone run his own music on his client.

i mean how to make the client read other xml file and put it in table from client side .

so i can make music.xml file in every client and read it table to display in ipod menu.

i don't have good background about lua programming but i can read and understand the scrpit.

the server code and client code for the ipod program is shown below:-

local gRoot = getRootElement(); 
  
addEvent( "serverLoadMusicTable", true ); 
addEventHandler( "serverLoadMusicTable", gRoot, 
  function () 
    local res, mTable, xml = getThisResource(), {}, xmlLoadFile( "meta.xml", res ); 
    if xml then 
      local i = 0; 
      while ( xmlFindChild( xml, "file", i ) ) do   
        local dir = xmlNodeGetAttribute( xmlFindChild( xml, "file", i ), "src" ); 
        if dir:find( "music/" ) ~= nil then 
          table.insert( mTable, dir ); 
        end; 
        i = i + 1; 
      end; 
    end; 
    triggerClientEvent( source, "clientReceiveMusicTable", gRoot, mTable ); 
  end 
) 

and the client side is

gMe         = getLocalPlayer(); 
gRoot       = getRootElement(); 
gResRoot    = getResourceRootElement( getThisResource () ); 
  
btn = {}; 
ipodCoor = { moving={}, pos={} }; 
addEvent( "clientReceiveMusicTable", true ); 
  
addEventHandler( "onClientResourceStart", gResRoot, 
  function () 
    outputChatBox( "pree i to open ipod", 0, 255, 0 ); 
     
    ipod = guiCreateStaticImage( 1.0, 0.2279, 0.1916, 0.4036, "ipod.png", true );  --0.7744 
    ipodCoor.moving[ipod] = false; 
    ipodCoor.pos[ipod] = "out"; 
     
    songDisplay = guiCreateGridList( 0.0671, 0.0245, 0.8504, 0.4663, true, ipod ); 
     
    btn[1] = guiCreateButton( 0.64, 0.67, 0.15, 0.05, "Play", true, ipod ); 
    btn[2] = guiCreateButton( 0.185, 0.67, 0.15, 0.05, "Stop", true, ipod ); 
    btn[3] = guiCreateButton( 0.42, 0.825, 0.15, 0.05, "vD", true, ipod ); 
    btn[4] = guiCreateButton( 0.42, 0.525, 0.15, 0.05, "vU", true, ipod ); 
     
    for i=1,4 do 
      guiSetAlpha( btn[i], 1.0 ); 
      guiSetFont( btn[i], "default-small" ); 
    end; 
     
    songList = guiGridListAddColumn( songDisplay, "My Songs", 0.85 ); 
    addEvent( "serverLoadMusicTable", true ); 
     
    addEventHandler( "onClientGUIClick", gRoot, 
      function () 
        if source == btn[1] then 
          local selSong = guiGridListGetItemText( songDisplay, guiGridListGetSelectedItem( songDisplay ) ); 
          if selSong then 
            if not music then 
              music = playSound( tostring( selSong ) ); 
            else 
              stopSound( music ); 
              music = playSound( tostring( selSong ) ); 
            end; 
          end; 
        elseif source == btn[2] then 
          if music then 
            stopSound( music ); 
            music = nil; 
          end; 
        elseif source == btn[4] then 
          if music then 
            setSoundVolume( music, getSoundVolume( music ) + 0.25 ); 
            if getSoundVolume( music ) > 1 then 
              setSoundVolume( music, 1 ); 
            end; 
          end; 
        elseif source == btn[3] then 
          if music then 
            setSoundVolume( music, getSoundVolume( music ) - 0.25 ); 
            if getSoundVolume( music ) < 0 then 
              setSoundVolume( music, 0 ); 
            end; 
          end; 
        end; 
      end 
    ) 
     
    bindKey( "i", "down", 
      function () 
        if ipodCoor.moving[ipod] == false then 
          if ipodCoor.pos[ipod] == "out" then 
            showCursor( true, false ); 
            ipodCoor.moving[ipod] = true; 
            addEventHandler( "onClientRender", gRoot, openIPod ); 
            toggleControl( "fire", false ); 
          else 
            showCursor( false, false ); 
            ipodCoor.moving[ipod] = true; 
            addEventHandler( "onClientRender", gRoot, closeIPod ); 
            toggleControl( "fire", true ); 
          end; 
        end; 
      end 
    ) 
  end 
) 
  
function openIPod() 
  local x, y = guiGetPosition( ipod, true ); 
  guiSetPosition( ipod, x - 0.01, y, true ); 
  if x < 0.775 then 
    ipodCoor.moving[ipod] = false; 
    ipodCoor.pos[ipod] = "in"; 
    removeEventHandler( "onClientRender", gRoot, openIPod ); 
  end; 
end; 
  
function closeIPod() 
  local x, y = guiGetPosition( ipod, true ); 
  guiSetPosition( ipod, x + 0.01, y, true ); 
  if x > 1.0 then 
    guiSetPosition( ipod, 1.0, y, true ); 
    ipodCoor.moving[ipod] = false; 
    ipodCoor.pos[ipod] = "out"; 
    removeEventHandler( "onClientRender", gRoot, closeIPod ); 
  end; 
end; 
  
  
  
addEventHandler( "clientReceiveMusicTable", gRoot, 
  
  function ( mTable ) 
    if mTable == nil then 
      addEvent( "serverLoadMusicTable", true ); 
    else 
      for _, v in ipairs ( mTable ) do 
        local row = guiGridListAddRow( songDisplay ); 
        guiGridListSetItemText( songDisplay, row, 1, v, false, false ); 
      end; 
      guiGridListAutoSizeColumn( songDisplay, 1 ); 
      guiBringToFront( songDisplay ); 
    end; 
  end 
) 

i'll be thankful for your reply

  • Moderators
Posted

You can't make that because the folder in the player computer can't be modified ( if is it modified, the server will resend the folder to the client ), so he can't put his songs in the folder.

Maybe I'm wrong, I don't know. :|

  • Moderators
Posted
Of course it is possible, i've made a Sound player using 1.1 functions with this feature.

Ok so is it possible to modify the clients folder of a server ?

Posted

Well, the client can edit XML files, i've done it before, and this is how my sound player works, you must add your songs to the "songs" folder then add to .xml file and then it will load them.

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