Griefhard Posted August 24, 2018 Posted August 24, 2018 Hello, here's my plan: After takeoff, I'd like to play a soundfile to the palyer that has taken off. So set the condition in the editor is not that difficult: For example: CONDITION UNIT'S SPEED HIGHER THAN (Player Uzi 1, 51.4) //that's about 100kts Now there's only - SOUND TO GROUP - SOUND TO COUNTRY - SOUND TO COALITION - SOUND TO ALL But I need something like SOUND TO UNIT... I believe it can be done with a script, but I don't know how that is achieved and I don't know, where I could learn that specific part. So - could someone maybe tell me, what code I have to use to play a specific soundfile to a specific unit? Thank you!
feefifofum Posted August 24, 2018 Posted August 24, 2018 As a general rule I'd get in the habit of making player flights their own individual groups for this as well as a host of other reasons. THE GEORGIAN WAR - OFFICIAL F-15C DLC
Griefhard Posted August 24, 2018 Author Posted August 24, 2018 I see... But IS there actually a way to play a soundfile to a unit (player/client) rather than a group? And how would the code be? Would be great, if someone could post it. Thanks!
Grimes Posted August 25, 2018 Posted August 25, 2018 Unfortunately "toUnit" scripts and triggers aren't quite in the game yet. Its been requested for a while now. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Griefhard Posted August 25, 2018 Author Posted August 25, 2018 Thanks Grimes - I find a workaround. For now I guess all players get a different group then. ;-)
Hardcard Posted August 26, 2018 Posted August 26, 2018 (edited) I see... But IS there actually a way to play a soundfile to a unit (player/client) rather than a group? And how would the code be? Yes, there is. I'm gonna show you a way of doing this in MOOSE. Send a text message + sound message to a specific client: YourClient = CLIENT:FindByName("Name of the client UNIT in ME") --This tells MOOSE which client to look for. Remember, it must be the client's unit name defined in ME, quotes are required -- MESSAGE:New("content of the text message", 10):ToClient(YourClient) --Creates a new 10 second text message and sends it to the client object defined above (YourClient). Quotes are required-- USERSOUND:New( "FULL name of the sound file with its extension included" ):ToClient(YourClient) --Plays the sound file for the client object defined above (YourClient). Quotes and file extension are required-- --Btw, remember that Lua is case sensitive, if you make syntax mistakes, the script won't work. Also, you'll need to download Moose.lua and run it at mission start (using a "do script file" action).-- Edited August 26, 2018 by Hardcard [sIGPIC][/sIGPIC]
Griefhard Posted August 26, 2018 Author Posted August 26, 2018 Cool! - Thanks Harcard. I'll be looking into this!
Grimes Posted August 27, 2018 Posted August 27, 2018 Yes, there is. I'm gonna show you a way of doing this in MOOSE. Send a text message + sound message to a specific client: That literally uses trigger.action.outTextForGroup. function MESSAGE:ToClient( Client, Settings ) self:F( Client ) if Client and Client:GetClientGroupID() then if self.MessageType then local Settings = Settings or ( Client and _DATABASE:GetPlayerSettings( Client:GetPlayerName() ) ) or _SETTINGS -- Core.Settings#SETTINGS self.MessageDuration = Settings:GetMessageTime( self.MessageType ) self.MessageCategory = "" -- self.MessageType .. ": " end if self.MessageDuration ~= 0 then local ClientGroupID = Client:GetClientGroupID() self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen) end end return self end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Hardcard Posted August 27, 2018 Posted August 27, 2018 (edited) Hi there Grimes! Yes, if you open the declaration for that script bit, it does look like the message should be sent to groups, not individual clients. However, in reality, if you try to use the client's group name in YourClient instead of its unit name, the message won't be sent. In other words, CLIENT:FindByName ONLY accepts client unit names, it really does target only individual clients in practice. If you need proof, just try the attached test mission, which runs the script I posted above. Two client J11As on ramp, leader and wingman, both belong to the same group. Leader will receive the text message every second, wingman will be ignored all the time. Just switch slots and see for yourself. Now, I'm still a MOOSE noob and couldn't tell you how this all works "under the hood"... All I know is that it does, somehow :thumbup:Client test.miz Edited August 27, 2018 by Hardcard [sIGPIC][/sIGPIC]
Grimes Posted August 27, 2018 Posted August 27, 2018 Best guess is that it is checking for the first client unit to exist in order to display the message. If you did it in MP with both slots occupied then both clients will see the message. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
BaD CrC Posted August 27, 2018 Posted August 27, 2018 Just create as many different groups as you have players, no? So you can use sound to group and only one player can hear it. https://www.blacksharkden.com http://discord.gg/blacksharkden
Hardcard Posted August 28, 2018 Posted August 28, 2018 (edited) Best guess is that it is checking for the first client unit to exist in order to display the message. You mean at database level? Because this doesn't seem to be the case in the test mission itself. Have you tried the test mission I provided? It doesn't look like you have, mate. If you have, then you must've seen how wingman NEVER receives the text message, not even when it's the first active unit in the mission. Leader, on the other hand, ALWAYS receives the message, even if it's the last to spawn. If I use wingman's unit name in my script instead, the opposite happens. Actually, I've gone ahead and created 3 test examples, same mission, same method: -In the first example, ONLY Leader will receive the message, regardless of activation order. -In the second example, ONLY Wingman will receive the message, regardless of activation order. -In the third example, both Leader and Wingman will receive their own custom messages, regardless of activation order. Now, please provide a logical explanation for this, assuming I'm wrong... If you did it in MP with both slots occupied then both clients will see the message. I don't see how having both clients spawned would change the behavior I already described. PS: I don't like being called a liar or a fool, Grimes, that's why I'm insisting... I'm sure you understand.Leader gets message_Wingman is ignored.mizWingman gets message_Leader is ignored.mizLeader and Wingman get their own messages.miz Edited August 28, 2018 by Hardcard [sIGPIC][/sIGPIC]
Grimes Posted August 29, 2018 Posted August 29, 2018 I debated how to answer this because of your response. For one reason or another you seemed to take it as a personal insult when no such comment was made. In fact the only depreciation to your knowledge was self made with the "moose noob" comment. Additionally you question if I had actually tested it, without you testing it either. So here is how I can be so sure. Scientific Response with both clients spawned. Which I had to change the units to Su-25T because the server I have access to does not have FC3 on its account. I invite you to test it in MP to confirm the result. I don't see how having both clients spawned would change the behavior I already described. Detailed response: I've attached a mission that does the exact same thing as that møøse code with the exact same result. The only difference is that I used trigger.action.outText instead of trigger.action.outTextForGroup. All it does is check for the presence of a given unit object and if it returns a playerName. If that check is true, then it will display the message associated with each unit. There are 4 possible outcomes. 1. No message is displayed when no units are alive. 2. Unique Message 1 is displayed when client 1 is alive 3. Unique Message 2 is displayed when client 2 is alive 4. Both messages are displayed when both clients are alive. if Unit.getByName('J11A_1') and Unit.getByName('J11A_1'):getPlayerName() then trigger.action.outText('Unique Message 1', 10) end if Unit.getByName('J11A_2') and Unit.getByName('J11A_2'):getPlayerName() then trigger.action.outText('Unique Message 2', 10) end An important thing to realize is that all scripting libraries out there are limited to the same functionality of the Scripting Engine. The scripts that people release all repackage the scripting engine functions into something specific or useful.Leader and Wingman get their own messages in only 600 fewer kilobytes.miz The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Zayets Posted August 29, 2018 Posted August 29, 2018 An important thing to realize is that all scripting libraries out there are limited to the same functionality of the Scripting Engine. The scripts that people release all repackage the scripting engine functions into something specific or useful. This! There's nothing a script library can do and SSE not. [sIGPIC]OK[/sIGPIC]
Hardcard Posted August 30, 2018 Posted August 30, 2018 (edited) Hi Grimes. Let's see if we can cool this down. For one reason or another you seemed to take it as a personal insult when no such comment was made. In fact the only depreciation to your knowledge was self made with the "moose noob" comment. Additionally you question if I had actually tested it, without you testing it either. I took it rather personally because, out of the blue, you quoted my response to the OP (which didn't involve you in any way) and then dismissed my script example without even explaining. Call me crazy, but it's not that hard to take that kind of thing "personally" over the internet. It wouldn't be the first time I meet a major ahole online (I'm not saying you are, I actually admire your work with the wiki and helpful comments in this forum, that's why I was cool in my first response. After your second dismissal, however, I got pissed, not gonna lie). Keep in mind that I was only contemplating SP environment, where the script...works? That's why your dismissal didn't make any sense to me. I mean, put yourself in my shoes. You have a script that seems to successfully target individual clients in SP, then you see a guy over the ED forums who's asking for a script that does precisely this. You make the effort to create a script example for him, then another guy comes around and shits on it without even explaining, when the script actually seems to work when you test it... What gives? :huh: I don't think it's that hard to understand, tbh. Anyway, the thing is that I hadn't tested the script in multiplayer because I have no way of doing that. I had only tested it in SP, which was its intended usage (to my mind), and it worked all the time, so I didn't get why you were so keen on denying it. To anyone else reading the thread, it would've seemed that I was lying or something, and I didn't like that one bit, since the script freaking worked in SP, I wasn't making it up. I can see your point now, MP is tricky, I didn't know that, I was wrong to get pissed, I apologize for that. Although, in my defence, I'll say that you saw that the script works as I described in SP, and yet you decided to ignore that and focus on the fact that it doesn't work in MP. :( Also, I just said that I don't like being called a liar or a fool, which is true, and your posts seemed to point towards that direction (albeit accidentally, I'm sure). You are free to post dismissive one liners without giving any real explanation, of course, but it might lead to misunderstanding, like it happened here. Again, I apologize for getting pissed at you Grimes, please don't take it badly. PS: I can depreciate myself as much as I want, but when somebody else does it, that's different. It's like a white guy using the "n" word to refer to a black person, it just sounds wrong. Edited August 30, 2018 by Hardcard [sIGPIC][/sIGPIC]
Grimes Posted August 30, 2018 Posted August 30, 2018 This is a tad silly. I simply responded to elaborate on what that moose function is actually doing. Which is why I posted the code it uses with the exact function call I said it used via trigger.action.outTextForGroup. Your argument over it functioning in single player and not something else is more or less arguing over the different ways to skin a cat. For starters the actual outText function you use is kind of irrelevant because in single player by definition only the player will see the message. AI get nothing out of a sound or text displayed for them. In the instance of playing a multiplayer mission in singleplayer with multiple aircraft as a choice, it is simply a matter of detecting which aircraft is used to display whatever customized message you have. In multiplayer to achieve the "toUnit" functionality you have to have each client as their own group because trigger.action.outTextForUnit isn't currently a function. I sure hope it gets added someday though. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Hardcard Posted August 30, 2018 Posted August 30, 2018 (edited) This is a tad silly. That's the kind of thing that leads to misunderstandings. Didn't I just apologize to you? Twice? Yet you opened with a hostile statement. :huh: Your argument over it functioning in single player and not something else is more or less arguing over the different ways to skin a cat. I was simply showing the OP how to target specific clients in SP. I did, you didn't seem to like it, I honestly didn't get what you meant, I misunderstood, I admitted it, I apologized. End of the story. I didn't come to this thread to start an argument with you, Grimes, believe it or not. And I don't like where this is going, tbh. For starters the actual outText function you use is kind of irrelevant because in single player by definition only the player will see the message. AI get nothing out of a sound or text displayed for them. In the instance of playing a multiplayer mission in singleplayer with multiple aircraft as a choice, it is simply a matter of detecting which aircraft is used to display whatever customized message you have. Again, hostile attitude... that doesn't help clarify anything, mate. I already know that the AI won't receive messages, only the player... (Btw, that kind of insinuation could be very easily understood as: "See, Hardcard? You're a fool!", in case you didn't realize). Now, you said that the method is irrelevant in SP, I honestly don't see it that way, precisely because it's meant to be used in the kind of instance you described: SP mission with multiple aircraft choices for the player. In that scenario, sure, you can always create single client groups and just target those (which is what I do, believe it or not). But just imagine that I wanted to create a separate set of messages for client group leaders and their wingmen (the mission would allow the player to choose between leader or wingman slots). The AI would take control of the clients not chosen by the player (I'm assuming this can be done, btw). What then? Would the script be irrelevant in that case? Well, that's the kind of scenario I had in mind when I posted it for the OP. Now, if the AI can't take control of the remaining clients in a given group, then sure, I guess the script is pointless :megalol: (but note that I'm not aware of that, since I've had the AI take control of abandoned client slots just a couple of months ago). In multiplayer to achieve the "toUnit" functionality you have to have each client as their own group because trigger.action.outTextForUnit isn't currently a function. I sure hope it gets added someday though. I didn't know that, thanks for explaining. I will definitely take your word for it, since you obviously know far more scripting stuff than I do. The problem before was that your dismissal didn't seem to match the results I was getting in my SP tests. That's the only reason I doubted you, really. PS: Please don't be hostile in any further responses, THAT would be pointless. I already apologized, and in fact, I apologize again. If I'm wrong about something (which I'm sure it'll happen many times), you can always explain the why and the how without the need for any kind of hostility. A good explanation is often all it takes. I do thank you for pointing out the limitations of the script, I just wish you would've done it differently, is all. Edited August 30, 2018 by Hardcard [sIGPIC][/sIGPIC]
feefifofum Posted August 30, 2018 Posted August 30, 2018 Yeah, you can't fly wing for an AI lead. There's literally no reason for a player wingman slot outside of a multiplayer environment which is where most of this confusion is coming from. You know what that they about assuming things. ;) You can use 3rd party AI balancer scripts to replace entire flights (or single-ship groups) but not individual members of a group. At this time, there's not much reason for a player wingman slot inside of the multiplayer environment either because a number of things exhibit limited functionality especially when it comes to 3rd party scripts. No one's calling you a liar or a fool, but kinda seems like you're expecting folks to walk on eggshells here bud instead of just saying "that doesn't work." THE GEORGIAN WAR - OFFICIAL F-15C DLC
Zayets Posted August 31, 2018 Posted August 31, 2018 So, to recap, you can't send text/sound to individual units just yet. You can simulate something close by having a group containing one unit only. I can see why ED did not bothered to add (just yet) a text/sound to unit. Once, if you fly in a group chatting on the same freq then you probably want to hear what happens within the group. Secondly, it is the frequency which should matter the most. Someone tunes into that frequency and T/R on it. See the AWACS or tankers. If you are tuned on that particular frequency you will hear all the chatter even if you are part of a different group. Thirdly, as in real life, you can call the unit you are adressing to even now if you want. Is just that the message is targeting the group (or frequency) that particular unit belongs to. Message to unit would be a nice addition but I am not missing it a lot right now. [sIGPIC]OK[/sIGPIC]
Hardcard Posted September 1, 2018 Posted September 1, 2018 @feefifofum Right, I see the problem now, I totally thought this was possible, my bad. (I'll try it anyway, just for the heck of it, not that I don't trust what you're saying :thumbup:) As for me expecting people to walk on eggshells, it's not that. I'm fine with other people telling me how I'm wrong and why... The problem wasn't what Grimes said, the problem was how he said it (dismissive single liners just don't work for noobs like myself :cry:. They are likely to cause confusion and not clarify much). Now I understand that Grimes was thinking about MP environment only, since he already knew that doing this in SP is pointless... I just didn't know. That's why I think it's always better when things are explained, rather than "thrown around". I would've said something like: "That might seem to work in SP, but here's what happens when you try to run that kind of thing in MP...(examples) Also, your test mission has two clients in the same group, why would you want to do that, exactly?". I don't know, maybe it's just the way my brain works...(or doesn't, :doh:) Thanks to you all guys for your clarifications, including Grimes, of course. [sIGPIC][/sIGPIC]
Griefhard Posted September 4, 2018 Author Posted September 4, 2018 I found it a very interesting conversation, anyways. I see that there seem to be ways of achieving it, but it is usually rarely used. Although I see that there would be a need for that. I can tell you what I wanted to do and how I did it then. I was building a very small campagne for myself and a couple of friends. We wanted to fly the F-18. And what I thought would be cool was: When starting for the aircraft carrier it would be awesome, if everyone hears the TopGun Soundtrack, just after launch from the catapult. Just like in the opening scene of TopGun. Just for fun and a little surprise. Of course everyone needed to hear his individual music piece, just when he started his jet and not when the flight leader took off. I usually arrange Flights in Groups. Even with no AI. I group A/A and A/G units to easier give them waypoints and triggers and stuff. Also it „feels right“ if the same tasks are in the same group. Nevertheless. Since I only needed this task as a surprise in the first mission as of yet, I created the easiest way (for me) different groups for each player. Then I could give each group a trigger to play sound, when the aircraft goes faster than 80 knots. In the following missions I arranged the flights again as groups with no individual sounds. The sounds for successful Mission or whatever can be transmitted as sound to coalition for example as a radio transmission or whatever, telling the „blue“ that the mission is accomplished. For future projects, I‘d say it would be nice, if we could get a funktion „sound to unit“ in the editor. I thank you for your input and the interesting discussion about the lua script language.
Hardcard Posted September 6, 2018 Posted September 6, 2018 Of course everyone needed to hear his individual music piece, just when he started his jet and not when the flight leader took off. I usually arrange Flights in Groups. Even with no AI. I group A/A and A/G units to easier give them waypoints and triggers and stuff. Also it „feels right“ if the same tasks are in the same group. Nevertheless. Since I only needed this task as a surprise in the first mission as of yet, I created the easiest way (for me) different groups for each player. Then I could give each group a trigger to play sound, when the aircraft goes faster than 80 knots. For future projects, I‘d say it would be nice, if we could get a funktion „sound to unit“ in the editor. Yep, that's the way I do it in MOOSE. Just create a separate group for each client and target it every time you want to send text and sound messages to that specific client. Btw, you can use scripts to subscribe groups to certain events in game (EngineStart events, for instance). Now, there are still ways of accomplishing the kind of stuff you described without having to put all clients in a single group. You can create sets of "single-client groups", which will allow you to target them all at once, so to speak. Alternatively, you can also set stuff at coalition level (as you already did). [sIGPIC][/sIGPIC]
Recommended Posts