Jump to content

Trigger users/3DSound


nikitafloy

Recommended Posts

Hi, sorry for the use of an interpreter.

Q: How can I transfer the user information between server-client?

Example:

function prov(thePlayer) 
    triggerClientEvent(thePlayer, 'Hello', getRootElement ( ), thePlayer ) 
end 
addCommandHandler('pr', prov) 
  
function HelloEnable(source) 
    guiSetVisible(hello.window[1],true) 
    guiSetInputEnabled(true) 
    showCursor(true) 
end 
addEvent( "Hello", true ) 
addEventHandler( "Hello", getRootElement(), HelloEnable ) 
  
... -- Opens GUI - user agreed - opens another GUI user group 'Helper' - a user group 'Helper' agrees - it will teleport to the first player who agreed in the first GUI. 
  
function sentBoxHelperBar(thePlayer) 
    guiSetVisible(helphim.window[1],true) 
    guiSetInputEnabled(true) 
    showCursor(true) 
end 
addEvent( "sentBoxHelperBar", true ) 
addEventHandler( "sentBoxHelperBar", getRootElement(), sentBoxHelperBar ) 
  
helphim = { 
    button = {}, 
    window = {} 
} 
helphim.window[1] = guiCreateWindow(gx/2-310, gy/2-140, 532, 103, 'This player ' ..tostring(getElementData( thePlayer, 'nickNamePom' )).. ' - need help!!!', false) 
guiWindowSetSizable(helphim.window[1], false) 
guiSetVisible(helphim.window[1],false) 
guiSetInputEnabled(false) 
showCursor(false) 
  
helphim.button[1] = guiCreateButton(45, 34, 188, 45, "Ok", false, helphim.window[1]) 
guiSetProperty(helphim.button[1], "NormalTextColour", "FFAAAAAA") 
helphim.button[2] = guiCreateButton(296, 34, 188, 45, "Later", false, helphim.window[1]) 
guiSetProperty(helphim.button[2], "NormalTextColour", "FFAAAAAA") 
  

Edited by Guest
Link to comment

I get false

You can pass arguments to triggerClientEvent/triggerServerEvent
  
        triggerClientEvent(source, 'Hello', root, source ) -- pass source to client 
 addEventHandler( "Hello", getRootElement(), HelloEnable ) -- Open GUI 
  
-- next i send a request 'Helper' 
    function sentBox() 
        triggerServerEvent( 'sentBoxHelper', root, thePlayer ) 
        disable() 
    end 
  
function sentBox(thePlayer) 
    local players = getElementsByType ( "player" ) -- get a table of all the players in the server 
    for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player 
    if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( thePlayer )), aclGetGroup ( "Helper" ) ) ) then 
        triggerClientEvent(thePlayer, 'sentBoxHelperBar', root, thePlayer) 
    end 
    end 
end 
-- i filter players and open new GUI 
  
    helphim.window[1] = guiCreateWindow(gx/2-310, gy/2-140, 532, 103, 'This player' ..tostring(source).. ' - need help!!!', false) -- 'source' -> 'false' 
  

Link to comment

Another question, if I may.

Music does not play for everyone. Need trigger server-client. How can I implement it in the code? Hard to imagine a sequence.

function onClickPlay(button) 
for _, n in ipairs (radSpis) do 
    if button == "left" then 
        if ( guiGetText( Radio.combobox[1] ) ~= tostring('Click to open') ) and ( guiGetText( Radio.edit[1] ) ~= "" ) then outputChatBox( 'Choose one thing!' ) return end  
            stopSound(sound3DSound) 
        if ( guiGetText( Radio.edit[1] ) ~= "" ) and ( guiGetText( Radio.combobox[1] ) == tostring('Click to open') ) then 
            sound3DSound = playSound3D ( guiGetText( Radio.edit[1] ), x,y,z, true ) 
            break 
        else 
            local dimensionPlayer = getElementDimension ( getLocalPlayer ( ) ) 
            if ( guiGetText( Radio.combobox[1] ) == 'Dubstep #1' ) then 
            sound3DSound = playSound3D ( "http://radiorecord.fm/m3u/trap320-32kbps.m3u", x,y,z, true ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Club Society' ) then 
            sound3DSound = playSound3D ( "http://radio.freshclub.net:9000/8094", x,y,z, true ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Trap' ) then 
            sound3DSound = playSound3D ( "http://www.radiorecord.fm/m3u/trap320-32kbps.m3u", x,y,z, true ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Mfm' ) then 
            sound3DSound = playSound3D ( "http://radio.mfm.ua/online128.m3u", x,y,z, true ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Click to open' ) then return 
            end 
        end 
        attachElements( sound3DSound, getLocalPlayer ( ) ) 
    end 
end 
end 

Link to comment
That's because playSound3D only plays for the local player, you must make a client-server synchronization.

Yes, I read the forum. :)

Here, everything is more difficult for me.

I do not know where to use the trigger on the client from the server. Nothing happens.

Turned out only without using GUI.

If you need the full code, I strip off in HP. I need to solve this problem. I still have 3 of my script that you want to finish. (

Link to comment

I would do this:

Make a function which will play a sound from a URL sent by the server, then attach an event handler to it.

Where you currently do "playSound3D" you use triggerServerEvent and pass the URL and dimension to the server side, then from the server side, you trigger the client side event you previously created, passing the URL and dimension received.

Link to comment
I would do this:

Make a function which will play a sound from a URL sent by the server, then attach an event handler to it.

Where you currently do "playSound3D" you use triggerServerEvent and pass the URL and dimension to the server side, then from the server side, you trigger the client side event you previously created, passing the URL and dimension received.

How i can sent URL by the server? Only elements.

Check me, please.

Send link to client.

  
--Server 
        function link() 
            link = "http://radiorecord.fm/m3u/trap320-32kbps.m3u" 
            triggerClientEvent( 'linkplaySound', link ) 
        end 
        addEvent('urlDim', true) 
        addEventHandler( 'urlDim', root, link ) 

Take link from client.

  
--Client 
  
function playSound() 
    sound3DSound = playSound3D ( ''..link..'', 0,0,0, true ) 
end 
addEvent('linkplaySound', true) 
addEventHandler( 'linkplaySound', root, playSound ) 
  
function onClickPlay(button) 
... 
            local dimensionPlayer = getElementDimension ( getLocalPlayer ( ) ) 
            if ( guiGetText( Radio.combobox[1] ) == 'Dubstep #1' ) then 
            sound3DSound = "http://radiorecord.fm/m3u/trap320-32kbps.m3u" 
            triggerServerEvent( 'urlDim', sound3DSound, dimensionPlayer ) -- when i start play sound, then link and dimension send to server.(Server need only link. I feel a lot of mistakes.) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
... 
            end 
        end 
        attachElements( sound3DSound, getLocalPlayer ( ) ) 
    end 
end 
end 
  

Link to comment

You are wrong, you can't send just elements.

The triggerServerEvent is wrong, put localPlayer after the event name.

Also, you named a function "playSound", that is not good, naming functions the same way as a native function shouldn't be done, unless you want to replace it.

Link to comment
You are wrong, you can't send just elements.

The triggerServerEvent is wrong, put localPlayer after the event name.

Also, you named a function "playSound", that is not good, naming functions the same way as a native function shouldn't be done, unless you want to replace it.

Thx for u remarks.

But now every player hears music. Need to hear it was only from the source. And now playing some URL, if I change the station.

Edited by Guest
Link to comment
Post the client and server side scripts.

Client.

function playSoundNow() 
    local x,y,z = getElementPosition(localPlayer) 
    sound3DSound = playSound3D ( ''..link..'', x,y,z, true ) 
end 
addEvent('linkplaySound', true) 
addEventHandler( 'linkplaySound', root, playSound ) 
  
function onClickPlay(button) 
local x,y,z = getElementPosition ( localPlayer ) 
for _, n in ipairs (radSpis) do 
    if button == "left" then 
        if ( guiGetText( Radio.combobox[1] ) ~= tostring('Кликните, чтобы раскрыть') ) and ( guiGetText( Radio.edit[1] ) ~= "" ) then outputChatBox( 'Выберите что-то одно!' ) return end  
            stopSound(sound3DSound) 
        if ( guiGetText( Radio.edit[1] ) ~= "" ) and ( guiGetText( Radio.combobox[1] ) == tostring('Кликните, чтобы раскрыть') ) then 
            sound3DSound = playSound3D ( guiGetText( Radio.edit[1] ), x,y,z, true ) 
            triggerServerEvent( 'urlDim', localPlayer ) 
            break 
        else 
            local dimensionPlayer = getElementDimension ( localPlayer ) 
            if ( guiGetText( Radio.combobox[1] ) == 'Dubstep #1' ) then 
            sound3DSound = "http://radiorecord.fm/m3u/trap320-32kbps.m3u" 
            triggerServerEvent( 'urlDim', localPlayer ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Club Society' ) then 
            sound3DSound = playSound3D ( "http://radio.freshclub.net:9000/8094", x,y,z, true ) 
            triggerServerEvent( 'urlDim', localPlayer ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Trap' ) then 
            sound3DSound = playSound3D ( "http://www.radiorecord.fm/m3u/trap320-32kbps.m3u", x,y,z, true ) 
            triggerServerEvent( 'urlDim', localPlayer ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Mfm' ) then 
            sound3DSound = playSound3D ( "http://radio.mfm.ua/online128.m3u", x,y,z, true ) 
            triggerServerEvent( 'urlDim', localPlayer ) 
            setElementDimension( sound3DSound, dimensionPlayer ) 
            elseif ( guiGetText( Radio.combobox[1] ) == 'Кликните, чтобы раскрыть' ) then return 
            end 
        end 
        attachElements( sound3DSound, localPlayer ) 
    end 
end 
end 

Server.

        function link() 
            link = "http://radiorecord.fm/m3u/trap320-32kbps.m3u" 
            triggerClientEvent( 'linkplaySound', root, link ) 
        end 
        addEvent('urlDim', true) 
        addEventHandler( 'urlDim', root, link ) 

Link to comment

-- server side:

function link ( link, dimension ) 
    triggerClientEvent ( 'linkplaySound', root, client, link, dimension ) 
end 
addEvent ( 'urlDim', true ) 
addEventHandler ( 'urlDim', root, link ) 

-- client side:

function playSoundNow ( player, link, dimension ) 
    local x, y, z = getElementPosition ( player ) 
    sound3DSound = playSound3D ( link, x,y,z, true ) 
    setElementDimension ( sound3DSound, dimension ) 
    attachElements ( sound3DSound, player ) 
end 
addEvent ( 'linkplaySound', true ) 
addEventHandler ( 'linkplaySound', root, playSound ) 

Then you make your triggerServerEvent like this:

triggerServerEvent ( 'urlDim', localPlayer, "http://radio.mfm.ua/online128.m3u", dimensionPlayer ) 

  • Like 1
Link to comment
-- server side:
function link ( link, dimension ) 
    triggerClientEvent ( 'linkplaySound', root, client, link, dimension ) 
end 
addEvent ( 'urlDim', true ) 
addEventHandler ( 'urlDim', root, link ) 

-- client side:

function playSoundNow ( player, link, dimension ) 
    local x, y, z = getElementPosition ( player ) 
    sound3DSound = playSound3D ( link, x,y,z, true ) 
    setElementDimension ( sound3DSound, dimension ) 
    attachElements ( sound3DSound, player ) 
end 
addEvent ( 'linkplaySound', true ) 
addEventHandler ( 'linkplaySound', root, playSound ) 

Then you make your triggerServerEvent like this:

triggerServerEvent ( 'urlDim', localPlayer, "http://radio.mfm.ua/online128.m3u", dimensionPlayer ) 

THX U!

9c0118ee860a.png

'Special thanks - Castillo' :D

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