Paplo Posted June 19, 2013 Share Posted June 19, 2013 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
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 -- 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
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 -- 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
iPrestege Posted June 19, 2013 Share Posted June 19, 2013 triggerServerEvent triggerClientEvent getRootElement or getElementsByType ( 'player' ); Link to comment
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 triggerServerEvent triggerClientEvent getRootElement or getElementsByType ( 'player' ); example plz ! Link to comment
Castillo Posted June 19, 2013 Share Posted June 19, 2013 You must trigger a server side event with triggerServerEvent then send back to client for all players with triggerClientEvent. Link to comment
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 trigger?, all the codes he writes are client Link to comment
Castillo Posted June 19, 2013 Share Posted June 19, 2013 3azef: If you don't understand what he's talking about, please don't reply, you are confusing him. Link to comment
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 @Solidsnake14: sorry, i just wanna help people Link to comment
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 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
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 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
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 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
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 (edited) -- server addEvent("test", true) addEventHandler("test",getRootElement(), function () sound = playSound ( "1.mp3", false ) end) you added 2 end Edited June 19, 2013 by Guest Link to comment
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 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 () Link to comment
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 (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 June 19, 2013 by Guest Link to comment
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 lol the event dont need endjust close the Parentheses look at my last reply now end or ")" The same thing Link to comment
Castillo Posted June 19, 2013 Share Posted June 19, 2013 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
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 lol the event dont need endjust 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 Link to comment
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 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
iPrestege Posted June 19, 2013 Share Posted June 19, 2013 You're not make a sense learn lua. Link to comment
Paplo Posted June 19, 2013 Author Share Posted June 19, 2013 lol the event dont need endjust 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 ^^ Link to comment
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 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 Link to comment
iMr.3a[Z]eF Posted June 19, 2013 Share Posted June 19, 2013 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
iPrestege Posted June 19, 2013 Share Posted June 19, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now