Home   Help Search Login Register  

Author Topic: setting radio messages from server  (Read 2094 times)

0 Members and 1 Guest are viewing this topic.

ido_

  • Guest
setting radio messages from server
« on: 21 Sep 2006, 12:54:39 »
I have a pretty heavy script that I run so a heli will follow a runaway car, I want it to run on the server so it wont affect frames on the players but on the other hand I need the script to set a new radio message for the leader when it begins and remove the radio message when it ends.

the begining is easy by making the setradiomsg before the server check but how do I remove it ?

edit: another two little questions, doStop and CommandMove, global or local ?

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: setting radio messages from server
« Reply #1 on: 21 Sep 2006, 18:41:41 »
1)You need a client side script to run. Call it rspeak.sqs
Code: [Select]
_unit = _this select 0
_msgnumber = _this select 1
_msg = ["Hardy harhar","You suck","No thanks, I don't like chicken"]
_unit groupChat _msg select _msgnumber
exit

2)Put in your in your init.sqs a variable for the speaker, and a variable for the message number.
Code: [Select]
rMsgSpeaker = ObjNull
rMsgNumber = -1

In your script add the lines:
Code: [Select]
rMsgSpeaker = unit you want to send message
publicVariable "rMsgSpeaker"
rMsgNumber = index of message in array
publicVariable "rMsgNumber"

Now put a repeatedly trigger on your map with this as the condition:
Code: [Select]
rMsgNumber > -1and this in its onActivation:
Code: [Select]
[rMsgSpeaker,rMsgNumber] exec "rspeak.sqs"; rMsgNumber = -1
OFP can not send strings and arrays between machines in MP, so if you want to generate a dynamic message you must add the code to the rspeak.sqs to construct the message on each client.
e.g. rspeak.sqs
Code: [Select]
_unit = _this select 0
_msgnumber = _this select 1
_msg = ["We have lost target", format ["We are %1 metres from target.", heli distance car], format["Target destroyed at position %1, at time %2", position heli, daytime ]]
_unit groupChat _msg select _msgnumber
exit


Your other option is to use Chain of Commands' Network Services 2.0 i.e. CoC_NS2

urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: setting radio messages from server
« Reply #2 on: 21 Sep 2006, 18:45:07 »
Those commands must be called on the machine that owns the group.  If it is an AI group they must be called on the server. If it is a group of AI under a player's command, they must be called on that player's machine. You can safely call the commands on all machines i.e server and all clients. The commands will be ignored by the machines that do not own the group.


edit: I've just read on the Bis Wiki pages that these commands can be called on any machine for any unit and will still work. However, that is not true for most of the other commands of this type, which are local and follow the rules I originally posted. 
« Last Edit: 21 Sep 2006, 19:36:01 by Mr.Peanut »
urp!

ido_

  • Guest
Re: setting radio messages from server
« Reply #3 on: 21 Sep 2006, 21:37:53 »
thanks for the reply I don't think you understood my first question,
lets say the heli starts a car, from now on it follows the car and the players can request update on the car's location with the radion meaning: 5 setRadioMsg "Ask for Update" and if the heli looses the car I need the command 5 setRadioMsg "NULL". I need it to run on all of the clients computers. only thing I could think of is creating a trigger with a boolean variable in its condition, on activation make it do the first command and on deactivation make it do the second one but is there a ways to make this command run on all computers from withing the script that runs only on the server ?

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: setting radio messages from server
« Reply #4 on: 22 Sep 2006, 14:07:37 »
Nope.

1) You can have the server script PV the booleans and use triggers to change the radio.

2) You can have the server script PV the booleans and use a client side script to change the radio. The client side script would simply wait for the boolean to change and then change the radio accordingly.


The only reason to use 2) is that with a client side script you can set the delay longer than 0.2 seconds, which is how often a trigger or the @ command poll.  You could set the delay to 1 or 2 seconds.  This is really only a performance issue for very long scripts or if you have many booleans, which does not seem to be your case so I would stick with 1).
« Last Edit: 23 Sep 2006, 15:59:00 by Mr.Peanut »
urp!

ido_

  • Guest
Re: setting radio messages from server
« Reply #5 on: 23 Sep 2006, 09:58:08 »
thanx