How to make it multiplayer usable (Moose) - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 08-03-2018, 09:28 AM   #1
L39Tom
Junior Member
 
Join Date: Aug 2016
Posts: 29
Default How to make it multiplayer usable (Moose)

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)


Quote:
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.0032
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 is offline   Reply With Quote
Old 08-08-2018, 09:58 PM   #2
L39Tom
Junior Member
 
Join Date: Aug 2016
Posts: 29
Default

No one? Come on, just a clue that I can finish that script.
L39Tom is offline   Reply With Quote
Old 08-09-2018, 05:39 AM   #3
fargo007
Member
 
Join Date: Jul 2017
Posts: 497
Default

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.


Quote:
SET_CLIENT:ForEachClient(IteratorFunction, ...)

SET_CLIENT:ForEachClientInZone(ZoneObject, IteratorFunction, ...)
https://flightcontrol-master.github.....ForEachClient

Download the MOOSE example missions. There are some examples of this being used in there.
__________________



You dig rotorcraft? Training, Quals, Missions, & FUN. Ask me about joining the Black Sharks!

Last edited by fargo007; 08-09-2018 at 05:42 AM.
fargo007 is offline   Reply With Quote
Old 08-11-2018, 12:15 PM   #4
L39Tom
Junior Member
 
Join Date: Aug 2016
Posts: 29
Default

Thanks for your help. I will give it a try. Seems not easy to me.
L39Tom is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 12:31 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.