Jump to content
Sign in to follow this  
somethingcool

OnMapSingleClick moving units around the map

Recommended Posts

Hi,

Ive had a search through the forums for this problem and seen a couple of items that kinda apply but im still a bit stuck. I am trying to move a group of units (called support) around the map using on mapsingleclick. Ive got it working in Singleplayer/mission preview however once uploadeded to a serverr it fails to work.

I have marker 1 on the map that is moved by a trigger set on radio alpha with this code

onMapSingleClick{"marker1"setMarkerPos _pos;onMapSingleClick {}}; support move getMarkerPos "marker1"

it moves the units in the SP game but no MP, can any genius help me place this into a script so that i can execute it outside of the engine as it were

i tried

onMapSingleClick{"marker1"setMarkerPos _pos; onMapSingleClick {}}

; _support move getMarkerPos "marker1"

that however didnt work crazy errors, can somebody help me do it:S preferabley id like it to say "where to" when you activate the trigger then confirm either the cordinates or just that they recieved the order when you click on the map.

Cheers,

SC

Share this post


Link to post
Share on other sites

Hi Thing,

The problem is locality of your script. In multiplayer, your "move" command is executed locally, making groups on other machines unresponsive. You will need a way to communicate commands to the other nodes of the network.

Spinor is working on something similar for the Command Engine. The CoC Network Services were specifically created to tackle this issue. You might want to check it out:

http://www.website.thechainofcommand.net/coc_network_services.htm

Share this post


Link to post
Share on other sites

As Matt says, or try using a global variable(s). Its not the ideal way but if you havent got too much else scripted for MP its OK.

Try moving a named gamelogic instead of a marker.

Onclick;

- move the gamelogic

- set ITSMOVED = 1

- wait 5 secs

- set ITSMOVED = 0

then have a script looping on all machines like;

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

@ITSMOVED

support move getPos "myGamelogic"

~1

goto "loop"

... or something like that smile_o.gif

Share this post


Link to post
Share on other sites

Sorry guys but it's not the move command being

executed locally but the setmarkerpos command wink_o.gif

Try this one instead:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick{_support move _pos; onMapSingleClick {}}

P.S: i'm not quite sure right now if you gonna get probs because of probably onmapsingleclick being executed locally only also and so the onMapSingleClick {}, but

if so this will not be too hard to be solved either wink_o.gif

~S~ CD

Share this post


Link to post
Share on other sites

I just thought I'd throw this one out for the hell of it but I imagine you guys are already ahead of me on this one given the more advanced solutions offered already in this thread but,

Would using the publicvariable command help? Or does this increase latency if it is over used? If what chris is saying is right and the move command is not causing locality issues then wouldn't broadcasting positional data to clients solve the issue?

Bear with me on this one, I am painfully new to multiplayer scripting  inlove.gif

Share this post


Link to post
Share on other sites
Sorry guys but it's not the move command being

executed locally but the setmarkerpos command wink_o.gif

Try this one instead:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick{_support move _pos; onMapSingleClick {}}

P.S: i'm not quite sure right now if you gonna get probs because of probably onmapsingleclick being executed locally only also and so the onMapSingleClick {}, but

if so this will not be too hard to be solved either wink_o.gif

~S~ CD

Now... if onmapSingleClick is executed locally, that wouldn't matter if Move were a global command. If either of them would be global, the message would come through on the other side.

I am currently working on a Skirmish system (lightweight Command Engine type of thing), an early beta of which can be seen in OFP-Willem's "Beats the Dutch" mission. As I want to extend the script with networking functionality, I already checked the localty of the MOVE command's execution. My findings are that the MOVE command is executed locally.

(Maybe you're mixing up DoMove or CommandMove with the Move command?)

Quote[/b] ]I just thought I'd throw this one out for the hell of it but I imagine you guys are already ahead of me on this one given the more advanced solutions offered already in this thread but,

Would using the publicvariable command help? Or does this increase latency if it is over used? If what chris is saying is right and the move command is not causing locality issues then wouldn't broadcasting positional data to clients solve the issue?

Bear with me on this one, I am painfully new to multiplayer scripting inlove.gif

You may be painfully new to MP scripting, but in fact you are right. The PublicVariable command is used to communicate messages. CoC's network services uses this command to communicate information between nodes.

smile_o.gif

The value of CoC NS lies in the fact that you don't have to figure everything out by yourself. It's all ready for use, providing several structured communication channels for your needs.

For my Skirmish scripts, I'm just curious if I can make it all on my own. So I won't use CoC NS, but instead I'm going to re-invent the wheel all over again. A man needs a hobby, right?

whistle.gif

Share this post


Link to post
Share on other sites

Thanks very much for the reply Matthijs wink_o.gif Can I ask briefly what the Chain of Command's Network Services utility is for? Not sure why but I seem to have an interest in coding functional things more so than addons. I suppose it's because in the end they benefit a wider number of users.

Any idea where I get hold of the Chain of Command's Network Services from?

I might also have a look through their artillery script. I bet that one is real corker of a script too, going on their reputation.

Thanks again thumbs-up.gif

Share this post


Link to post
Share on other sites

Where to get it:

http://www.website.thechainofcommand.net/coc_network_services.htm

(you can also find this link a few posts back icon_rolleyes.gif )

You want to tell a remote unit to move to position [1240,223]. How to do that?

Let's say you have a script running on every client, that monitors variables varMoveX, varMoveY and varOrderToGroup. You do the following:

varMoveX=1240

varMoveY=223

varOrderToGroup=group Myhero

Finally you send them to the other machines using the PublicVariable command.

publicVariable "varMoveX"

publicVariable "varMoveX"

publicVariable "varOrderToGroup"

So far so good, but now you have the following challenges:

- How do you know that the variables ever reached the destination over the network? After all, the connection could have timed out.

- How long should you wait before issueing the next order for antoher group? You never know how long it might take for a variable to be replicated to all clients.

- How do you prevent other clients from overwriting the variables, before the values you put in were replicated to the intended destination?

- When implementing a method to prevent that clients overwrite variables, before the "message' was received by the intended destination, how do you prevent that one client claims too much time before letting the others "talk"?

- Now you want to send a boolean value, instead of numerical values. How do you make your scripts so that they will be able to handle both numbers and boolean values?

Also, the PublicVariable has a few shortcomings:

- PublicVariable does not support arrays. Wouldn't it be nice to just send a position as [X,Y] instead of having to split it over several variables?

- PublicVariable does not support strings. What if you want to send text to other clients?

CoC NS provides you with a complete set of scripts and functions, to tackle many of the problems that you may encounter.

The names of the CoC NS functions say it all:

fArrayToVar

fDefined

fNGetType

fNPrint

fNSend

fNSendAll

fNSendClients

fNSendServer

fNSendRange

fPublicArray

fReceiveArray

fVarToArray

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  

×