Home   Help Search Login Register  

Author Topic: My First Step To Multiplayer Mission Editing  (Read 1466 times)

0 Members and 1 Guest are viewing this topic.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
My First Step To Multiplayer Mission Editing
« on: 22 Jun 2010, 17:39:44 »
I am now trying to make First Strike a multiplayer mission.

And i am trying to add Who killed Who messages in the game.

Trigger  : Anyone,Present
Radius = 500
{_x addeventhandler ["Killed",{_this exec "eh_killed.sqs"}] } foreach thislist

eh_killed.sqs
Code: [Select]
_man=_this select 0

_killer=_this select 1

;show who killed who
?_killer!=_man : message = "_killer sidechat format [""%1 killed %2"",name _killer,name _man]"

;show the following if the unit has killed by himself
?_killer==_man : message = "_killer sidechat format [""%1 was killed accidentally"",name _killer]"

publicvariable "message"
call message
exit

I run the game in a single computer,two instances of ofp,one is the host and other the client.
The messages only show up in the host computer!


SO i tried the following and the result is the same!


Trigger  : Anyone,Present
Radius = 500
Code: [Select]
{_x addeventhandler ["Killed",{hint format ["%1 killed %2",name (_this select 1),name (_this select 0)}] } foreach thislist

Any idea on this ?

The main problem is how do i transmit messages to ALL computers including the server (IF its a host ,not dedi)

I found the use of a gamelogic , but it is impossible in ofp since i cannot use
setvehicleinit and processinitcommands  in OFP

Regards,
Haroon1992
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: My First Step To Multiplayer Mission Editing
« Reply #1 on: 22 Jun 2010, 18:27:10 »
Hi haroon.

The problem is that, as the biki says, "killed" and "hit" eventhandlers are executed where the unit to which they are added is local.

Also, in OFP it was not possible to transmit strings using publicvariable, so I'm surprised you haven't gotten an error from this:

Code: [Select]
?_killer!=_man : message = "_killer sidechat format [""%1 killed %2"",name _killer,name _man]"
?_killer==_man : message = "_killer sidechat format [""%1 was killed accidentally"",name _killer]"

publicvariable "message"

Quote
I found the use of a gamelogic , but it is impossible in ofp since i cannot use
setvehicleinit and processinitcommands  in OFP

Well according to the biki, the initialization of units created with createUnit is executed on all computers. So, try something like this:

Code: [Select]
_message = format [{%1 killed by %2}, _killed, _killer]
_code = format [{player sideChat {%1}},_message]
"Logic" createUnit [someplace, specialLogicGroup,_code]

Another way is to set up a trigger or looping script that will check to see if a message has been sent, then display the text for each player.

Code: [Select]
#re
killed = objNull
killer = objNull

#ch
~0.1
? killed == killed : goto "ch"

@(killed == killed)
player sideChat format ["%1 killed by %2",name killed, name killer]
goto "re"

And have another script (the "transmitter", if you will) send messages when people are killed:

Code: [Select]
;execute from an eventhandler
killed = _this select 0
killer = _this select 1

publicVariable "killed";publicVariable "killer"
exit

This will probably be less efficient and reliable than the gameLogic creation hack described above, though.
« Last Edit: 22 Jun 2010, 18:48:48 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: My First Step To Multiplayer Mission Editing
« Reply #2 on: 23 Jun 2010, 17:01:41 »
EDIT :
NVM.

I experimented with triggers yesterday, and found that there is no need to use PV command.
Not tested it with WPs though.

And the gamelogics i create must have a valid group, so i grouped them to the 'server' gamelogic  :cool2:
I think I am ready for a basic MP Mission...



Regards,
Haroon1992
« Last Edit: 25 Jun 2010, 04:14:26 by haroon1992 »
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(