Jump to content
Sign in to follow this  
ikmn

Questions on Locality/MP

Recommended Posts

So I am making my first MP mission - I vaguely understand the locality issues, JIP issues. So far my tasks, markers, etc are working flawlessly in MP\JIP using Public Variables. This part I comprehend.

The question and problem I have is with the add\action scripts. I have scripts for AI recruitment, Teleport, Map Click Group HALO and eventually an artillery script. The scripts are mostly modified versions of free scripts I have downloaded from the web. All of them work via add\action. I suspect though that most of these scripts are for single player. They work flawlessly on dedicated if I setup dedicated or host a MP game on my machine. However, I can't test them in a true MP environment yet and haven't tested them with any other players other than myself.

I am concerned that for example with multiple clients, when I use the teleport script it will teleport everyone in game. Or when using the HALO script it will parachute everyone connected instead of just the player that activated it. I have read that an ON ACTION command will only run on the client that activated it so I assume this will all be fine. But will it also run on the server and the client that activated it or only on the client??

So for example sake: Client selects PARADROP by an add action on a flagpole that runs the PARADROP.sqf script. That script is executed on that client. But it will probably also run on the server which could cause issues??

So do I need to have at the top of the paradrop script something that will prevent it from running on the server like if (isServer) then exit with {}; command ?? Is it that simple or do I need a more complex solution?

The reason I am asking is I can't host a dedi @ home due to an issue with the router provided by my ISP so I can't really test. So I'd like to get these issues sorted out before I send the mission for testing to someone who can host it.

cheers

k

Share this post


Link to post
Share on other sites

Disclaimer: I am FAR from an expert in these areas :p

Teleport script you'd have to do some extra work for it to teleport a group or > 1 player (ie: runscript forEach units _group) so you should be OK.

I know for addAction scripts you need to make sure that it is only being run once (server) and not for every connected player (else you get 1 x addAction scroll-wheel option for each player connected).

Share this post


Link to post
Share on other sites

AddAction(s) are local to the player.

So if you add an action in the init.sqf all the players connected have the action, but if one player uses an action, the script runs on that client only

Share this post


Link to post
Share on other sites

Thanks guys for the replies. I have an ADD-ACTION on a FLAGPOLE that the player activates that runs a TELEPORT script. I also have a similar script on a RADIO TOWER that runs a PARADROP script. They are not in the INIT.SQF but actually I placed them in the EDITOR in the VEHICLE init for those objects that both call separate scripts. The scripts files themselves don't have anything in them that is specific to running on SERVER, or CLIENT.

For example:

private ["_StartLocation"];

flagpole removeAction ClickOnMapCounter;

openmap true;
hintsilent format["%1Single-click where you want to parachute, make sure the location is safe!!!"];
onMapSingleClick "_StartLocation = _pos; [_StartLocation] execVM ""scripts\Paradrop.sqf""; clicked = 1; openmap false; onMapSingleClick ''; true;";
waitUntil {(clicked == 1)};
hint"";

That's the parachute script - it's in the ADD-ACTION of an object. So say it runs on the client that activated it. But then it calls another script - will that subsequent script also run only on the client that activated the original ADD-ACTION?

Just for kicks - I added an if(isServer) then exit with {}; to the parachute script.

I tried it in single player and it didn't work. I tried it in multiplayer (hosted game) and it didn't work. I tried on a dedicated server I setup and it worked. Sorry to seem like a pain I am just trying to learn about this locality thing. Nothing worse than releasing my mission to my friends to test and the teleporter and parachute system is broken.

Thanks for any help or suggestions,

k

Share this post


Link to post
Share on other sites

That's the parachute script - it's in the ADD-ACTION of an object. So say it runs on the client that activated it. But then it calls another script - will that subsequent script also run only on the client that activated the original ADD-ACTION?

Yes

Just for kicks - I added an if(isServer) then exit with {}; to the parachute script.

I tried it in single player and it didn't work. I tried it in multiplayer (hosted game) and it didn't work. I tried on a dedicated server I setup and it worked. Sorry to seem like a pain I am just trying to learn about this locality thing. Nothing worse than releasing my mission to my friends to test and the teleporter and parachute system is broken.

Thanks for any help or suggestions,

k

Whent you host you are a Server, even in SP.

if(isDedicated) then exit with {};

This is the right syntax, but useless, you don't need it

Share this post


Link to post
Share on other sites

Ok, I get it somewhat. I am not saying you are wrong because maybe I did a poor job of explaining my crappy comprehension of MP scripting. He hosted the game in MP not on DEDI. I used the teleport script and it teleported my friend even though I was the one who activated the flagpole - so it seems like it ran on his computer as well so I thought you were wrong... but your probably right and it's how I setup the mission.

//telebeach.sqf
//to teleport player & AI to landing beach

_ldr = _this select 1;
_dest = (beachdestination);
_dir = 190;

{_x SetPos [(_dest select 0)-10*sin(_dir),(_dest select 1)-10*cos(_dir),+0]} forEach units group _ldr;

That the code. (beachdestination) is a PublicVariable that changes FYI cause I need to change the teleport location throughout the mission. It's a group teleport that I wanted to teleport AI in the players group with the player - but not human players. Anyway, in the editor I had the players grouped together. So I think even though I was the one who activated the script it teleported him cause he was a member of my group. So in the mission I need to ungroup all the playable slots and it would probably worked?

If I put if (isServer) exit with {}; at the top of the script it would definitley not run on the server, however- if I was hosting a game MP on my machine it would do nothing because my machine would be recognized as the server. Sorry for so many questions I am just trying to comprehend. I think my problems is that I grouped the human players together in the editor and I shouldn't have done that.

cheers

k

Share this post


Link to post
Share on other sites

Just exlude the players not local in the array.

If (isplayer _x && local _x)

Or ungroup them.

You didn't say that the script setpos of a group :P

Share this post


Link to post
Share on other sites

Thanks for the "pro tip". I think I am getting this. I had a major locality issue in my scripts because I didn't understand the logic behind locality. In my init I called a script that started the mission on server only missionstart.sqf - The mission start then called other missions. The problem was I assume that by calling that script from server only - anything in that script and any other scripts that are called are LOCAL to run only on the server. So when I had text, sounds, etc. they wouldn't work because they are broadcast locally - hence only the server got those commands. Even if I had if (is!server) then playsound blah blah blah. It wouldn't work because I callled that script originally from a script that started from an if (isServer). So I made the missionstart.sqf not if(isServer) - now everthing works. I made it JIP compatible by using a publicglobalvariable so that it won't missionstart.sqf when a player joins. Thanks for the explanations they helped me understand locality.

cheers

k

Share this post


Link to post
Share on other sites

Thanks again Giallustio. I have another question if you don't mind? It's about MP mission structure. I hope I explain well what I am asking. When it comes to designing a MP mission what should the structure of the scripts be or what is the proper way to have the mission flow? For example in my mission I have a missioninit file that runs only once by checking a global variable if is(NIL) in the mission INIT. Then it is random but for simplicity sake lets just say it it runs another script that is objective1. In my objective1 script I have things like spawning the enemy, vehicles, etc and setting triggers which I run only on the server. In the same script I have things like TEXT messages and TASKS which I run on client and server or just client depending on need. Then it calls another objective2 script and so forth with the same concept. Obviously I have public variables for things that need to work for JIP and I have a JIP sync script in the init file for JIP players. Is this flow ok? I guess call something like this a single flow chart.

Or is better to have like two flow charts where there is a set of scripts that run on the server and a separate set of scripts that are for client and try to have them work together? Sorry to sound like such a noob but I am one. lol

cheers

k

Share this post


Link to post
Share on other sites

I don't know if i understand correctly.

Let's make an example.

You have "obj1.sqf" script.

You have something like this in it?

if (isServer) then
{
SPAWNING STUFF AND VAR
}
else
{
TASK AND TEXT STUFF
};

waitUntil {obj1done};
[] execVM "obj2.sqf";

It could work. There isn't a proper way to script, everyone has its own style.

Share this post


Link to post
Share on other sites
I don't know if i understand correctly.

Let's make an example.

You have "obj1.sqf" script.

You have something like this in it?

if (isServer) then
{
SPAWNING STUFF AND VAR
}
else
{
TASK AND TEXT STUFF
};

waitUntil {obj1done};
[] execVM "obj2.sqf";

It could work. There isn't a proper way to script, everyone has its own style.

Yep that's how I am doing it.

I guess what I meant was do it like above or have like objective1server.sqf and object1client.sqf? Sometimes I just have a hard time explaining myself. Thanks for all the links and advice. Eventually, I'll figure out how to store all my missions in a variable with an array and just have like a spawnmission.sqf and just pass the variables to the script but that's a little too far out of my experience at this moment. lol - thanks again for your time to reply to me.

k

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  

×