Jump to content

Sign in to follow this  
scajolly

Locality issue

Recommended Posts

Hi all

I've a problem with something I've written. It does not seem to spawn any enemies when I'm on MP, but it works fine in the mission editor.

Below, the code finds a position, puts a few markers there, and then calls UPSMON. Now, nothing's wrong with UPSMON as far as spawning goes: It's working fine when called in triggers, and works fine in the editor. But not in this script when in MP.

I'm not getting ANY script errors showing. By the way, "SHK Pos" is Shuko's positioning: http://www.armaholic.com/page.php?id=13784

"var1" is a marker that I placed to tell where the scripts are activated, and that one absolutely works when I'm in MP.

I tried this script both with and without an if (isServer) exitwith at the beginning. The below version has it taken out. That's why I'm stumped. Is there something about the handle for Upsmon being nul? That's never been a problem before. :confused:

_cmd = _this select 0;

_pos = getPos _cmd;

grenadex setpos _pos;

"maxmarker" setmarkerpos _pos;
"minmarker" setmarkerpos _pos;
"amarker" setmarkerpos _pos;
"var1" setmarkerpos _pos;

_p1 = ["maxmarker",false,["minmarker"]] call SHK_pos;
trigger1 setpos _p1;
"min1" setmarkerpos _p1;

_p2 = ["maxmarker",false,["minmarker","min1"]] call SHK_pos;
trigger2 setpos _p2;
"min2" setmarkerpos _p2;

_p3 = ["maxmarker",false,["minmarker","min1","min2"]] call SHK_pos;
trigger3 setpos _p3;
"min3" setmarkerpos _p3;  

_p4 = ["maxmarker",false,["minmarker","min1","min2","min3"]] call SHK_pos;
trigger4 setpos _p4;
"min4" setmarkerpos _p4;

nul = [1,position trigger1,1,["amarker","noveh","safe","nosmoke","delete:",600,"respawn:",1]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [1,position trigger1,1,["amarker","noveh","safe","nosmoke","delete:",600,"respawn:",2]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [2,position trigger2,1,["amarker","noveh","combat","nosmoke","delete:",600,"respawn:",2]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";

sleep 600;

nul = [1,position trigger3,1,["amarker","nosmoke","delete:",600,"respawn:",3]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [3,position trigger4,1,["amarker","noveh","nosmoke","delete:",600,"respawn:",3]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [2,position trigger1,1,["amarker","nosmoke","delete:",600,"respawn:",2]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";

sleep 1300;

nul = [1,position trigger1,1,["amarker","nosmoke","delete:",600,"respawn:",3]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [3,position trigger2,1,["amarker","noveh","nosmoke","delete:",600,"respawn:",2]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [2,position trigger3,1,["amarker","nosmoke","delete:",600,"respawn:",2]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
nul = [1,position trigger4,1,["amarker","nosmoke","delete:",600,"respawn:",2]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";

---------- Post added at 13:57 ---------- Previous post was at 13:22 ----------

To compound the issue, when hosting my own dedicated to check the spawning, the spawns work. When I go on a proper server and test it, it doesn't. Must be some locality shit, isn't it? Is there something wrong when a script calls an sqf like UPSMON which has an "if !(isServer) exitwith---"?

Edited by SCAJolly

Share this post


Link to post
Share on other sites

I dont work with UPSMON very much but check MON_SPAWN.sqf and see if it is limiting the script to only run on the server.

For your script you should put this at the top, it will ensure that it only runs on the server, you dont want an AI spawning script running on all clients(You would have a set for each client +server.)

This will tell everything except the server to exit.(Works for Dedi as well as local hosted.).

if (!isServer) exitWith {};

I have a feeling this is due to how your calling the script, can you post more detail about how your calling it so we can debug it some more.

---------- Post added at 07:13 AM ---------- Previous post was at 07:10 AM ----------

Ok just saw your updated post, just as I thought, your calling the script from a client and the script your calling (MON_SPAWN.SQF) has a check to only run on the server. So your problem is that your calling it from a client, I need some more details though to help with how your calling it.

Edited by Riouken

Share this post


Link to post
Share on other sites

It's being called through an AddAction to a vehicle.

If I understand you correctly, I should take the MON_spawn, copy it (since I also rely on its normal functions for triggers), remove the "if !isserver.." and call the copy through this sqf?

I'll try this out immediately.

---------- Post added at 14:35 ---------- Previous post was at 14:23 ----------

I've added "if (!isServer) exitWith {};" to the top of the script, whilst taking it out of SPAWN_MON2.sqf (the copy).

Now, the script does not run at all: The "var1" marker does not change its position.

The addAction is called thus in the Init of a vehicle:

attackhandle1 = this addAction ["Deploy Command Module (your FOB is finished)", "scripts\attack.sqf",[build1]]

Attack.sqf is the script shown at the very top, except it's now calling "execVM "SCRIPTS\UPSMON\MON_SPAWN2.SQF";" - ie the version of Mon_spawn that has not got the "if (!isserver) exitWith {};"

Edited by SCAJolly

Share this post


Link to post
Share on other sites

You need to exicute the script on the server, addactions are local, when you call the script from an addaction it is only called on the client that used the addaction. What you need to do is tell the server to start the script for that you will use:

http://community.bistudio.com/wiki/addPublicVariableEventHandler

Or you could use the CBA Event system.

Share this post


Link to post
Share on other sites

Thank you immensely for your help, Riouken. However, I'm not well versed with eventhandlers and not certain how I am to make this transfer from client to server.

Would I do it like this? As in, if I run a script on the server first, and then provide an addAction through that script, that should make it work on the server?

Vehicle (Build1)'s INIT line:

attackhandle1 = this execVM "scripts\addaction.sqf";

AddAction.sqf:

waitUntil{!isNil "bis_fnc_init"};
_this addAction ["Deploy Command Module (your FOB is finished)", "scripts\attack.sqf",[build1]];

Attack.sqf (not changed):

  Reveal hidden contents

Share this post


Link to post
Share on other sites

The above did not work, I'm afraid. I misread you the first time, but I've still no real grasp on addPublic...; we're dealing with 2 or 3 scripts here: One to offer an addaction to activate the Attack.sqf, then that sqf to move markers and call MON_SPAWN.sqfs which adds enemies.

You say "tell the game to start the script", and for that to use addPublic.., but I'm not sure which of the scripts to treat in what way.

Edited by SCAJolly

Share this post


Link to post
Share on other sites

Maybe an example from one of my missions will help you.

This is a set of scripts that allow the user to select a locations via mapclick and color of the flare and will rain down flares on the selected location.(The dialog and a few other parts were not shown to not cloud the example) All of the options are made locally, then the script is ran on the server so that everyone in MP can see the flares as well.

In the init.sqf

// This is the eventhandler that we are adding to the server and the clients.
"flare_start" addPublicVariableEventHandler {[] execVM "opcom\scripts\flares\flaremain.sqf";};

This is from my dialog(which is local, it is just like you starting it from an addaction).

class flrstrtbtn: RscShortcutButton
{
idc = 1701;
text = "Start";
x = 0.285417 * safezoneW + safezoneX;
y = 0.176667 * safezoneH + safezoneY;
w = 0.113888 * safezoneW;
h = 0.0938889 * safezoneH;
       onButtonClick = "execVM 'opcom\scripts\flares\flarego.sqf'";
};

this is the flarego.sqf.

// Opcom Interface , By Oliver 15thMEU(SOC).

flare_start = true;

publicVariable "flare_start"; 

and this is the flaremain.sqf:

// Opcom Interface , By Oliver 15thMEU(SOC).

if (!isServer) exitWith {};
// _flrinpcolor = lbCurSel 2100;
// _flrinptime = lbCurSel 2101;
_flrcolor = "";
_flrtime = "";

switch (true) do {
   case (flrinpcolor == 0) : { _flrcolor = "F_40mm_Red";};
   case (flrinpcolor == 1) : { _flrcolor = "F_40mm_Green";};
   case (flrinpcolor == 2) : { _flrcolor = "F_40mm_White";};
};

switch (true) do {
   case (flrinptime == 0) : { _flrtime = 30;};
   case (flrinptime == 1) : { _flrtime = 60;};
   case (flrinptime == 2) : { _flrtime = 120;};
   case (flrinptime == 3) : { _flrtime = 180;};
   case (flrinptime == 4) : { _flrtime = 300;};
   case (flrinptime == 5) : { _flrtime = 600;};
   case (flrinptime == 6) : { _flrtime = 1800;}; 
};

_starttime = time + 0;

//_xflrpos = newflrpos select 0;
//_yflrpos = newflrpos select 1

while {time <(_starttime + _flrtime)} do
{

   flare = _flrcolor createVehicle [newflrpos select 0, newflrpos select 1,150];

   sleep 21;
   flars_are_running = true; 
};


if (time >(_starttime + _flrtime)) then
{
   flars_are_running = false;
   [nil,opcom,"loc",rHINT,"Flares have ended."] call RE;
};

---------- Post added at 12:37 PM ---------- Previous post was at 12:30 PM ----------

The only problem with publicVariableEventhandler's are that the EH will not fire on the client that is sending the publicVariable, so if your testing it on local host or in the editor it will not work, but a work around for this is this:

flarego.sqf.

// Opcom Interface , By Oliver 15thMEU(SOC).

if (isServer) then {

     flare_start = true;
     _nop = [] execVM 'opcom\scripts\flares\flarego.sqf;

} else {

    flare_start = true;
    publicVariable "flare_start";
};

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  

×