yusufbali Posted July 24, 2015 Share Posted July 24, 2015 I just wanna when i say /kazandik , everyone see this but now when i say /kazandik only i see this and only i listen that music . Help please I am newbie function startMusic() setRadioChannel(0) song = playSound("music2.mp3",true) outputChatBox ( "#FFFFFFGenius Monsters #33ff00Kazandı!", 255, 255, 255, true ) end function makeRadioStayOff() setRadioChannel(0) cancelEvent() end function toggleSong() if not songOff then setSoundVolume(song,0) songOff = true removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) else setSoundVolume(song,1) songOff = false setRadioChannel(0) addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) end end addCommandHandler ( "kazandik", startMusic ) addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff) addCommandHandler("musicmusic",toggleSong) bindKey("m","down","musicmusic") Link to comment
novo Posted July 24, 2015 Share Posted July 24, 2015 You can either go through events and trigger a client-sided event from server-side or, create a client-sided command and execute it from server-side. Both examples: -- #1 -- Server addCommandHandler("kazandik", function(player, command, ...) triggerClientEvent(root, "kazandik_music", root) -- trigger this event for every player belonging to the root element, which should trigger for everyone in case you did not change any player's parent element end ) -- Client / Add the snippet bellow into your code addEvent("kazandik_music", true) addEventHandler("kazandik_music", root, function() startMusic() -- calling and executing startMusic end ) ----------------- -- #2 -- Server addCommandHandler("kazandik_all", -- As both, server and client sided commands, can not be named the same - we are using a different one function(player, command, ...) executeCommandHandler("kazandik", root) -- not sure if root can be used here instead of a player element directly / executing 'kazandik', your client-sided command that does the thing -- and in case that does not work for _, v in ipairs(getElementsByType("player")) do -- we iterate over a table returned by 'getElementsByType' that contains all players and executeCommandHandler("kazandik", v) -- execute the command for each one of them end end ) Link to comment
yusufbali Posted July 24, 2015 Author Share Posted July 24, 2015 That works, thank you 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