Home   Help Search Login Register  

Author Topic: Init.sqf problem  (Read 1653 times)

0 Members and 1 Guest are viewing this topic.

Offline CharlieReddog

  • Members
  • *
Init.sqf problem
« on: 13 Jul 2009, 21:08:02 »
Hi, thanks to the sterling efforts of spooner I had some code which works perfectly in the editor to remove all items from units, then add bits back. However, when I've made it MP compatible, it just doesn't work at all. I just don't get what I've done wrong ???

Code: [Select]
if (isserver) then
{
private ["_newObjs"];

_newObjs = [getmarkerpos "mkr_Camp1_1", 75, "mediumtentcamp_napa"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf"));
_newObjs = [getmarkerpos "mkr_camp1", 275, "citybase04"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf"));
_newObjs = [getmarkerpos "mkr_camp1_2", 275, "guardpost_cdf"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf"));
_newObjs = [getmarkerpos "mkr_camp1_3", 275, "guardpost2_us"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf"));

{
removeAllItems _x;
if (((side _x) == east) and (_x == (leader _x))) then
{
if ((random 1) < 0.3) then { _x addWeapon "itemMap"; };
if ((random 1) < 0.3) then { _x addWeapon "itemRadio"; };
};
} forEach allUnits;
};
tskEvade= player createSimpleTask["Escape and Evade"];
tskEvade setSimpleTaskDescription["You need to try to make it back to friendly lines centered around Krasnostav.<br/>Unfortunately you didn't have time to grab much
gear before bailing out, so you'll have to make do with what you can find.", "Escape and Evade", ""];
player setcurrenttask tskEvade;

dryFriends=player createDiaryRecord["Diary",["Friendly Forces","Friendly forces are focussed around the FOB south of Krasnostav and the villages environs. If you can get your hands
on a radio then you may be able to call in support. <br/><br/>Mortars, Howitzers and Fast Air are all in-theatre but may be alternately tasked. Given the enemy's AAA threat
it is unlikely that air support will include helicopters unless close to the safe zone."]];

dryEnemy=player createDiaryRecord["Diary",["Enemy Forces","Enemy forces are as yet unknown. Our forces have had little contact with the enemy, and intel suggests that
they will consist of small roving patrols on foot and in vehicles. Some AAA capability is expected."]];

drySituation=player createDiaryRecord["Diary",["Situation","The C130 you and the rest of your team was flying into Chernarus on has been shot down.
You were lucky enough to be near the ramp when the aircraft was hit and had just enough time to don a parachute and leap out.<br/><br/>
The C130 will have crashed somewhere near your position or maybe even crashlanded. You might find additional team members there, or weapons and equipment.<br/><br/>
Alternatively you can strike out for home on your own."]];

Offline CharlieReddog

  • Members
  • *
Re: Init.sqf problem
« Reply #1 on: 19 Jul 2009, 23:30:09 »
No one has any ideas? Looks like I'm royally buggered then. :confused:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Init.sqf problem
« Reply #2 on: 20 Jul 2009, 22:16:37 »
I guess the dyno stuff only needs to be run on the server and is still working fine for you. Never used it myself though.

Well, you are only removing items from units on the server, so players won't necessarily get their items removed since add/remove commands need to be run local to the object being affected. Run that code everywhere, not just on the server, and it will ignore all the units that aren't local to the script being run (and ensure that, on player machines, the player is synchronised before running it, as I explain next).

On clients, the objects aren't created by the time init.sqf is started, so you need to ensure you wait until the object initialisation phase is completed before you start doing things with the player object (or other objects, for that matter):
Code: (wait for player synchronisation) [Select]
if (not isDedicated) then { waitUntil { alive player } };
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)