• Help with my addon
    14 replies, posted
So I am trying to make it so it plays music when someone is arrested but for some reason its not working [CODE]playerArrested(Player criminal, number time, Player actor) local sound = 'badboys.mp3'; resource.AddFile("sound/"..sound); hook.Add("playerArrested", "PlaySoundForArrested", function(crim, time, arrs) ply:SendLua('surface.PlaySound("badboys.mp3")'); end ) [/CODE]
[CODE]function plyMeta:arrest(time, arrester) hook.Call("playerArrested", DarkRP.hooks, self, time, arrester) self:SendLua('surface.PlaySound("badboys.mp3")'); end end[/CODE] Try it
Why would you ever teach someone to use SendLua?
[CODE]local sound = 'badboys.mp3'; resource.AddFile("sound/arrestedmusic/"..sound); function plyMeta:arrest(time, arrester) hook.Call("playerArrested", DarkRP.hooks, self, time, arrester) self:SendLua('surface.PlaySound("badboys.mp3")'); end end ) [/CODE] I have it like that and its still not working
[QUOTE=FluffedWolf;51744361][CODE]local sound = 'badboys.mp3'; resource.AddFile("sound/arrestedmusic/"..sound); function plyMeta:arrest(time, arrester) hook.Call("playerArrested", DarkRP.hooks, self, time, arrester) self:SendLua('surface.PlaySound("badboys.mp3")'); end end ) [/CODE] I have it like that and its still not working[/QUOTE] I ain't no lua master but from what I heard SendLua is bad
why send a string to a client when you can call a net message
[QUOTE=gonzalolog;51744471]why send a string to a client when you can call a net message[/QUOTE] Elaborate please, I have literally no experience with lua
[QUOTE=FluffedWolf;51744863]Elaborate please, I have literally no experience with lua[/QUOTE] SendLua networks a string to the client. Since the string is constant, you can instead send a net message that simply pings the client to run that code. It's much more network efficient since you're sending no actual data.
[QUOTE=code_gs;51745372]SendLua networks a string to all clients. Since the string is constant, you can instead send a net message that simply pings the client to run that code. It's much more network efficient since you're sending no actual data.[/QUOTE] SendLua uses usermessages. It just sends one to the player, it doesn't network it to everyone. [IMG]http://i.imgur.com/ic4i4sj.png[/IMG]
[QUOTE=sannys;51745405]SendLua uses usermessages. It just sends one to the player, it doesn't network it to everyone. [IMG]http://i.imgur.com/ic4i4sj.png[/IMG][/QUOTE] Sorry, meant to say "the client" not "all clients"
Okay I have a problem now, it works, the sound downloads, everything is fine and dandy but Create Stream Failed error 41 Failed to load sound "sound\badboys.mp3", file probably missing from disk/repository The file is not missing and I dont know why it does that...
Did you resource.AddFile it? If you don't have the file locally and are joining a server, the server needs to have you download it. Or workshop collection it. (Seems a waste for one file though)
[QUOTE=Nookyava;51749308]Did you resource.AddFile it? If you don't have the file locally and are joining a server, the server needs to have you download it. Or workshop collection it. (Seems a waste for one file though)[/QUOTE] Yes I did, the server makes you download it.
Bump
Sorry, you need to Log In to post a reply to this thread.