Jump to content

help again


Paplo

Recommended Posts

  
client 
local lastTick = 0 -- Define a variable with the last tick count 
local toWait = 60000 -- Define a variable with the time needed to wait 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then -- Calculate how long it passed since last used and compare with required time to wait. 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    sound = playSound ( "1.mp3", false ) 
                    lastTick = getTickCount ( ) 
                else 
                    outputChatBox ( 'You Not Have Money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 

how i can make playsound To hear all audio from the server

Link to comment
  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  
-- client 
local lastTick = 0 -- Define a variable with the last tick count 
local toWait = 60000 -- Define a variable with the time needed to wait 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then -- Calculate how long it passed since last used and compare with required time to wait. 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    sound = playSound ( "1.mp3" ) 
                    lastTick = getTickCount ( ) 
                else 
                    outputChatBox ( 'You Not Have Money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 

A boolean representing whether the sound will be looped. To loop the sound, use true. Loop is not available for streaming sounds, only for sound files.

Link to comment
  
-- client 
local lastTick = 0 -- Define a variable with the last tick count 
local toWait = 60000 -- Define a variable with the time needed to wait 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then -- Calculate how long it passed since last used and compare with required time to wait. 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    sound = playSound ( "1.mp3" ) 
                    lastTick = getTickCount ( ) 
                else 
                    outputChatBox ( 'You Not Have Money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 

Did not bring anything new ! :?

Link to comment
server 
  
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function () 
                    sound = playSound ( "1.mp3", false ) 
end 
end 

client 
  
local lastTick = 0 
local toWait = 20000 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    triggerServerEvent ( 'test', money ) 
                    outputChatBox ( ' the sound has started', 0, 255, 0 ) 
                    lastTick = getTickCount ( ) 
                                    else 
             outputChatBox ( 'you don't have money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "you must wait 60 sc to use again", 255, 0, 0 ) 
                end  
 

Link to comment
server 
  
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function () 
                    sound = playSound ( "1.mp3", false ) 
end 
end 

client 
  
local lastTick = 0 
local toWait = 20000 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    triggerServerEvent ( 'test', money ) 
                    outputChatBox ( ' the sound has started', 0, 255, 0 ) 
                    lastTick = getTickCount ( ) 
                                    else 
             outputChatBox ( 'you dont have money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "you must wait 60 sc to use again", 255, 0, 0 ) 
                end  
  

Link to comment
server 
  
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function () 
                    sound = playSound ( "1.mp3", false ) 
end 
end 

client 
  
local lastTick = 0 
local toWait = 20000 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    triggerServerEvent ( 'test', money ) 
                    outputChatBox ( ' the sound has started', 0, 255, 0 ) 
                    lastTick = getTickCount ( ) 
                                    else 
             outputChatBox ( 'you dont have money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "you must wait 60 sc to use again", 255, 0, 0 ) 
                end         end 
    end             
) 
  

like this ?

Link to comment
server 
  
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function () 
                    sound = playSound ( "1.mp3", false ) 
end 

you added 2 end

end to addEventHandler

and end to function () xD

Link to comment
server 
  
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function () 
                    sound = playSound ( "1.mp3", false ) 
end 
end 

client 
  
local lastTick = 0 
local toWait = 20000 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    triggerServerEvent ( 'test', money ) 
                    outputChatBox ( ' the sound has started', 0, 255, 0 ) 
                    lastTick = getTickCount ( ) 
                                    else 
             outputChatBox ( 'you don't have money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "you must wait 60 sc to use again", 255, 0, 0 ) 
                end  
  
 

playSound is a client side only function, you need to trigger back to client to play it.

Link to comment
client 
  
local lastTick = 0 
local toWait = 20000 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    triggerServerEvent ( 'test2', ) 
                    outputChatBox ( ' the sound has started', 0, 255, 0 ) 
                    lastTick = getTickCount ( ) 
                                    else 
             outputChatBox ( 'you dont have money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "you must wait 60 sc to use again", 255, 0, 0 ) 
                end         end 
    end             
) 
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function() 
                    sound = playSound ( "1.mp3", false ) 
end) 
  

server 
  
addEvent("test2", true) 
addEventHandler("test2",getRootElement(), 
function () 
                    triggerClientrEvent ( 'test' ) 
end 
end 

like this : / ?

Link to comment
client 
  
local lastTick = 0 
local toWait = 20000 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    triggerServerEvent ( 'test2', ) 
                    outputChatBox ( ' the sound has started', 0, 255, 0 ) 
                    lastTick = getTickCount ( ) 
                                    else 
             outputChatBox ( 'you dont have money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "you must wait 60 sc to use again", 255, 0, 0 ) 
                end         end 
    end             
) 
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function() 
                    sound = playSound ( "1.mp3", false ) 
end) 
  

server 
  
addEvent("test2", true) 
addEventHandler("test2",getRootElement(), 
function () 
                    triggerClientrEvent ( 'test' ) 
end 
end 

like this : / ?

??????

you did not do what I told you

and trigger is mistake in writing

Link to comment

Try this :

-- Client Side --

local lastTick = 0 -- Define a variable with the last tick count 
local toWait = 60000 -- Define a variable with the time needed to wait 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0 
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then -- Calculate how long it passed since last used and compare with required time to wait. 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent('SyncSound',localPlayer) 
                    lastTick = getTickCount ( ) 
                else 
                    outputChatBox ( 'You Not Have Money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 
  
addEvent('ClientSyncSound',true) 
addEventHandler('ClientSyncSund',root, 
    function (  ) 
                  if isElement ( sound ) then destroyElement ( sound ) sound = nil end 
        sound = playSound ( "1.mp3", false ) 
    end 
) 

-- Server Side --

addEvent('SyncSound',true) 
addEventHandler('SyncSound',root, 
    function (      ) 
        triggerClientEvent ('ClientSyncSound',root) 
    end 
) 

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