Home   Help Search Login Register  

Author Topic: Random Arty for MP Question  (Read 1564 times)

0 Members and 1 Guest are viewing this topic.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Random Arty for MP Question
« on: 16 Oct 2011, 10:58:23 »
Hi OFPEC, i was just wondering if i call this script via a trigger in Multiplayer will it create a mess up of where the explosions actually are on each client.

Code: [Select]
// random mortar fire function
if (isServer) then {
if (isNil "DZ_fnc_MortarFire") then {
    DZ_fnc_MortarFire = {
        private ["_ammo", "_marker", "_xcoord", "_ycoord", "_timer", "_fire"];
        _ammo = _this select 0;
        _marker = _this select 1;
        _xcoord = _this select 2;
        _ycoord = _this select 3;
        _timer = _this select 4;
        _fire = true;
        while {_fire} do {
            _firerun = _ammo createvehicle [(getmarkerpos _marker select 0) + random _xcoord, (getmarkerpos _marker select 1) + random _ycoord, getmarkerpos _marker select 2];
            sleep (random _timer);
        };
    };
};
};

Code: [Select]
mf1 = ["ARTY_Sh_81_HE", "mort1", 100, 150, 17] spawn DZ_fnc_MortarFire;
I am learning my answer from the surrounding threads - god bless ofpec without you tis' a cold world indeed salute
« Last Edit: 19 Oct 2011, 14:30:46 by Carroll »

Offline Loyalguard

  • Former Staff
  • ****
Re: Random Arty for MP Question
« Reply #1 on: 19 Oct 2011, 14:35:57 »
Because of the isServer check the script should only run on the server which means the shells should only be created there as well so it should be consistent for all clients.

Just out of curiosity, when/where are you loading the function?

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: Random Arty for MP Question
« Reply #2 on: 19 Oct 2011, 14:40:53 »
loading the function via an "anybody" trig on mission start.

add note: I realise that i can do so from INIT file. I am currently learnin myself how to understand the sqf - im quite the noob, and in past got by with what the ED offers (for singleplay atleast).

From your answer i am safe in the bombardment being what it is on all clients yes.

Thankyou, more things of syntax are understanded
« Last Edit: 19 Oct 2011, 14:50:01 by Carroll »

Offline Loyalguard

  • Former Staff
  • ****
Re: Random Arty for MP Question
« Reply #3 on: 19 Oct 2011, 15:49:39 »
I cannot say for sure, but the way you are loading and then spawning the function may cause errors on clients.  When the trigger that spawns the function fires, it will fire on all clients.  But, the function will not be loaded into memory on clients because of the isServer check.  You may want to put an additional isServer check in the On Act field of the trigger that spawns the function such as...

Code: [Select]
if (isServer) then {mf1 = ["ARTY_Sh_81_HE", "mort1", 100, 150, 17] spawn DZ_fnc_MortarFire;};
...to ensure that the function is only spawned on the server.  If you did this, you could even remove the isServer check from the function file itself.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: Random Arty for MP Question
« Reply #4 on: 22 Oct 2011, 08:10:35 »
I will be able to test it this weekend on a LAN with my brother & update the thread, Thanks again