Forum Jump :

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#1 Posted at 2014-05-03 18:41        
     
So ive been trying to work on the hostage scripts but now ive run into brick wall here. i built an array

I placed 4 units and put This in there unit init lines: null = [this] execVM "Hostage.sqf";

they start out the way i want but i can only free one and some of the gear doesn't equip any ideas?

/////////////////////////// Hostage.sqf /////////////////////////////////////////////////
_hostage_array = [];
hostage0 = [];
hostage1 = [];
hostage2 = [];

if (isServer) then {

_hostage_array = [hostage0, hostage1, hostage2, hostage3];
_hostage_array disableAI "move";
_hostage_array disableAI "fire";
_hostage_array setcaptive true;
_hostage_array unassignitem "nvgoggles";
_hostage_array removeitem "nvgoggles";
removeallweapons _hostage_array;
removebackpack _hostage_array;
removeGoggles _hostage_array;
removeHeadgear _hostage_array;
action = _hostage_array addaction ["P.O.W. joins your team","freehostage.sqf",[_hostage_array]]; ///<------ this code i got from someone els so not shure if im useing it right.////

};

/////////////////////////// freehostage.sqf /////////////////////////////////////////////
///////////////// This part seams to be working only on one unit ////////////////////////////

_hostage_array = [];
hostage0 = [];
hostage1 = [];
hostage2 = [];
_caller = [];

if (isServer) then {

_hostage_array = [hostage0, hostage1, hostage2, hostage3];
_hostage_array join group _caller;
_hostage_array setcaptive false;
_hostage_array setunitpos "auto";
_hostage_array enableAI "Move";
_hostage_array enableAI "fire";
_hostage_array addWeaponglobal ["arifle_MXM_F", 1], ["hgun_P07_snds_F", 1];
_hostage_array addMagazineglobal ["30Rnd_65x39_caseless_mag", 5], ["16Rnd_9x21_Mag", 3];

};

///i think i need to break the action = _hostage_array addaction ["P.O.W. joins your team","freehostage.sqf",[_hostage_array]]; to each hostage and just put it in the init line of the units any ideas guys?


Author Message


Posts: 1484
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2014-05-03 22:13        
     
You can't use arrays like that you need to extract the units one by one.
/////////////////////////// Hostage.sqf /////////////////////////////////////////////////
_hostage_array = [hostage0, hostage1, hostage2, hostage3];
if (isServer) then {
{
_x disableAI "move";
_x disableAI "fire";
_x setcaptive true;
_x unassignitem "nvgoggles";
_x removeitem "nvgoggles";
removeallweapons _x;
removebackpack _x;
removeGoggles _x;
removeHeadgear _x;
action = _x addaction ["P.O.W. joins your team","freehostage.sqf"]; // other things can be added but depends on what your trying to do
foreach _hostage_array;
};

/////////////////////////// freehostage.sqf /////////////////////////////////////////////
///////////////// This part seams to be working only on one unit ////////////////////////////

_hostage_array = [hostage0, hostage1, hostage2, hostage3];
if (isServer) then {
{
[_x] join group (_this select 1);
_x setcaptive false;
_x setunitpos "auto";
_x enableAI "Move";
_x enableAI "fire";
_x addWeaponglobal ["arifle_MXM_F", 1], ["hgun_P07_snds_F", 1];
_x addMagazineglobal ["30Rnd_65x39_caseless_mag", 5], ["16Rnd_9x21_Mag", 3];
} foreach _hostage_array;
};

///i think i need to break the action = _hostage_array addaction ["P.O.W. joins your team","freehostage.sqf",[_hostage_array]]; to each hostage and just put it in the init line of the units any ideas guys?

The addaction will probably still be an issue as it's MP and it's not really done that way (I'm not into MP) you will need to try it first


Advertisement


Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#3 Posted at 2014-05-04 11:58        
     
yea F2kSel im trying to make it where any player can save a hostage they join the group of the player who "saves" them they go to the drop off point in a trigger area at base and your off to save the next one. thanks for helping me with my script but why couldn't i put the
_hostage_array = [];
hostage0 = [];
hostage1 = [];
hostage2 = [];
in there all that would do it tell the server hey somethings about to happen it would help with the lag in game


Author Message


Posts: 1484
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2014-05-04 12:29        
     
_hostage_array = [];
creates an empty array

_hostage_array = [hostage0, hostage1, hostage2, hostage3];
creates an array with units in it.
I can't imagine there's any difference.

hostage0 = [];
hostage0 is a unit not an array so it cold be an issue.

foreach [hostage0, hostage1, hostage2, hostage3];
you don't need to create the array until it's needed and can be done in foreach.

Not being a MP scripter I can't be sure about lag it's just my opinion, also the script isn't running constantly so it's unlikely to have a serious impact.


Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#5 Posted at 2014-05-05 17:46        
     
ohhhhhhhhhh ok cool thanks F2kSel your awesome!!!