L39Tom Posted August 3, 2018 Posted August 3, 2018 Hi everone, I try to make some poor scripts using Moose.It works likely in making some missions in singleplayer, but I have no glue to translate it to a multiplayer mission. Lets give you an example (trying to do a kind ol LSO-script) function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end ac = 0.06102 --glideslope a1 = 0.07406 --high a2 = 0.06530 --GlideslopeUp a3 = 0.05664 --GlideslopeDpwn a4 = 0.04800 --low carrierdeck = 20.73 --m _SETTINGS:SetImperial() player1name = "Voodoo 311" carrier = GROUP:FindByName( "Stennis" ) player1 = GROUP:FindByName( player1name ) -- Carrier Degrees stennis = carrier:GetCoordinate() brc = carrier:GetHeading() if brc <= 8 then fb = brc + 172 else fb = brc - 188 end -- Player 1 Data player1coor = player1:GetCoordinate() player1vec3 = player1coor:GetVec3() player1alt = round (player1vec3.y * 0.00328) playerbearing = round (stennis:GetAngleDegrees(stennis:GetDirectionVec3( player1coor))) player1dist = round (stennis:Get2DDistance(player1:GetCoordinate()),2) player1dist = round (player1dist / 1852) MESSAGE:NewType( " FB = ".. fb .." Player at ".. playerbearing .."°", MESSAGE.Type.Information ):ToAll() angleO = fb + 5 angleU = fb - 5 angleOc = fb + 0.25 angleUc = fb - 0.25 Messager = SCHEDULER:New( nil, function() player1coor = player1:GetCoordinate() player1vec3 = player1coor:GetVec3() player1alt = player1vec3.y - carrierdeck stennis = carrier:GetCoordinate() brcwire = brc - 175 wire = stennis:Translate(82,brcwire) player1dist = wire:Get2DDistance(player1:GetCoordinate()) playerbearing = round (wire:GetAngleDegrees(wire:GetDirectionVec3( player1coor))) quotient = player1alt/player1dist winkel= math.atan(quotient) if winkel < a1 and winkel >= a2 then MESSAGE:NewType( "You are to high ", MESSAGE.Type.Information ):ToAll() elseif winkel < a2 and winkel >= a3 then MESSAGE:NewType( "*** On Glideslope ", MESSAGE.Type.Information ):ToAll() elseif winkel < a3 and winkel >= a4 then MESSAGE:NewType( "Power ", MESSAGE.Type.Information ):ToAll() else end if playerbearing > angleUc and playerbearing < angleOc then MESSAGE:NewType( " On Glideslope ", MESSAGE.Type.Information ):ToAll() elseif playerbearing >= angleU and playerbearing <= angleUc then MESSAGE:NewType( " Come Left ", MESSAGE.Type.Information ):ToAll() elseif playerbearing <= angleO and playerbearing >= angleOc then MESSAGE:NewType( " Come Right ", MESSAGE.Type.Information ):ToAll() else end end, {}, 1, 4 ) Sorry for this poor script, but it may just be an example. Can someone give me an idea to rewrite it for - lets say - four clients. thanks Tom
L39Tom Posted August 8, 2018 Author Posted August 8, 2018 No one? Come on, just a clue that I can finish that script.
fargo007 Posted August 9, 2018 Posted August 9, 2018 (edited) I just got some help here, so I'll try and pass that forward. It seems what you want to do is define a set of clients, and then perform a set of operations per client, where right now it's locked into a singleton model. The SET class does this, specifically SET_CLIENT. You define a filterprefix that includes the clients (by name, e.g.) and then you get a callback function for each matched client that you can use to accomplish what you are after. SET_CLIENT:ForEachClient(IteratorFunction, ...) SET_CLIENT:ForEachClientInZone(ZoneObject, IteratorFunction, ...) https://flightcontrol-master.github.io/MOOSE_DOCS/Documentation/Set.html##(SET_CLIENT).ForEachClient Download the MOOSE example missions. There are some examples of this being used in there. Edited August 9, 2018 by fargo007 1 Have fun. Don't suck. Kill bad guys. https://discord.gg/blacksharkden/
L39Tom Posted August 11, 2018 Author Posted August 11, 2018 Thanks for your help. I will give it a try. Seems not easy to me.:huh:
Recommended Posts