OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: haroon1992 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
_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{_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
-
Hi haroon.
The problem is that, as the biki says (http://community.bistudio.com/wiki/addEventHandler), "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, (http://community.bistudio.com/wiki/publicVariable) so I'm surprised you haven't gotten an error from this:
?_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"
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 (http://community.bistudio.com/wiki/createUnit), the initialization of units created with createUnit is executed on all computers. So, try something like this:
_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.
#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:
;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.
-
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