Jump to content

help again


Paplo

Recommended Posts

Posted
  
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

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted

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

Posted
  
-- 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 ! :?

Posted
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  
 

Posted
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  
  

Posted
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 ?

Posted (edited)
-- server 
  
addEvent("test", true) 
addEventHandler("test",getRootElement(), 
function () 
                    sound = playSound ( "1.mp3", false ) 
end) 

you added 2 end

Edited by Guest
Posted
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

Posted (edited)

lol the event dont need end

just close the Parentheses

look at my last reply now

EDIT:

Now, one step remain = trigger back to client

Edited by Guest
Posted
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.

Posted
lol the event dont need end

just close the Parentheses

look at my last reply now

end or ")" The same thing

who told you the end & ")" is same thing?

end is for:

function 
if 
for 

Posted
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 : / ?

Posted
lol the event dont need end

just close the Parentheses

look at my last reply now

end or ")" The same thing

who told you the end & ")" is same thing?

end is for:

function 
if 
for 

thank you for knowing ^^

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

??????

you did not do what I told you

and trigger is mistake in writing

Posted
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

Posted

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 
) 

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