armatoday 12 Posted December 5, 2016 Hi, Below script -published here- turns not working with Dedicated Server after 1.66 Update. Any help really be appreciated Mission init.sqf [] execVM "scripts\Restrictions\Restrictions.sqf"; scripts\Restrictions\Restrictions.sqf BAKE_VREST_RESTRICTIONS = [ ["blackHawk", "a10"], [ [['["Driver"]'], ["pilot_1", "pilot_2"], "Pilots only."], ], ["a10"], [ [['["Driver"]'], ["123", "456"], "Members only."] ] ]; execVM "scripts\Restrictions\init.sqf"; scripts\Restrictions\init.sqf if (isDedicated) exitWith {}; waitUntil {!isNull player}; BAKE_VREST_RESTRICTIONS = missionNamespace getVariable ["BAKE_VREST_RESTRICTIONS", []]; BAKE_VREST_CHECK_INTERVAL = missionNamespace getVariable ["BAKE_VREST_CHECK_INTERVAL", 0.1]; BAKE_VREST_SHOW_ROLE = missionNamespace getVariable ["BAKE_VREST_SHOW_ROLE", false]; while {true} do { _vehicle = vehicle player; if (_vehicle != player) then { _role = str assignedVehicleRole player; if (BAKE_VREST_SHOW_ROLE) then { hintSilent _role; copyToClipboard _role; }; for "_i" from 1 to count BAKE_VREST_RESTRICTIONS step 2 do { if (str _vehicle in (BAKE_VREST_RESTRICTIONS select (_i - 1))) then { { _restrictedRoles = _x select 0; _playerWhitelist = _x select 1; if (_role in _restrictedRoles && !(str player in _playerWhitelist) && !(getPlayerUID player in _playerWhitelist)) exitWith { moveOut player; titleText [_x select 2, "PLAIN", 0.2]; }; } forEach (BAKE_VREST_RESTRICTIONS select _i); }; }; }; sleep BAKE_VREST_CHECK_INTERVAL; }; Thank you for your help in advance Share this post Link to post Share on other sites
Larrow 2822 Posted December 5, 2016 Code updated see post #ThereAreNoNumbersAnyMore:( Note the change in structure for BAKE_VREST_RESTRICTIONS, plus vehicle, player and positions names must be in lower case. Think that works out right - untested. 1 Share this post Link to post Share on other sites
armatoday 12 Posted December 6, 2016 Larrow thank you for your time. Will inform you if it works Share this post Link to post Share on other sites
armatoday 12 Posted December 6, 2016 Larrow, Good news is your script is working on DS for "driver" only. But, i could not use the vehicle slots with your script as it used to -like: BAKE_VREST_RESTRICTIONS = [ ["ghost1"], [ [['["driver"]'], ["helipilot"], "Notification comes here. "] ], ["ghost1"], [ [['["turret",[0]]'], ["helipilot","helicrew"], "Notification comes here. "] ], ["ghost1"], [ [['["turret",[1]]'], ["helipilot","sl","tl"], "Notification comes here."] ], ["ghost1"], [ [['["turret",[2]]'], ["helipilot","sl","tl"], "Notification comes here."] ], ["apc"], [ [['["driver"]'], ["crewman"], "Notification comes here. "] ], ["apc"], [ [['["turret",[0,0]]'], ["sl","tl"], "Notification comes here. "] ] ]; As shown above, - Pilot slot ("driver") fly the aircraft. CoPilot (Helicopter Crew) slot ["turret",[0]] can be used by both Helicopter Pilot and Helicopter Crew roles. - For the APC , "driver" is a Crewman and the slot ["turret",[0,0]] which is Commander's Seat is reserved for Squad Leader or TeamLeader (respresented by "sl" and "tl") I really insist on this script because, this one is the easiest-customizable-codding free one i guess. :=) On the other hand, With your script or ARMA update - i dont know which of them - the slot names are changed from "turret" to "gunner". "driver" has no problem but i tried with both "gunner" and "turret" with no luck. But the problem is, i guess, i could not implement the correct use of brackets and quatations for formats like ["gunner",[0]] - which i am really confused. Thank you for all kind responses in advance. Share this post Link to post Share on other sites
Larrow 2822 Posted December 13, 2016 Try this, unfortunately i didnt get it in before the forum went down. BAKE_VREST_RESTRICTIONS = [ "ghost1", //vehicle var name [ //ARRAY of restricted positions, either position name "driver", turret path [0] Or //full turret path [ "gunner", [0,0] ], multiples of [ "driver" ], //player var names OR UIDs OR trait [ "helipilot", "isPilot" ], //Messsage to show "Only the pilots are allowed to fly this" ], "ghost1", [ [ [0] ], //CoPilot turret path [ "helipilot", "helicrew", "canCoPilot" ], //Only players named helipilot and helicrew or have trait canCoPilot "Only the helicopter crew are allowed to copilot" ], "ghost1", [ [ [1], [2] ], //GhostHawk side gunner turret paths [ "helipilot", "sl", "tl", "isGunner" ], //Only player named helipilot, sl OR tl OR has trait isGunner "Only the helipilot or squad/team leader are allowed in gunner seats" ], "apc", [ [ "driver" ], [ "crewman", "isDriver" ], "Only crewmen and designated drivers are allowed to drive this vehicle" ], "apc", [ //Example of a Full turret path for Marshall Commander //could be just replaced as [0,0] [ ["turret",[0,0]], ["commander",[0,0]] ], //Both valid full commander turret paths, depends how you enter [ "sl", "tl", "canCommand" ], "Only the squad/team leader or units with approved command status are allowed in the commanders chair" ], "apc", [ [ [0] ], //Marshall Gunner turret path [ "sl", "tl", "isGunner" ], "Only the squad/team leader or gunners are allowed in the gun turret" ] ]; //Allow debug of positions BAKE_VREST_SHOW_ROLE = true; //Exit if we are not a player client if !( hasInterface ) exitWith {}; TAG_fnc_checkVehicleRestrictions = { params[ "_unit", "_position", "_vehicle", "_turretPath", [ "_switched", false ] ]; //Show debug info if ( BAKE_VREST_SHOW_ROLE ) then { hintSilent format[ "Position - %1\nTurretPath - %2\nFull Path - %3", str _position, _turretPath, [ _position, _turretPath ] ]; copyToClipboard format[ "Position - %1\nTurretPath - %2\nFull Path - %3", str _position, _turretPath, [ _position, _turretPath ] ]; }; //Are we switching seats _canSwitchBack = if !( _switched ) then { //If not then we must be getting in a vehicle //Store players vehicle role _unit setVariable [ "BAKE_lastPosition", [ _position, _turretPath ] ]; //Flag as unable to switch back to an internal vehicle position { false } }else{ //Return function that switches player back to his previous vehicle position { params[ "_unit", "_vehicle" ]; ( _unit getVariable "BAKE_lastPosition" ) params[ "_position", [ "_turretPath", [] ] ]; //If we dont have a turret path if ( _turretPath isEqualTo [] ) then { //Find our position name switch toLower _position do { case "driver" : { //If there is no current driver if ( isNull ( driver _vehicle ) ) then { //Fix as we cannot move in from an internal position _unit setPos [0,0,0]; //Move the player back in as driver _unit moveInDriver _vehicle; //Move was successful true }else{ //Move was unsuccessful false }; }; case "cargo" : { //If there are empty cargo positions if ( _vehicle emptyPositions "cargo" > 0 ) then { //Fix as we cannot move in from an internal position _unit setPos [0,0,0]; //Move player into cargo _unit moveInCargo _vehicle; //Move was successful true }else{ //Move was unsuccessful false }; }; }; }else{ //Is the previous turret unoccupied if ( isNull ( _vehicle turretUnit _turretPath ) ) then { //Fix as we cannot move in from an internal position _unit setPos [0,0,0]; //Move player into turret _unit moveInTurret[ _vehicle, _turretPath ]; //Move was successful true }else{ //Move was unsuccessful false }; }; } }; //For each restirction for "_index" from 0 to (( count BAKE_VREST_RESTRICTIONS ) - 1 ) step 2 do { //If its relevant to this vehicle if ( BAKE_VREST_RESTRICTIONS select _index == vehicleVarName _vehicle ) then { //Get the restriction data ( BAKE_VREST_RESTRICTIONS select ( _index + 1 )) params[ "_restricted", "_whiteList", "_message" ]; if ( //For each restricted position { ( _x isEqualType "" && { _x == _position } ) || //If its a STRING and is equal to the players position { _x isEqualType [] && { ( _x select 0 ) isEqualType "" } && //OR its an ARRAY and the first index is a STRING { ( _x select 0 ) == _position && //AND the first index is equal to the players position ( _x select 1 ) isEqualTo _turretPath //AND the second index is equal to the players turret path } } || { _x isEqualTo _turretPath } //OR is just a turret path equal to player turretPath }count _restricted > 0 && //If we have a restriction //AND for each white list { { _x == vehicleVarName _unit || //If its the players var name { _x == getPlayerUID _unit } || //OR his UID { _unit getUnitTrait _x } //OR he has a trait }count _whiteList isEqualTo 0 //If he is not in the white list } ) exitWith { //See if the player can switch back to a previous position if !( [ _unit, _vehicle ] call _canSwitchBack ) then { //If not kick him out of the vehicle moveOut player; _unit setVariable [ "BAKE_lastPosition", nil ]; }; //and show him a message why titleText [_message, "PLAIN", 0.2]; }; }; }; //If hes still in the vehicle if ( _unit in _vehicle ) then { //Update his saved previous position to his current _unit setVariable [ "BAKE_lastPosition", assignedVehicleRole _unit ]; }; }; //Add event for when player enter vehicle player addEventHandler [ "GetInMan", TAG_fnc_checkVehicleRestrictions ]; //Add event to handle internal seat switching player addEventHandler [ "SeatSwitchedMan", { params[ "_unit", "", "_vehicle" ]; assignedVehicleRole _unit params[ "_position", [ "_turretPath", [] ] ]; [ _unit, _position, _vehicle, _turretPath, true ] call TAG_fnc_checkVehicleRestrictions; }]; And a test mission to go with. God damn it. Ill write this out again, new forum just deleted half of my post. Quote the slot names are changed from "turret" to "gunner". As you have noticed the position names change depending on how you enter the vehicle. For instance for the APC I have ["Turret",[0,0]] and ["commander",[0,0]] which are both the same position. I recommend using the trurret path [0,0] instead of the full turret path ["commander",[0,0]]. Quote i could not implement the correct use of brackets and quatations for formats like ["gunner",[0]] - which i am really confused. As mentioned in my last post I have changed the structure of BAKE_VREST_RESTRICTIONS as there were far to many brackets hopefully the comments in the above code will make it clearer. You can supply for the restricted positions position name - "Driver" turret path - [0] full turret path - ["Cargo",[3]] For the white list you can supply VehicleVarName of unit UID Trait You can supply a Trait for the white list this can allow you to change a units permission during a mission, or alleviate the need to name all the units for the white list restrictions. I have also implemented that if you switch seats into a restricted position that you are not booted from the vehicle but are placed back in the position you left, if still available. I think that was it. 1 Share this post Link to post Share on other sites
armatoday 12 Posted December 16, 2016 Thank you Larrow once again for this such detailed help. Will inform you about the result. Edited: Larrow, Thank you very much for your help. And now, i owe you a drink. Share this post Link to post Share on other sites