Mattar_Tharkari
-
Content Count
961 -
Joined
-
Last visited
-
Medals
Posts posted by Mattar_Tharkari
-
-
Haven't done any DayZ scripting so a bit in the dark - using Arma2 logic this should work:
BYBox setvehicleLock "LOCKED"; sleep 0.1; //Build Arrays private ["_inv", "_wheel", "_scrap"]; _inv = BYBox call BIS_fnc_invstring; _wheel = {_x=="PartWheel"} count _inv; //PROBLEM AREA _scrap = {_x=="PartGeneric" } count _inv; //PROBLEM AREA //Check Box if (_wheel >= 2 && _scrap >= 2) then { {BYBox removeMagazine "PartWheel"; BYBox removeMagazine "PartGeneric";} forEach [1,2]; //PROBLEM AREA hint "It works!"; } else { hint "you didn't have enough!!"; }; sleep 0.1; BYBox setVehicleLock "Unlocked";
Got rid of cost as it didn't make sense to me - those arrays are for addMagazine. I'm assuming you only need 2 of each mag for this to work?
-
-
Well done! Always room for improvement though - I wondered if there was a game function that would make things easier for you, turns out there is:
If you sit in the pilots seat and put this in a radio trigger it fills the empty crew spaces and joins them to your group - all in 1 line lol. (functions module required on map)
nul = [vehicleName, group player] call BIS_fnc_spawnCrew;
if you add that to the eventHandlers:
for empty helicopters:
{if (side _x == Civilian && _x isKindOf "Helicopter") then { _x addEventHandler ["GetIn", "if ((_this select 2) == driver (_this select 0)) then {[(_this select 0), group player] call BIS_fnc_spawnCrew; hint 'crew spawned';}"];};} forEach vehicles; {if (side _x == Civilian && _x isKindOf "Helicopter") then { _x addEventHandler ["GetOut", "if ((_this select 1) == 'driver') then {{moveOut _x; deleteVehicle _x} forEach crew (_this select 0); hint 'crew deleted';}"];};} forEach vehicles;
Better method: for all vehicles with a driver position and cfg side WEST (will work even if empty):
{if (getNumber(configFile >> "CfgVehicles" >> (typeOf _x) >> "hasDriver")==1 && getNumber(configFile >> "CfgVehicles" >> (typeOf _x) >> "side") == 1) then { _x addEventHandler ["GetIn", "if ((_this select 2) == driver (_this select 0)) then {[(_this select 0), group player] call BIS_fnc_spawnCrew; hint 'crew spawned';}"];};} forEach vehicles; {if (getNumber(configFile >> "CfgVehicles" >> (typeOf _x) >> "hasDriver")==1 && getNumber(configFile >> "CfgVehicles" >> (typeOf _x) >> "side") == 1) then { _x addEventHandler ["GetOut", "if ((_this select 1) == 'driver') then {{moveOut _x; deleteVehicle _x} forEach crew (_this select 0); hint 'crew deleted';}"];};} forEach vehicles;
In the config "side"=0 is opfor, "side" = 1 is blufor, "side" = 2 is guer, "side" = 3 is civ
Never drive / fly alone again lol!
Example mission - has the functions viewer on radio alpha as well so you can look through the BIS functions
https://dl.dropbox.com/u/37698503/BIS_fnc_spawnCrew.Shapur_BAF.zip
-
http://community.bistudio.com/wiki/say3D
You need to have the sound defined in description.ext
class CfgSounds { sounds[] = {}; class gunshot1 { // how the sound is referred to in the editor (e.g. trigger effects) name = "gunshot1"; // path to filename, volume, pitch sound[] = {"sounds\gunshot1.ogg", 1, 1}; titles[] = {}; }; };
mess with volume till you get it right - 1 is quiet - increase if necessary.
-
It doesn't make sense:
_vehicle = _this select 0; _driver = _this select 1; //if (count crew _unit == 0)) exitwith {}; // this should work to prevent the action to appear if the helicopter is already empty, right? _callout = _vehicle addaction ["Dismiss Crew",1]; _callout = 1; if (_callout ==1) then { {deleteVehicle _x} forEach crew _vehicle; hint "Crew has been dismissed"; _vehicle removeAction action1; //remove the action when pilot gets out };
is the same as:
_vehicle = _this select 0; _driver = _this select 1; //if (count crew _unit == 0)) exitwith {}; // this should work to prevent the action to appear if the helicopter is already empty, right? {deleteVehicle _x} forEach crew _vehicle; hint "Crew has been dismissed"; _vehicle removeAction action1; //remove the action when pilot gets out
The _callout is pointless as it doesn't do anything??? You may as well run the script allth eway through in the 1st place.
This will not work BTW, you can't delete crew while they are sitting in the vehicle - you need to move them out of the vehicle in someway 1st, moveOut/getOut/setPosATL etc:
{deleteVehicle _x} forEach crew _vehicle;
It needs to be:
{moveOut _x; deleteVehicle _x} forEach crew _vehicle;
-
What do you have in crewOut.sqf? that removeAction should work?
If not then you need to broadcast it with either:
_id = _this select 2; [nil, _object, "per", rREMOVEACTION, _id] call RE;
http://community.bistudio.com/wiki/Multiplayer_framework
or
[-2, {_id = _this select 2; _object removeAction _id;},_this] call CBA_fnc_GlobalExecute;
https://dev-heaven.net/docs/cba/files/network/fnc_globalExecute-sqf.html
You will need the CBA addon
_callout = _vehicle addaction ["Dismiss Crew",1];
RE this - I am unfamiliar with this - what does it do exactly? Is it correct syntax in the 1st place?
What I would do is:
_callout = _vehicle addaction ["Dismiss Crew","dismiss.sqf"];
//dismiss.sqf:
_object = _this select 0; _caller = _this select 1; _id = _this select 2; {moveOut _x; deleteVehicle _x;} foreach (crew _object); _object removeAction _id;
If you are deleting and creating the crew based on the 2 EH's not sure why you neeed another option? It can all be done with in the 2 EH's?
-
It's always very important to read the notes on the command wiki, anything that involves vectors like setPitchBank has an odd relationship with setDir. I know your pain well lol.
-
This is without any errors but no idea if it will work as the correct elements might not be in the arrays - you would have to give us more info:
This looks like DAYZ stuff - parts for building a car?
BYBox setvehicleLock "LOCKED"; sleep 0.1; //Build Arrays private ["_cost", "_inv", "_wheel", "_scrap"]; _cost = [ ["PartWheel", 2], ["PartGeneric", 2] ]; _inv = BYBox call BIS_fnc_invstring; _wheel = {_x=="PartWheel"} count _inv; //PROBLEM AREA _scrap = {_x=="PartGeneric" } count _inv; //PROBLEM AREA //Check Box if (_wheel > 2 && _scrap > 2) then { {BYBox removeMagazine _x } forEach _cost; //PROBLEM AREA hint "It works!"; } else { hint "you didn't have enough!!"; }; sleep 0.1; BYBox setVehicleLock "Unlocked";
Command ref: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2
-
GetOut EH works with eject - already tested - not sure about the respawn thing, Foxy is right - it probably only refers to units (players) not vehicles so you would need to re-add it for a new vehicle.
-
Example mission:
http://dl.dropbox.com/u/37698503/HeliEventHandlrTest3.Shapur_BAF.zip
(Had problems with drob box last night so hope this works!)
-
Just use the getOut event handler and change the 0 to a 1:
{if (side _x == CIVILIAN && _x isKindOf "Helicopter") then {_x addEventHandler ["GetOut", "if ((_this select 1) == 'driver') then {(_this select 2) setVariable ['ace_w_allow_dam',1]}"];};} forEach vehicles;
http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#GetOut
(I don't do much MP scripting but thought EH's were automatically readded after respawn? It says this on the wiki:
Multiplayer: Event handlers are persistent (i.e. they stay attached to a unit, even after it dies and respawns). -
Ahh - sorry thought it was the vehicle that required it.
If you look at the getIN EH it passes an array [vehicle, position, unit] so you need to select the right thingy - _this select 2:
try this if the vehicle starts empty:
{if (side _x == CIVILIAN && _x isKindOf "Helicopter") then {_x addEventHandler ["GetIn", "if ((_this select 1) == 'driver') then {(_this select 2) setVariable ['ace_w_allow_dam',0]}"];};} forEach vehicles;
Change CIVILIAN to WEST if there is an AI in gunners seat
Can't test ACE but similar code works - eg this turns light on only if you get in pilots seat:
{if (side _x == CIVILIAN && _x isKindOf "Helicopter") then {_x addEventHandler ["GetIn", "if ((_this select 1) == 'driver') then {(_this select 2) action ['lightOn', (_this select 0)] }"];};} forEach vehicles;
-
Just worked this out for someone else:
{if (side _x == civilian && _x isKindOf "Air") then {_x addEventHandler ["GetIn", "(_this select 0) setVariable ['ace_w_allow_dam',0]"];}} forEach vehicles;
http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#GetIn
Should add it to all empty aircraft.
Untested but has a reasonable chance of success, I hope!
-
Just tested it and found a few errors - sorry!
Use this for empty helicopters - empty helos are side civilian till someone gets in:
{if (side _x == civilian && _x isKindOf "Helicopter") then {_x addEventHandler ["GetIn", "if ((_this select 2) == driver (_this select 0)) then {nul = [(_this select 0),(_this select 2)] execVM 'crewin.sqf'}"];}} forEach vehicles; {if (side _x == civilian && _x isKindOf "Helicopter") then {_x addEventHandler ["GetOut", "if ((_this select 1) == 'driver') then {nul = [(_this select 0),(_this select 2)] execVM 'crewout.sqf'}"];}} forEach vehicles;
In the addaction I left the "" in around the argument so it will be passing "_class" each time lol - remove them:
action1 = _vehicle addaction [("<t color=""#ee6600"">" + ("Recruit Crew") +"</t>"), "crewmaker.sqf",_class, 1, false, true,"","isEngineOn _target && driver _target == _this"];
Also make the handle on the addAction global so getting out removes it as well - my 1st post updated with correct code plus hints that show all is working.
-
Do not edit the mission.sqm - it will break the mission and it will not load unless you relly know what you are doing.
_vehicle_13 = createVehicle ["Land_bags_EP1", [4515.6045, 8497.7813, 3.3981621], [], 0, "CAN_COLLIDE"]; _vehicle_13 setDir 0.48552921; //sure just 0 would be ok here? 9 decimal places for a degree is a bit much! _vehicle_13 setPosATL [4515.6045, 8497.7813, 3.3981621]; _vehicle_13 enableSimulation false;
That's all you need - save it as anynameulike.sqf
init.sqf:
nul = [] execVM "anynameulike.sqf";
-
Delete the line where it says: removeAction
-
In the if - hint format has the wrong syntax, no variable and only 1 element? Tried it with just a hint in there?
-
-
@ Iceman77
Thanks for your proposal. You are right, spawning a crewed chopper looked like the easiest way, In fact I already spawned helos with full crew and ejected+deleted the pilot, but then one of the gunners jumped out of his place and ran to get into the pilot's place!!! it was a sort of musical chairs game for the pilot place! Unfortunately I have no idea on how to glue the gunner to his position on a spawned chopper with full crew minus the pilot.
That sort of behaviour is always due to 1 thing - the group leader giving commands. You see, he knows the helicopter should have a pilot and he knows best!
To stop that you need to make them all join the player's group with the player as leader after you have deleted the AI pilot:
_spawnPos = [getPosATL _caller select 0,getPosATL _caller select 1, 500]; _dir = getDir _caller; _vehArray = [_spawnPos, _dir, "UH60M_EP1", WEST] call bis_fnc_spawnvehicle; //you need a functions module (F7) on the map - see notes on createCentre or it will spawn empty _heli= _vehArray select 0; _pilot = driver _heli; deleteVehicle _pilot; _caller moveInDriver _heli; {[_x] joinSilent group _caller} forEach crew _heli - [_caller]; //useful item that for running things on the crew excepting the player group _caller selectLeader _caller; /*Warning - In Multiplayer the selectLeader command has to be executed on the client where the group is actually local - note on wiki. Should be ok as when the player enters the vehicle, the vehicle and crew become local? */
http://community.bistudio.com/wiki/Category:ArmA_2:_Functions
http://community.bistudio.com/wiki/BIS_fnc_spawnVehicle
Or: this works on a group if you move them into a building and makes them stay in the buidling positions, (not sure if it will work while the group is in a vehicle), the group leader always rearranges them back into formation so:
_pilot = driver _heli; _grp = group _pilot; _lst = units _grp; _ldr = leader _grp; {[_x] joinsilent grpNull;} forEach _lst -[_ldr]; //each unit gets it's own group and can't then be commanded to move elsewhere //later you can merge them back into the original group waitUntil {var_enemyAttack}; // var_enemyAttack = true; in a trigger activated by opfor {[_x] joinsilent _grp;} forEach _lst -[_ldr];
-
You have only 4 playable units per side and maxPlayers = 12; in the server.cfg ?
-
^ init fields if you still want to try to use triggers:
handle = (thislist select 0) execVM "script.sqf";
(thislist select 0) gets the relevant unit, don't reassign player
-
phew - there is much wrong there (there were also a few things wrong in this post! - all updated and working - tested):
-see wiki for syntax references: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2
-don't start execVM's with a number handle
-Is there a reason behind naming every crew member? Can't see why it's necessary:
-init: lines are completely wrong should be: handle = (thislist select 0) execVM "script.sqf"; (thislist select 0) gets the relevant unit as said below don't reassign player
-if (_helotype == UH1Y) then - typeOf returns a string - should be "UH1Y"
- in crewout your addAction has no filename see http://community.bistudio.com/wiki/addAction
- if (_callout ==1) then - _callout must be defined somewhere (can't use an addaction to do it)
_callout = 1; if (_callout ==1) then {};
-rather than triggers - an eventHandler might be better for MP?
to add EH to all blufor helicopters with crew at beginning of mission, script will only work when driver gets in - init.sqf:
{if (side _x == WEST && _x isKindOf "Helicopter") then {_x addEventHandler ["GetIn", "if ((_this select 2) == driver (_this select 0)) then {[(_this select 0),(_this select 2)] execVM 'crewin.sqf'}"];};} forEach vehicles; {if (side _x == WEST && _x isKindOf "Helicopter") then {_x addEventHandler ["GetOut", "if ((_this select 1) == 'driver') then {[(_this select 0),(_this select 2)] execVM 'crewout.sqf'}"];};} forEach vehicles;
1st one above could also have condition:
{if (side _x == CIVILIAN && _x isKindOf "Helicopter ") then {};
to only add for helicopters with no crew.
crewin.sqf
_vehicle = _this select 0; _driver = _this select 1; _class = typeOf _vehicle; action1 = _vehicle addaction [("<t color=""#ee6600"">" + ("Recruit Crew") +"</t>"), "crewmaker.sqf",_class, 1, false, true,"","isEngineOn _target && driver _target == _this"]; //addaction is only available to driver when engine is on hint "crewIn";
crewout.sqf
_vehicle = _this select 0; _driver = _this select 1; hint "crewOut"; _vehicle removeAction action1; //remove the action when pilot gets out //more code here
crewmaker.sqf
_vehicle = _this select 0; _caller = _this select 1; _id = _this select 2; _helotype = _this select 3; //_class passed in addAction arguments player sidechat format["%1", _helotype]; hint "crewMaker"; _vehicle removeAction _id; //remove the action once it is activated //make crew here
You will also need to check locality issues with all the above - the vehicle will move from the server to the player's client when the player gets in so you might need conditions to check where the scripts run with isServer, isLocal , isDedicated etc. see:
http://community.bistudio.com/wiki/Locality_in_Multiplayer
http://community.bistudio.com/wiki/6thSense.eu:EG
One concern is the AI you create - it migth be best to have them join the players group as you create them so the player and the AI are all in the same locality?
-
It's not free - you are supposed to already have a licence, so just downloading it and installing it is not legal, just possible. Are they going to chase all those that downloaded now? Aslo it's not designed for Windows 7/8 - could cause probems?
UPDATE, 2:40 p.m. PT: There has been clarification since this story broke. Adobe has not released the CS2 software for free. Instead, it has cancelled its CS2 license management servers, so for those with existing licenses it is now offering downloads that do not require contact with the licensing servers. This service is only going to be available for those with existing Adobe CS2 licenses, which will be verified when creating the Adobe account to download the software.Adobe's popular Creative Suite has been developed way beyond the capabilities of the initial versions of the software; however, older versions such as CS2 are still very powerful image-manipulation and content-creation tools. Still, they are no longer supported by the company and could cause problems or fail to run when installed on computers running the latest versions of OS X or Windows.
-
Not got much time to look but can suggest the following:
That 1st line should be (however you define the caller is up to you):
[player] execVM "buy.sqf";
_unit = _this select 0;
if (side _unit == west) then { ..code here.. };
if (side _unit == east) then { ..code here.. };
if (side _unit == guer) then { ..code here.. };
You should also probably create different marker names each time the script is run to avoid running code on markers already created with same name, define var_buy somewhere - you may need 3 differnet variables - 1 for each side to keep track of things? eg var_buy_guer etc:
var_buy_guer = 0; publicVariable "var_buy_guer";
if (isdedicated) exitWith {}; if (side _unit == guer) then { var_buy_guer = var_buy_guer +1; publicVariable "var_buy_guer"; _pos = [getPosATL _unit select 0, getPosATL _unit select 1]; _mkr = createMarkerLocal [format["mkr%1", var_buy_guer], _pos]; // creates different marker names depending on value of var_buy at current position of _unit. _mkr setMarkerShapeLocal "ICON"; _mkr setMarkerTypeLocal "DOT"; _mkr setMarkerTextLocal format["buy%1",var_buy_guer]; };
Using Foreach and Count Properly
in ARMA 2 & OA : MISSIONS - Editing & Scripting
Posted · Edited by Mattar_Tharkari
edit: Just tested it and had a look at the functions viewer - BIS_fnc_invstring is the correct function - don't think you are calling it correctly - should be:
Tested it in game with:
try it in and out of vehicles
or:
_content = getMagazineCargo carName;
http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2
http://community.bistudio.com/wiki/getMagazineCargo