Jump to content
Sign in to follow this  
-)a)(

Solution: local radio

Recommended Posts

Hi,

you always get angry with the radio-triggers which always act global?

Try this:

Create a Radio-Trigger (Alpha):

- Repeatable

- Countdown: 0

- Condition: this && !radio_alpha

- Activation : hint "Huhu"; radio_alpha = true; publicvariable "radio_alpha"

Create a 2nd Radio-Trigger (Alpha!!!):

- Repeatable

- Countdown: 2

- Condition: this

- Activation : radio_alpha = false

The variable "radio-alpha" must be defined as "false" in the "init.sqs".

This radio-trigger only act local, not global! It works fine, but it's not fully tested. So test it, and tell us your experiences! It was a chance accidental, that i found this solution. I used it in my map "Battlefield 1985".

Greetz

Dax

P.S.: Sorry, for my english, but i did my best!

Share this post


Link to post
Share on other sites

Yeah that's a good idea but it relies on the principle that the Radio Alpha action will be transferred and processed after the PublicVariable call. I'm not sure, but it may very well be that this will work reliably. smile_o.gif

EDIT: Oh, now I remember something like this from a whiel ago in our research on CoC, it didn't turn out too well, so hopefully it's not the same concept.

Share this post


Link to post
Share on other sites

I didn't got a view on the CoC-Stuff, but maybe it's the same thing, i don't know. It was a chance hit, i did not want a local radio! :o)

Share this post


Link to post
Share on other sites
smile_o.gif No problem. I'm just trying to see if I can remember, we lost our old forum so....

Share this post


Link to post
Share on other sites

Actually I totally forgot about htis thread, Spinor had a look at this and he confirmed it worked well and found no failures. biggrin_o.gif

Share this post


Link to post
Share on other sites

Are you saying that if you did it this way, a player in a MP game could use Radio Alpha, and it would only activate on his machine?

could anyone give some examples of what would be possible with this?

Im still a pretty novice OFP scripter but have encountered numerous problems when it comes to Radio triggers and multiplayer - if someone can describe what can be done with this using examples, it might help me with some of my problems smile_o.gif

Share this post


Link to post
Share on other sites

I'm hoping that this means that the next CoC version will be able to support 2 commanders in multiplayer smile_o.gif

Share this post


Link to post
Share on other sites
I'm hoping that this means that the next CoC version will be able to support 2 commanders in multiplayer smile_o.gif

That is the plan. Yes. smile_o.gif

However, the radio workaround here is not the reason we will be able to do this, the main reasons are dialogs and onMapSingleClick which BIS was kind enough to add for such projects. smile_o.gif

You can get check out our forums if you wish to gain more information about our projects.

Share this post


Link to post
Share on other sites
Guest jacobaby

@ the original poster;

Im guessing, but maybe You can keep a radio trigger local to any unit you desire.

Example;

Create Radio Alpha;

Condition: local UNITNAME && this

That works for other checks.......

Share this post


Link to post
Share on other sites

@jacobaby

I've already been playing around with what you suggested

in the last post.

I've tried to execute a dialogue by radio-call, only on a

single client.

I've tried the local unit AND whatever

I've tried using: xxx exec "anyscript.sqs"

script ran everywhere

I've tried tru'ing a boolean (not using publicVariable)

script ran everywhere

I've tried sync'ing a gamelogic's waypoints to

the radio trigger, and let then start the gamelogic

a script from inside one of it's waypoints

script ran everywhere

The only thing i haven't tried yet is:

the workaround from the first post

I'm gonna mess around with it then i think

nice find if it works ])a)( (whatever this name means  biggrin_o.gif )

:edit - hang on ])a)(

does your name maybe mean: DaX? tounge_o.gif

~S~ CD

Share this post


Link to post
Share on other sites
I'm hoping that this means that the next CoC version will be able to support 2 commanders in multiplayer  smile_o.gif

That is the plan. Yes. smile_o.gif  

However, the radio workaround here is not the reason we will be able to do this, the main reasons are dialogs and onMapSingleClick which BIS was kind enough to add for such projects.  smile_o.gif

You can get check out our forums if you wish to gain more information about our projects.

I'm one of those countless 'guests' that lurk around your forum regularly biggrin_o.gif

I'm actually very intersted in your progress, and I'm thrilled to find some post by you or Dinger. The UA progress reports have been especially nice. That reminds me, though. Do you update the developer's diary? I remember reading it, but it didn't change for a long while so I stopped checking. Definitely looking forward to it though smile_o.gif

Share this post


Link to post
Share on other sites

Yes, it means Dax. ])a)( is an older nick. Now i'm also known as Duke Dax.

I tested my idea on my map "Battlefield 1985" and it works fine! And it's the only way i know, to make a radio-trigger local.

"local UNITNAME && this" <--- works only if you want one specific person is able to use the radio

But everyone should be able to use it!

Share this post


Link to post
Share on other sites

bn880, maybe i have another idea for you.

A friend asked how he can synchronize vehicle-textures in MP. He made an addon-car which has random textures (they are similar expect the color). The textures are set by using "setObjectTexture". The problem is that the command is a local command!

He wanted the cars to have the same color on all clients. So he needed a way to do this, without using specific variables (like CAR1_COLOR,CAR2_COLOR,...) for it, because he wanted to integrate the script for it into the addon. An he wanted that the user can place as many cars as he want on the map, without handling with variables.

So i thought about a way making variables which belongs to the placed car. First i tried it like this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call Format ["%1_Colour = _colorarray select Random (3)",_car]

, but because of the spaces in vehicle-id, it did not work.

My new idea:

For each car starts a seperate script on the server.

The server generates a name for the variable:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_random = Random (10000)

_random = _random - (_random mod 1)

call Format ["Objekt_%1 = _car",_random]

_random2 = Random (3)

_random2 = _random2 - (_random2 mod 1)

call Format ["Texture_%1 = %2",_random,_random2]

For example the names of the variables of the first car is "Objekt_5324" and "Texture_5324"

On each client starts a script for each car seperate, which is looking in which "Objekt_XXXXX"-Variable is the ID of the car. When the script found the car in variable "Objekt_5324", it knows that it will find the correct texture-number for the texture in "Texture_5324".

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_i = 0

while "call Format [""Objekt_%1"",_i] != _car" do {_i=_i+1}

call Format ["Texture_Wert = Texture_%1",_i]

(The "while"-code above is untested, if it don't work you can use a loop instead.)

Because of the range from 1-10000 of numbers, it's nearly impossible that the variablenames will occur double.

It's all untested what i wrote, but it should work in this way. You did a great work with your CoC, and i hope you can use it. Perhaps you found a similar way. smile_o.gif

Greetz

Duke Dax

Share this post


Link to post
Share on other sites

Thanks Dax, but actually rather than using a semi-dangerous and cpu intensive random number generation, a good method is to use sequential numbers by creating a "defined" function. (checking if a variable is used yet)

For example this is one of the defined functions we use at CoC <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_variable","_exists","_tostring"];

_variable=_this;

_exists=false;

if(call _variable in [call _variable])then{

_tostring=format["%1",call _variable];

if(_tostring=="false" || _tostring == "true" || _tostring == "<null-group>" || _tostring == "<null-object>")then{

_exists=true;

}else{

if(call _variable == call _variable) then {

_exists = true;

};

};

}else{_exists = true;};

_exists

Then in your addon (server SQF) you can do

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_i=0;

WHILE {format ["Object_%1",_i] call fDefined} do {_i=_i+1;};

call format ["Object_%1 = _car",_i];

call format ["Texture_%1 = _texture",_i]; // just example

then on all the clients you could do (SQS)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_i=0;

#SEARCH

@format ["Object_%1",_i] call fDefined

?call format ["Object_%1",_i] == _car:goto "GOTINDEX"

_i=_i+1;

goto "SEARCH"

#GOTINDEX

you got your object reference from _i

smile_o.gif This should be quite bulletproof. Actually passing objects is the basis for how the CoC Network Services connect all nodes reliably, so you are on the same wavelength for sure.

Have fun

EDIT: I forgot to add, make sure to TAG your Object_% and Texture_% variables so no other addons conflict. EX: DAX_Object_%1. Anyway thanks for your idea but this one we already found. biggrin_o.gif

Share this post


Link to post
Share on other sites
I'm one of those countless 'guests' that lurk around your forum regularly biggrin_o.gif

I'm actually very intersted in your progress, and I'm thrilled to find some post by you or Dinger. The UA progress reports have been especially nice. That reminds me, though. Do you update the developer's diary? I remember reading it, but it didn't change for a long while so I stopped checking. Definitely looking forward to it though smile_o.gif

Ok, the only problem is I don't remember any Diary, and neither does Dinger. biggrin_o.gif I'm sure if you say there was one we had one, but it probably remains in the digital rubble that was left of our old forums. (kind of a forum 9/11 happened to it) tounge_o.gif

We are considering a developers diary now though. smile_o.gif

Share this post


Link to post
Share on other sites
I'm one of those countless 'guests' that lurk around your forum regularly  biggrin_o.gif

I'm actually very intersted in your progress, and I'm thrilled to find some post by you or Dinger.  The UA progress reports have been especially nice.  That reminds me, though.  Do you update the developer's diary?  I remember reading it, but it didn't change for a long while so I stopped checking.  Definitely looking forward to it though  smile_o.gif

Ok, the only problem is I don't remember any Diary, and neither does Dinger.  biggrin_o.gif   I'm sure if you say there was one we had one, but it probably remains in the digital rubble that was left of our old forums. (kind of a forum 9/11 happened to it)  tounge_o.gif

We are considering a developers diary now though.  smile_o.gif

Developer's Diary

It's there already tounge_o.gif

I remember when the forums went down. I may have even been registered before then, but I didn't bother to afterwards.

Share this post


Link to post
Share on other sites

Very good solution.

First i had nearly a similar idea, because it's the best way to check if the variable already exist or not. But i was afraid because of the fact that the scripts will start at the same time. Assuming that ten cars were place on map, then the script starts ten times on server. I was afraid of that OFP will mess the variables. Script for Car1 want to use name "Variable1", the script for Car2 wants to use it too, but has not recognized yet that this name is reserved for Car1 and overwrites the content. Script for Car1 progressed meanwhile and did not recognized that.

What happens then? Can you definite exclude such errors?

Share this post


Link to post
Share on other sites

Heheh. I never saw that page before. Dang. Looks like one tail doesn't know which way the other is wagging.

biggrin_o.gif

Share this post


Link to post
Share on other sites
)a)( @ Aug. 28 2003,20:39)]Very good solution.

First i had nearly a similar idea, because it's the best way to check if the variable already exist or not. But i was afraid because of the fact that the scripts will start at the same time. Assuming that ten cars were place on map, then the script starts ten times on server. I was afraid of that OFP will mess the variables. Script for Car1 want to use name "Variable1", the script for Car2 wants to use it too, but has not recognized yet that this name is reserved for Car1 and overwrites the content. Script for Car1 progressed meanwhile and did not recognized that.

What happens then? Can you definite exclude such errors?

Actually that is not a problem here because the code that actually assigns the vaiables is called as an SQF, not execed as an SQS. SQF files will run basically as one block of execution before OFP goes and switches to the next one. That is unless your SQF is a while loop that exceeds 9999 repetitions.

As soon as the while loop in the SQF finds a free variable it will assign a value to it, which is guaranteed to happen before any other script is executed and true gamestate is updated.

If you really want to make solid scripts you should have this in every while loop also:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_x=0;

while "condition AND _x <9999" do {_x=_x+1;

code

};

if(_x >=10000) then {error handle};

however this is mostly useful when your loop is being debugged or is expected o fail somehow. smile_o.gif

Share this post


Link to post
Share on other sites

Yes you're right, unfortunenately i 've failed to notice that the code which is running on the server is a function. smile_o.gif

Thx, for this solution.

Share this post


Link to post
Share on other sites

Yep, I figured that, but I wrote the big message for others that may read it later on, and I had absolutely nothing to do also. biggrin_o.gif

Share this post


Link to post
Share on other sites

Question.....it seems like there is no Timeout for a Radio trigger.  I set Timeout to 2 like you suggested, but noticed it fired right away.

What's going on here?

Is this still the only/best way to run a radio command on the players machine that used the radio and not on everyone's machine?

EDIT: Wow I just noticed Radio triggers don't run On Deactivation either.  Weird.

EDIT2: Now I'm really confused.  I just looked at your mission and you don't have a second radio trigger.  You just have a None with Condition set to "radio_alpha".  So how does this work??  Player runs radio.  Their trigger fires first.  It says "hint 'Huhu'" and then sends out a "radio_alpha = true", which would prohibit the trigger from firing....this is assuming the clients receive the radio_alpha = true before their radio trigger syncs up (goes off)???

Doolittle

Share this post


Link to post
Share on other sites

Bump...

Does anyone know how to do a local-only radio trigger?

This is the first time I've ever bumped a message. Ouch.

Share this post


Link to post
Share on other sites

Errr... you do realize that you have dug up a 2 year-old thread, right? Personally, I have no idea how to do this, so I can't help you though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×