Doodle 10 Posted February 4, 2014 Wonder if anyone can help. On a dedi server I am looking for a way to lock all enemy vehicles that are both pre placed in editor and spawned in during the mission. Maybe something that could go in the init.sqf? Ideally it would be some sort of array that I could add and remove vehicles class names from as I need this way I can allow blufor access to some enemy vehicles to be used. The more drastic measure would be to lock ALL enemy vehicles from blufor. Thanks in advance Share this post Link to post Share on other sites
fight9 14 Posted February 4, 2014 something like this might work. Maybe, I might be misunderstanding nearestObjects. You can add more vehicle classnames in the array. //// null = [] execVM "vehicleLock.sqf"; while {true} do { _opforVics = nearestObjects [player, ["O_MRAP_02_F","O_Truck_02_covered_F"], 1000]; {_x setVehicleLock "LOCKED"} foreach _opforVics; sleep 180; }; Share this post Link to post Share on other sites
Doodle 10 Posted February 5, 2014 Intresting way of doing it - On a dedi server would "player" refer to all HUMAN players? - there are only blue for human player? Thanks Will have a test and report back Share this post Link to post Share on other sites
fight9 14 Posted February 5, 2014 Assuming you execute it globally, it should run for all human players. Share this post Link to post Share on other sites
Doodle 10 Posted February 5, 2014 would the best way would be to run null = [] execVM "vehicleLock.sqf"; from init.sqf? Thanks in advance Share this post Link to post Share on other sites
fight9 14 Posted February 5, 2014 Yeah, that or a trigger. Share this post Link to post Share on other sites
Doodle 10 Posted February 6, 2014 Perfect! Many thanks Share this post Link to post Share on other sites
KC Grimes 79 Posted February 6, 2014 What you have will work for editor-placed vehicles and only script-spawned vehicles that spawn before you execute that line in the init. You're better off setting vehicles to locked as you spawn them, but another option is looping the lock script every so often. I suggest just locking at spawn though. Share this post Link to post Share on other sites
fight9 14 Posted February 6, 2014 ;2616705']What you have will work for editor-placed vehicles and only script-spawned vehicles that spawn before you execute that line in the init. You're better off setting vehicles to locked as you spawn them' date=' but another option is looping the lock script every so often. I suggest just locking at spawn though.[/quote']It is in a while loop...? Share this post Link to post Share on other sites
KC Grimes 79 Posted February 6, 2014 It is in a while loop...? Woops, sorry, didn't see that. For whatever reason the comment threw me off :P Disregard. Share this post Link to post Share on other sites
fight9 14 Posted February 7, 2014 No worries. I was just little confused. I do agree though that locking from the vehicle INIT is the best solution. Use the above if that isn't an option for what ever reason, or you don't want to try to edit whatever spawn script you are using. Share this post Link to post Share on other sites
Doodle 10 Posted February 12, 2014 something like this might work. Maybe, I might be misunderstanding nearestObjects. You can add more vehicle classnames in the array. //// null = [] execVM "vehicleLock.sqf"; while {true} do { _opforVics = nearestObjects [player, ["O_MRAP_02_F","O_Truck_02_covered_F"], 1000]; {_x setVehicleLock "LOCKED"} foreach _opforVics; sleep 180; }; Thought this had worked but unfortunately after a long test last night - I dont think this worked as blufor where still able to get in vehicles. Any ideas? Thanks in advance Share this post Link to post Share on other sites
KC Grimes 79 Posted February 12, 2014 Thought this had worked but unfortunately after a long test last night - I dont think this worked as blufor where still able to get in vehicles.Any ideas? Thanks in advance Well, two things. First note that what you have there only consists of 2 classnames, thus 2 vehicles. I feel like you have more than 2 types of vehicles in the mission. As well, who "player" is depends on how you execute the script. If you're on a DS and the server executes, player is nothing. You'll need to execute it on all clients. Share this post Link to post Share on other sites
fight9 14 Posted February 12, 2014 Also, it locks every vehicle for 1km every 3 minutes. If your are traveling faster than that, then you have a chance of finding an unlocked vehicle. Adjust the distance and sleep values and add more vehicle classnames in same format. Share this post Link to post Share on other sites
Doodle 10 Posted February 12, 2014 Sorry should have been more clear this is the actual array of vehicles I am using. while {true} do { _opforVics = nearestObjects [player, ["O_APC_Tracked_02_cannon_F","O_APC_Wheeled_02_rcws_F","O_MBT_02_cannon_F","O_MRAP_02_hmg_F","O_Heli_Attack_02_black_F","O_Heli_Attack_02_F","I_APC_Wheeled_03_cannon_F","I_APC_tracked_03_cannon_F","I_MBT_03_cannon_F","I_MRAP_03_hmg_F"], 1000]; {_x setVehicleLock "LOCKED"} foreach _opforVics; sleep 180; }; And I am execing it in the init.sqf with null = [] execVM "vehicleLock.sqf"; But re the below and I think if anyone can answer this it might help me understand what a "player on a DS is" as I have never been able to fully understand it and it might help me solve another couple of issues. Well, two things. First note that what you have there only consists of 2 classnames, thus 2 vehicles. I feel like you have more than 2 types of vehicles in the mission. As well, who "player" is depends on how you execute the script. If you're on a DS and the server executes, player is nothing. You'll need to execute it on all clients. how would I exec this for all "players" on a dedi server. thanks in advance Share this post Link to post Share on other sites
fight9 14 Posted February 12, 2014 Since you are using the INIT.sqf, it should run for all players, I think. Did it just stop working or did you happen to travel somewhere quickly and find an unlocked vehicle before the 3 min loop restarted? There's probably a simpler solution to doing this than using the loop above. How are you spawning vehicles during the mission? Share this post Link to post Share on other sites
Doodle 10 Posted February 12, 2014 WOW quick reply When I tested from editor vehicles seemed to be locked - hence my "perfect" post above - buy alas as we all know ARMA MP is a different thing On our dedi last night it didnt lock the vehicles Didnt travel anywhere quickly so its not as if we arrived before the three min timer Vehicles are being spawned in using EOS. I am sure it is something to do with "player" on a dedi server - there is another issue I am having with something else that I think isnt working cos of the "player" on dedi thank in advance Share this post Link to post Share on other sites
KC Grimes 79 Posted February 12, 2014 Are your playable units in a group or groups? Could always just define the leader of the group as a variable and run the script solely off squad leaders. Share this post Link to post Share on other sites
Doodle 10 Posted February 12, 2014 they are one group of 9 players Running it off the squad leader would be fine but I have no idea how too thanks guys Share this post Link to post Share on other sites
KC Grimes 79 Posted February 12, 2014 Just name the squad leader in the editor something like squadleader. This does require that someone plays that position, however. init.sqf [] execVM "vehicleLock.sqf"; vehicleLock.sqf while {true} do { _opforVics = nearestObjects [squadleader, ["O_APC_Tracked_02_cannon_F","O_APC_Wheeled_02_rcws_F","O_MBT_02_cannon_F","O_MRAP_02_hmg_F","O_Heli_Attack_02_black_F","O_Heli_Attack_02_F","I_APC_Wheeled_03_cannon_F","I_APC_tracked_03_cannon_F","I_MBT_03_cannon_F","I_MRAP_03_hmg_F"], 1000]; {_x setVehicleLock "LOCKED"} foreach _opforVics; sleep 180; }; Share this post Link to post Share on other sites
chessmaster42 11 Posted February 12, 2014 (edited) In order to run for all players on an MP server you need something like this in your init: [[[], "vehicleLock.sqf"], "BIS_fnc_execVM", true, false] spawn BIS_fnc_MP; There are much better ways to handle what you're doing in that loop but if it works it works :) Edited February 12, 2014 by chessmaster42 Missed a param in the code Share this post Link to post Share on other sites
Doodle 10 Posted February 13, 2014 @Grimes [3rd ID] i tried doing this but i was running [color="#FF0000"]null = [] execVM "vehicleLock.sqf";[/[/color]CODE] didnt seem to work would it make a difference running[code] [color="#FF0000"][] execVM "vehicleLock.sqf";[/color] from the init? @chessmaster42 If theres a better way to do this care to share so we can all learn Thx guys Share this post Link to post Share on other sites
fight9 14 Posted February 13, 2014 Having the "null =" won't make a difference here. It's good practice though since the editor won't let you run execVM unless you have a return value, even if it's null. I know EOS lets you edit the init of a unit, I'll look into locking for it later. Share this post Link to post Share on other sites
chessmaster42 11 Posted February 13, 2014 (edited) This would probably capture more of what you're trying to do: init.sqf call compile preprocessFile "vehicleLock.sqf"; vehicleLock.sqf VL_East_Global = { { //Side of vehicle is determined by commander, then gunner, then others if((side _x) == "EAST") then { _x setVehicleLock "LOCKED"; }; } foreach vehicles; }; while {true} do { //Run the vehicle lock globally (i.e. all clients and server) [[], "VL_East_Global", true, false] spawn BIS_fnc_MP; sleep 180; }; I haven't tested this yet but it should work. Edited February 13, 2014 by chessmaster42 Changed some very bad code Share this post Link to post Share on other sites
Doodle 10 Posted February 13, 2014 This would probably capture more of what you're trying to do:init.sqf call compile preprocessFile "vehicleLock.sqf"; vehicleLock.sqf VL_East_Global = { { //Side of vehicle is determined by commander, then gunner, then others if((side _x) == "EAST") then { _x setVehicleLock "LOCKED"; }; } foreach vehicles; }; while {true} do { //Run the vehicle lock globally (i.e. all clients and server) [[], "VL_East_Global", true, false] spawn BIS_fnc_MP; sleep 180; }; I haven't tested this yet but it should work. Thanks for this - will test tonight and report back. I know you havent tried it yet but do you think it will be ok on a dedi? Thnaks in advance Share this post Link to post Share on other sites