Home   Help Search Login Register  

Author Topic: MP gunner scoring and target reset problems  (Read 1800 times)

0 Members and 1 Guest are viewing this topic.

Offline Sparticus76

  • Members
  • *
MP gunner scoring and target reset problems
« on: 13 Feb 2009, 07:46:10 »
G'day,
       I have a training mission where I drive a tank around a track with targets and the gunner of the tank engages the targets on the move. When I try out the mission(as exported to multi-player mission) it all works fine, when I kill a target, I get awarded points, and when I want them all reset, I hit "reset targets" in the radio and it all resets. However, I played it last night with others, and they didnt get scored, and it would not reset the targets. I have no idea why. Here's the details.


Init.sqs
Code: [Select]
setviewdistance 3500;
tankreset = compile preprocessFile "resettanks.sqf";
resetstabrun = compile preprocessFile "resetstabrun.sqf";
targetdown = compile preprocessFile "targetdown.sqf";
FNC_getReady = {hint format["%1 Get Ready!",_this]};
vtargetdown = compile preprocessFile "vtargetdown.sqf";

Trigger for resetting targets, pic 1


Trigger for resetting targets, pic 2


resetstabrun.sqf
Code: [Select]
private ["_mkr1dir","_mkr2dir","_mkr3dir","_mkr4dir","_mkr5dir","_mkr6dir","_mkr7dir","_mkr8dir","_mkr9dir","_mkr10dir","_mkr11dir","_mkr12dir","_mkr1pos","_mkr2pos","_mkr3pos","_mkr4pos","_mkr5pos","_mkr6pos","_mkr7pos","_mkr8pos","_mkr9pos","_mkr10pos","_mkr11pos","_mkr12pos","_tgt1","_tgt2","_tgt3","_tgt4","_tgt5","_tgt6","_tgt7","_tgt8","_tgt9","_tgt10","_tgt11","_tgt12","_mkr1","_mkr2","_mkr3","_mkr4","_mkr5","_mkr6","_mkr7","_mkr8","_mkr9","_mkr10","_mkr11","_mkr12"];
_tgt1 = _this select 0;
_tgt2 = _this select 1;
_tgt3 = _this select 2;
_tgt4 = _this select 3;
_tgt5 = _this select 4;
_tgt6 = _this select 5;
_tgt7 = _this select 6;
_tgt8 = _this select 7;
_tgt9 = _this select 8;
_tgt10 = _this select 9;
_tgt11 = _this select 10;
_tgt12 = _this select 11;
_mkr1 = _this select 12;
_mkr2 = _this select 13;
_mkr3 = _this select 14;
_mkr4 = _this select 15;
_mkr5 = _this select 16;
_mkr6 = _this select 17;
_mkr7 = _this select 18;
_mkr8 = _this select 19;
_mkr9 = _this select 20;
_mkr10 = _this select 21;
_mkr11 = _this select 22;
_mkr12 = _this select 23;

sleep 0.5;
_mkr1pos = getpos _mkr1;
_mkr2pos = getpos _mkr2;
_mkr3pos = getpos _mkr3;
_mkr4pos = getpos _mkr4;
_mkr5pos = getpos _mkr5;
_mkr6pos = getpos _mkr6;
_mkr7pos = getpos _mkr7;
_mkr8pos = getpos _mkr8;
_mkr9pos = getpos _mkr9;
_mkr10pos = getpos _mkr10;
_mkr11pos = getpos _mkr11;
_mkr12pos = getpos _mkr12;
sleep 0.5;
_mkr1dir = getdir _mkr1;
_mkr2dir = getdir _mkr2;
_mkr3dir = getdir _mkr3;
_mkr4dir = getdir _mkr4;
_mkr5dir = getdir _mkr5;
_mkr6dir = getdir _mkr6;
_mkr7dir = getdir _mkr7;
_mkr8dir = getdir _mkr8;
_mkr9dir = getdir _mkr9;
_mkr10dir = getdir _mkr10;
_mkr11dir = getdir _mkr11;
_mkr12dir = getdir _mkr12;
sleep 0.5;
deletevehicle _tgt1;
deletevehicle _tgt2;
deletevehicle _tgt3;
deletevehicle _tgt4;
deletevehicle _tgt5;
deletevehicle _tgt6;
deletevehicle _tgt7;
deletevehicle _tgt8;
deletevehicle _tgt9;
deletevehicle _tgt10;
deletevehicle _tgt11;
deletevehicle _tgt12;
sleep 0.5;
tgt1 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr1pos;
tgt1 setdir _mkr1dir;
tgt2 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr2pos;
tgt2 setdir _mkr2dir;
tgt3 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr3pos;
tgt3 setdir _mkr3dir;
tgt4 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr4pos;
tgt4 setdir _mkr4dir;
tgt5 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr5pos;
tgt5 setdir _mkr5dir;
tgt6 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr6pos;
tgt6 setdir _mkr6dir ;
tgt7 = "ACE_BRDM2" createVehicle _mkr7pos;
tgt7 setdir _mkr7dir;
tgt8 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr8pos;
tgt8 setdir _mkr8dir;
tgt9 = "ACE_TARGET_GREEN_FACUMC" createVehicle _mkr9pos;
tgt9 setdir _mkr9dir;
tgt10 = "ACE_BMP2" createVehicle _mkr10pos;
tgt10 setdir _mkr10dir;
tgt11 = "ACE_BMP2" createVehicle _mkr11pos;
tgt11 setdir _mkr11dir;
tgt12 = "ACE_T72" createVehicle _mkr12pos;
tgt12 setdir _mkr12dir;


Event handler Target down


targetdown.sqf
Code: [Select]
private ["_gunner","_score"];

_gunner = _this select 1;

_gunner addscore 10;

_score = score _gunner;

hint format ["+10, %2 your score is now: %1", _score, name _gunner];

What this does when I play by myself in mp, and not when others play


Where am I going wrong?

EDIT: I found the problem, apparently EventHandlers are not compatible with MP games.
« Last Edit: 16 Feb 2009, 13:08:07 by Sparticus76 »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: MP gunner scoring and target reset problems
« Reply #1 on: 23 Feb 2009, 14:13:53 »
No, event-handlers are entirely compatible with MP play, but in SP you don't notice their behaviour is not global. There are a multitude of differences between MP and SP scripting that you are not taking into account (MP is a lot more complex than SP). You will need to use MP comm

* Look at the MP tutorial (specifically to grasp the difference between local and global effects).
* Look at my functions tutorial to get a better grasp of functions (also look at cheetah's sqf tutorial, perhaps).
* Always use preprocessFileLineNumbers, rather than preprocessFile (look at the COMREF if you want an explanation of the differences).
* On another issue (not directly associated with your MP problems), seriously consider the multiple benefits of learning to use arrays and loops, rather than endlessly repeating code:
Code: (resetTanks.sqf) [Select]
// Run with:
//   nul = [[target0, target1, target2], [marker0, marker1, marker2]] execVM "resetTanks.sqf";
//
// or (since you are compiling your functions!):
//   [[target0, target1, target2], [marker0, marker1, marker2]] call tankreset;
//
// Note that the markers array is NOT an array of game markers, but of objects, such as game-logics.
//
private ["_dir","_pos","_markers","_targets","_class"];

_targets = _this select 0; // targets is an array.
_markers = _this select 1; // markers is also an array and must be the same size.

if ((count _targets) != (count _markers)) exitWith
{
    hint "ERROR: There must be exactly the same number of targets as markers!";
};

// Rather than repeating the exact same code for 12 targets, just iterate through the arrays you have.
for "_i" from 0 to ((count _targets) - 1) do
{
    // Record the old position:
    _pos = getPos (_markers select _i);
    _dir = getDir (_markers select _i);

    // Mostly just use a standard target, but a few want to be specific vehicles.
    _class = switch _i do
    {
         5: { "ACE_BRDM2" };
         9: { "ACE_BMP2" };
         10: { "ACE_BMP2" };
         11: { "ACE_T72" };
         default { "ACE_TARGET_GREEN_FACUMC" };
    };

    // Delete the old target, then replace it with a fresh one.
    deleteVehicle (_targets select _i);
    _target = _class createVehicle _pos;
    _target setDir _dir;
};
(code tested for syntax errors, but not run)
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Sparticus76

  • Members
  • *
Re: MP gunner scoring and target reset problems
« Reply #2 on: 24 Feb 2009, 03:53:10 »
Thankyou very much Spooner, I will do all of the above.

P.S. I highly admire the work of you and all the rest of your caliber on this forum.