Jump to content

Grumpy Old Man

Member
  • Content Count

    4333
  • Joined

  • Last visited

  • Medals

Everything posted by Grumpy Old Man

  1. Depends on how idiot proof you want to do this. Are there other backpacks of the same type in the mission? If yes, then you should keep track which player picked it up and keep track if the backpack has been passed to other players, could be tricky/impossible if the backpack ends up inside a vehicles cargo storage, together with other backpacks of the same type. A simple approach would be this: //initPlayerLocal.sqf player addEventHandler ["Put", { params ["_unit", "_container", "_item"]; if (_item isEqualTo "B_Messenger_Coyote_F" AND _unit distance dropPoint < 2) then {missionNamespace setVariable ["GOM_fnc_backpackDelivered",true,true]}; }]; And in the trigger that sets the task when the backpack has been dropped: time > 3 AND missionNamespace setVariable ["GOM_fnc_backpackDelivered",true] Also place an object where the backpack should be dropped, dropPoint in this example, task will only return true when the BP has been dropped within 2m of the droppoint. Only foolproof if this backpack is the only one of its type in the mission. Demo mission. Cheers
  2. Grumpy Old Man

    Can't find missing semicolon

    waitUntil {_playerCalling distance _type > 10}; Most likely this line. _type holds an array of strings, distance expects an object or location. Cheers
  3. Set it up like this: //initPlayerLocal.sqf player addEventHandler ["Take", { params ["_unit", "_container", "_item"]; if (_container isEqualTo YourBackPackUnit AND _item isEqualTo "B_Messenger_Coyote_F") then {missionNamespace setVariable ["GOM_fnc_backpackTaken",true,true]}; }]; Trigger condition that changes task state: time > 3 AND missionNamespace getVariable ["GOM_fnc_backpackTaken",false] Demo mission. Cheers
  4. There's multiple ways. How are you handling your tasks? Via script or editor modules? Cheers
  5. Try this: //init field of player or wherever you seem fit: this addEventHandler ["Take", { params ["_unit", "_container", "_item"]; if (_container isEqualTo YourBackPackUnit AND _item isEqualTo "B_Messenger_Coyote_F") then {systemchat "Backpack taken!"}; }]; Place a unit holding the respective backpack and name it YourBackPackUnit. Should do the trick. Adding the money pile as item isn't possible without a mod, as far as I know. Cheers
  6. Grumpy Old Man

    How To Change Countermeasures

    No idea if it's even possible to attach a lightPoint to the flare projectile, since CMFlares returns objNull on a fired eventhandler, at least last time I checked. Made something similar for UGL or mortar/arty flares. Thread might still be worth a read. Only some ugly workaround like spawning a physx object like a small can, give it appropriate movement vectors and attach the spawned lightpoint to them could probably do the trick. Doubt it'll be performance friendly though. Cheers
  7. Grumpy Old Man

    setHitPointDamage = local ??

    You're passing 3 parameters in wrong syntax to the setHitPointDamage command via remoteExec. Try this: [_x, ["hitFuel", 0.5]] remoteExec ["setHitPointDamage", _x]; Cheers
  8. Grumpy Old Man

    AI Discussion (dev branch)

    Do you have a repro mission for that? Which tank/target? AI gunner not aiming straight at a target is usually caused by wrong weapon (selected machine gun when target is a tank) or there's no clear line of sight. Cheers
  9. Grumpy Old Man

    DESTROY waypoints not working

    No worries, he doesn't want help anyway: Cheers
  10. Grumpy Old Man

    NIArms Release Thread

    Depends, can you dual wield the Mk.17? Cheers
  11. Grumpy Old Man

    AI Discussion (dev branch)

    Is the cannon the currently selected weapon of the gunner? Cheers
  12. Grumpy Old Man

    Player teleport outside Trigger

    Probably not that important in a simple script like that, but defining a variable named _side that's holding a string data type will just open a can of worms in the long run. Variables should always give at least a hint to what they're holding. You're also not passing the _caller to the teleportUnit.sqf. It's also easier to use find and select in this case, since the amount of sides are finite, something like this is easy to read and adjust: //on Activation: null = [player] execVM "teleport\teleportUnit.sqf"; //teleportUnit.sqf params ["_caller"]; _markers = ["bluforspawn","opforspawn","indforspawn","civspawn"];//just some examples _sides = [west,east,resistance,civilian];//west will select "bluforspawn" and so on _index = _sides find side _caller; if (_index isEqualTo -1) exitWith {systemchat "Invalid side, no teleport chosen"};//exit just in case _marker = _markers select _index; _caller setPos getMarkerPos _marker; Cheers
  13. Grumpy Old Man

    No errors but no result either

    You're missing the second quotation mark for fnc_RadioMessage. Cheers
  14. Grumpy Old Man

    Conflict?

    Did you try asking the respective mod authors? The mission editing and scripting forum is barely the right place for discussing mods/mod issues. Cheers
  15. Grumpy Old Man

    Player teleport outside Trigger

    Check the syntax. getPos only works with objects or locations. If you need to get a markers position you need to use getMarkerPos together with a string. _caller setPos (getpos (bluforspawn));//won't work _caller setPos (getMarkerPos "bluforspawn");//should work Cheers
  16. Grumpy Old Man

    Script obfuscating

    So if Mozart composed a concerto for solo violin, the violin manufacturer becomes the owner? That's not how it works, heh. Cheers
  17. Grumpy Old Man

    General Discussion (dev branch)

    New threat? SAM sites have been important and incredibly powerful since their introduction with jets DLC, if properly set up. With a wee bit of initial set up you can make AA missile platforms fire over 10km+. Transmitting information from a radar scouting vehicle to a dedicated SAM system or site (all seem to be limited to 16km receiving range) you can easily build a network to cover all airspace. Fortunately for all pilots no MP missions are utilizing this: Imagine having something like this on KotH. Cheers
  18. Grumpy Old Man

    Player Proximity Scan

    Well you went from wanting a simple hint over an addAction and now it should only run for n seconds. Best make up your mind regarding wanted functionality first. Doubt it's considered convenient having to activate an addAction every 5 seconds but here you go: GOM_fnc_scan = { params [["_scanObject",objNull],["_scanRadius",15],["_duration",5],["_debug",false]]; _scanObject setVariable ["GOM_fnc_scanActive",true,true]; if (_debug) then {systemChat "Starting to scan!"}; hint "Starting to scan!"; sleep 1; _stopTime = time + _duration; waitUntil { _nearPlayers = (_scanObject nearEntities _scanRadius) - [player] select {isPlayer _x}; hintsilent format ["Scan duration: %1\nPlayers detected: %2",[-(time - _stopTime),"HH:MM"] call BIS_fnc_timeToString,count _nearPlayers]; time > _stopTime }; if (_debug) then {systemChat "Stopped scanning!"}; _scanObject setVariable ["GOM_fnc_scanActive",false,true]; hint "Stopped scanning!"; }; //add scan action to object player addAction ["5s Scan for Players",{ params ["_object","_caller","_ID"]; _scan = [_object,15,5] spawn GOM_fnc_scan; },[],0,true,true,"","_this isEqualTo vehicle _this AND !(_this getVariable ['GOM_fnc_scanActive',false])",5]; Cheers
  19. Grumpy Old Man

    Player Proximity Scan

    If you want every player to have the addaction on all of the objects simply put the above example into initPlayerLocal.sqf, so every client connecting will receive the actions automatically. Cheers
  20. Grumpy Old Man

    Player Proximity Scan

    GOM_fnc_scan = { params [["_scanObject",objNull],["_scanRadius",15],["_debug",false]]; if (_debug) then {systemChat "Starting to scan!"}; hint "Starting to scan!"; sleep 1; waitUntil { _nearPlayers = _scanObject nearEntities _scanRadius select {isPlayer _x}; hintsilent format ["Players detected:\n%1",count _nearPlayers]; !(_scanObject getVariable ["GOM_fnc_scanActive",true]) }; if (_debug) then {systemChat "Stopped scanning!"}; hint "Stopped scanning!"; }; //add scan action to object test addAction ["Scan for Players",{ params ["_object","_caller","_ID"]; if (_object getVariable ["GOM_fnc_scanActive",false]) exitWith { _object setUserActionText [_ID,"Scan for Players"]; _object setVariable ["GOM_fnc_scanActive",false,true]; }; _object setUserActionText [_ID,"Stop scanning for Players"]; _object setVariable ["GOM_fnc_scanActive",true,true]; _scan = [_object,15] spawn GOM_fnc_scan; },[],0,true,true,"","_this isEqualTo vehicle _this",5]; You can activate/deactivate the scanning with a single action, should work fine. What do you mean? This will detect all players, or do you want to add the action for every player? Cheers
  21. Grumpy Old Man

    Player Proximity Scan

    Something like this could do the trick: //init.sqf or wherever you seem fit GOM_fnc_scan = { params [["_scanObject",objNull],["_scanRadius",15],["_debug",false]]; GOM_scanActive = true; if (_debug) then {systemChat "Starting to scan!"}; waitUntil { _nearPlayers = _scanObject nearEntities _scanRadius select {isPlayer _x}; hintsilent format ["Players detected:\n%1",count _nearPlayers]; !(_scanObject getVariable ["GOM_fnc_scanActive",true]) }; if (_debug) then {systemChat "Stopped scanning!"}; }; //call function in object init field _scan = [test,15] spawn GOM_fnc_scan; //to disable scanning sometime later, if needed: test setVariable ["GOM_fnc_scanActive",false,true]; Cheers
  22. Well you can always add more randomness, or even weighted randomness. You could do something like this: _spawnParams = [["B_MRAP_01_F","startPos","NONE"], ["B_APC_Tracked_01_CRV_F","startPos","NONE"], ["B_MBT_01_cannon_F","startPos","NONE"], ["B_Heli_Light_01_armed_F","startPos","FLY"] ]; _rndSpawn = selectRandom _spawnParams; _rndSpawn params ["_type","_marker","_special"]; _veh = createVehicle [_type, getMarkerPos _marker, [], 0, _special]; _veh setVehicleVarName _vehicleVarName; _veh call compile format ["%1=_this;", _vehicleVarName]; Or use selectRandomWeighted to make certain types appear more often, with a number between 0 and 1 determining the chance of selection: _spawnParams = [["B_MRAP_01_F","startPos","NONE"],0.5, ["B_APC_Tracked_01_CRV_F","startPos","NONE"],0.35, ["B_MBT_01_cannon_F","startPos","NONE"],0.2, ["B_Heli_Light_01_armed_F","startPos","FLY"],0.1, ]; _rndSpawn = selectRandomWeighted _spawnParams; _rndSpawn params ["_type","_marker","_special"]; _veh = createVehicle [_type, getMarkerPos _marker, [], 0, _special]; _veh setVehicleVarName _vehicleVarName; _veh call compile format ["%1=_this;", _vehicleVarName]; This way you could even randomize markers for spawn position and other stuff. Cheers
  23. Works as intended, first one returns 0.5, second one 0.1. Cheers
  24. _playerName is not defined inside the onMapSingleClick command. Replace it with "name player". Cheers
  25. Why use a switch statement for that? Or was it just for testing purposes? Take a look at scope and scope locality, since a variable is only local to the scope it was created in. As pointed out by @AZCoder you need to define _veh before the switch statement, so the variable exists outside of its scope. To give a vehicle a unique variable name you could use a global approach, not sure what you're trying to achieve with that while loop: if (!isServer) exitWith {}; params [["_veh",objNull],["_driver",objNull],["_group",grpNull],["_unitArray",[]]];//define variables as private and give them default values _myVar = floor random 4; _vehicleVarNameBase = "mts_RandomVic"; //alternative approach to unique var names: _vehicleVarNameNo = missionNamespace getVariable ["TAG_fnc_myVehCounter",1];//will return 1 for the first spawned vehicle and increase with every spawned one _vehicleVarName = _vehicleVarNameBase + str _vehicleVarNameNo; //remove this if my approach is working out for you /* _vehicleVarNameNo = 1; _vehicleVarName = _vehicleVarNameBase + str _vehicleVarNameNo; while {!(isNil _vehicleVarName)} do { _vehicleVarNameNo = _vehicleVarName + 1; _vehicleVarName = _vehicleVarNameBase + str _vehicleVarNameNo; }; */ switch (_myVar) do { case 0: { _veh = createVehicle ["B_MRAP_01_F", getMarkerPos "startPos", [], 0, "NONE"]; _veh setVehicleVarName _vehicleVarName; _veh call compile format ["%1=_this;", _vehicleVarName]; }; case 1: { _veh = createVehicle ["B_APC_Tracked_01_CRV_F", getMarkerPos "startPos", [], 0, "NONE"]; _veh setVehicleVarName _vehicleVarName; _veh call compile format ["%1=_this;", _vehicleVarName]; }; case 2: { _veh = createVehicle ["B_MBT_01_cannon_F", getMarkerPos "startPos", [], 0, "NONE"]; _veh setVehicleVarName _vehicleVarName; _veh call compile format ["%1=_this;", _vehicleVarName]; }; case 3: { _veh = createVehicle ["B_Heli_Light_01_armed_F", getMarkerPos "startPos", [], 0, "FLY"]; _veh flyInHeight 50; _veh setVehicleVarName _vehicleVarName; _veh call compile format ["%1=_this;", _vehicleVarName]; }; }; //increase the vehicle counter missionNamespace setVariable ["TAG_fnc_myVehCounter",_vehicleVarNameNo + 1,true]; _group = createGroup west; _driver = _group createUnit ["B_crew_F", getMarkerPos "startPos", [], 0, "FORM"];//you can also reference the driver using this _unitArray = units _group;//no need for more than this since units group returns an empty array if no units are in the group _driver assignAsDriver _veh; _driver moveInDriver _veh; _wp = _group addWaypoint [getMarkerPos "endPos",0]; [_group,0] setWaypointType "MOVE"; [_group,0] setWaypointCompletionRadius 50; [_group,0] setWaypointSpeed "LIMITED"; //_veh doesn't exist inside the scope as mentioned before, you can use "thisList" for an array of units in the group, or "this" for the group leader _wp setWayPointStatements ["true","deleteVehicle vehicle this;{deleteVehicle _x} forEach thisList"]; Also take a look at setWaypointStatements, this refers to the group leader, while thisList holds an array of units that are in the group. Cheers
×