Jump to content
Sign in to follow this  
Dunkelheit II

Identity of the created vehicle in Multiplayer

Recommended Posts

Hi. Sorry for old theme, but my question is about createVehicle in multiplayer missions.

 

It is well known that to prevent doubling of created vehicle in multiplayer missions ?!(local GameLogic): exit should be used. But how to preserve the identity of such vehicle? Suppose we have a bundle of scripts, first of which creates the vehicle and others are about operation with it. But when we deal with a doubling in the first script, the identity of the object seems to be lost for other scripts. I mean that the object is visible for players, it has no double, but it is as if invisible for other scripts or for machines that execute these scripts. Adding ?!(local GameLogic): exit  to all scripts does not help. I suppose here that mission works properly when we start it locally through multiplayer.

Share this post


Link to post
Share on other sites

It surely would help if you post some code snippets.

 

Do you assign the created vehicle into a global variable and then try to do something with it in subsequent scripts? Maybe you have to use publicVariable in between.

Share this post


Link to post
Share on other sites
6 minutes ago, zwobot said:

Do you assign the created vehicle into a global variable and then try to do something with it in subsequent scripts? Maybe you have to use publicVariable in between.

I assign it to local variable and then try to do some operation in subsequent scripts, the core of which is to find a vehicle through nearestObject (without transmission of variables, it is impossible). Also I'm trying to make a marker for it in another script. And yes, I would precisely wanted to know how to use publicVariable for this purpose. I have no global variables at all in this context.

Share this post


Link to post
Share on other sites

I don't think there is a way to make a local vairable usable in another script. I'm not much of an MP scripter but you probably have to do something like:

 

script1.sqs

?!local server : exit
yourVehicle = "M113" createVehicle getPos player
publicVariable "yourVehicle"

script2.sqs (should be called after script1.sqs or you have to make it wait until script1.sqs has publicVariabled yourVehicle

 

"YourMarkerName" setMarkerPos getPos yourVehicle

 

Maybe CoC NS2 has some facilities which might be useful to you but I've never used it. Maybe it would be worth checking-out for you.

[Guide] CoC Network Services 2

Edited by zwobot
Added link to NS2 topic

Share this post


Link to post
Share on other sites

OK, but how to identify vehicle through nearestObject, if no variable is used by this operator, only class name? Adding something like @yourVehicle to the second script is useless.

Share this post


Link to post
Share on other sites

What exactly are you trying to do? 

 

If you want to know whether your created vehicle is within a certain distance of another object you can simply use distance.

Share this post


Link to post
Share on other sites
22 minutes ago, zwobot said:

What exactly are you trying to do?

Simply to identify created vehicle in the second script without transmission of local variables. Reference to distance was presicely an instrument to do it locally, but not very necessary.

 

Some general questions:

1. Why should we use a bundle of ?!local server : exit and publicVariable if the command is already global?

2. What will be if "?!local server : exit" and "?!(local _vehicle) : exit" would be used in the same script?

3. Can I proceed this way: _vehicle = yourVehicle; publicVariable "yourVehicle"?

Share this post


Link to post
Share on other sites

Regarding your questions

1. You have to distinguish between global/local arguments and global/local effect. The MP tutorial available at Ofpec.com might also help (it's for Arma but the principles are the same for Ofp/CWA). Checking the locality of ther server for the createVehicle command is necessary because otherwise the object would be created once for every player who is connected (and the server maybe).

 

2. I don't know, depends on what else you do in the script

 

3. It won't make _vehicle available in any other script you might be running. You can only refer to your created vehicle if you assign it to the global variable yourVehicle and then publicVariable it. If you do the follow-on processing (setting a marker for it etc.) in the same script in which you create the vehicle, then you might not need to use publicVariable at all but it really depends on what you want to do.

 

 

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  

×