Jump to content
Sign in to follow this  
camdev

Action only shown for a car you own?

Recommended Posts

So usually in an Island Life server, you would press L to unlock your vehicle while when pressed, would run

case 38: 

{

if(!INV_shortcuts)exitwith{};

_vcls = nearestobjects [getposatl player, ["LandVehicle", "Air", "ship"], 7];
_vcl = _vcls select 0;

if(!(_vcl in INV_VehicleArray))exitwith{player groupchat "You do not have the keys to this vehicle.";_handled=true;};
["schluessel", _vcl, 0] execVM "keys.sqf";
_handled=true;

};

What I am looking to do is to take this and put it into a scroll option, but I would only like it to show up when you are with a vehicle that you own. The beginning would simply start with something like action665 = _role addAction ["Lock/Unlock Vehicle"... and so forth. I thought another file that may be useful is the keys.sqf which looks like this:

 _art = _this select 0;
if (_art == "use") then 
{
  _item = _this select 1;
_anzahl = _this select 2;
 if (!(createDialog "schluessel")) exitWith {
hint "Dialog Error!";
};

  {
 if (not(isnull _x)) then 
{
   _index = lbAdd [1, format ["%1 (%2)", typeOf _x, _x]];
   lbSetData [1, _index, format ["%1", _x]];
   };

  } forEach INV_VehicleArray;
 buttonSetAction [2, "if ((lbCurSel 1) > -1) then 
{
[""schluessel"",  (INV_VehicleArray select lbCurSel 1), lbCurSel 1] execVM ""keys.sqf"";
};

closedialog 0;
"];
   buttonSetAction [4, "if ((lbCurSel 1) > -1) then 
{
[""dropschluessel"", (INV_VehicleArray select lbCurSel 1), lbCurSel 1] execVM ""keys.sqf"";
};

closedialog 0;
"];
buttonSetAction [5, "if ((lbCurSel 1) > -1) then 
{
[""schluesseluebergabe"", (INV_VehicleArray select lbCurSel 1), lbCurSel 1] execVM ""keys.sqf"";
};

closedialog 0;
"];
};

if (_art == "schluessel") then 
{
 _vcl = _this select 1;
   _sel = _this select 2;
  if (player distance _vcl < 20) then
{
  if (not(locked _vcl)) then 
{


  format ["%1 lock true;", _vcl] call broadcast;
  player groupChat localize "STRS_inv_items_vehiclelock_locked";
} else {


  format ["%1 lock false;", _vcl] call broadcast;
  player groupChat localize "STRS_inv_items_vehiclelock_unlocked";
};

 } else {
   player groupChat localize "STRS_inv_items_vehiclelock_closer";
}; 

};

if (_art == "dropschluessel") then 
{
 _vcl = _this select 1;
   _sel = _this select 2;
   INV_VehicleArray = INV_VehicleArray - [_vcl];
player groupChat localize "STRS_inv_items_weggeworfen";
execVM "Scripts\statSave\antiglitch.sqf";
};

if (_art == "schluesseluebergabe") then 
{
_vcl = _this select 1;
_sel = _this select 2;
_spielernum = call compile INV_InventarGiveReceiver;
_spieler = INV_PLAYERSTRINGLIST select _spielernum;
_playerobject = INV_PLAYERLIST select _spielernum;
  if (!(_spieler call ISSE_UnitExists))  exitWith {
player groupChat localize "STRS_inv_not_ingame";
};

if (_playerobject == player)   exitWith {
player groupChat localize "STRS_inv_inventar_uebergabe_self";
};

  if (player distance _playerobject > 20)  exitWith {
player groupChat localize "STRS_inv_inventar_uebergabe_distance";
};

   format ["if (INV_ROLESTRING == ""%1"") then 
{
INV_VehicleArray = INV_VehicleArray + [%2];
player groupChat localize ""STRS_inv_items_uebergabe_schluessel_success""};

", _spieler, _vcl] call broadcast;
//INV_VehicleArray = INV_VehicleArray - [_vcl];
 player groupChat localize "STRS_inv_items_uebergabe_schluessel_success_self";
};

I hope someone can help and I thank anyone that helps.

Also I thought that an unflip vehicle option may be helpful in this post as it only comes up when you have the keys and are at teh driver door, So first will be the action and then the file.

Action:

action122 = _role addaction ["Unflip vehicle","unflipvehicle.sqf",["unflip"],1,false,true,"",'_vcl = (nearestobjects [getpos player, ["Air", "Ship", "LandVehicle"], 3] select 0);player distance _vcl < 5 and _vcl in INV_VehicleArray'];

unflipvehicle.sqf:

_selection = (_this select 3)select 0;

if(_selection == "unflip") then

{

_vcl = (nearestobjects [getpos player, ["LandVehicle"], 10] select 0);

//if (_vcl == "") exitwith {player groupchat "No vehicles in range";};

if (_vcl in INV_VehicleArray) then

{

if ((count crew _vcl) > 0) exitWith {player groupChat "The vehicle is not empty!";};

player groupchat "turning your vehicle over, wait 5s within 10meters.";

sleep 5;

if (player distance _vcl < 10) then

{

_vcl setvectorup [0.001,0.001,1];

player groupchat "Your vehicle has been reset";

}

else

{

player groupchat "Try again, stay within 10m";

};

}

else

{

player groupchat "You need the keys to unflip a vehicle";

};

};

Edited by CamDeV
More Info

Share this post


Link to post
Share on other sites

Ok, so after looking at this for a while, I got a few things down. I got the action to only show up on a car you own using this action:

action123 = _role addaction ["*Lock/Unlock Vehicle","lockNunlock.sqf",["lockunlock"],1,false,true,"",'_vcl = (nearestobjects [getpos player, ["Air", "Ship", "LandVehicle"], 3] select 0);player distance _vcl < 5 and _vcl in INV_VehicleArray'];

Now the problem I have is not getting the vehicle to unlock or lock. here is the quick lockNunlock.sqf that i made:

_selection = (_this select 3)select 0;

if(_selection == "lockunlock") then
{

_vcl = (nearestobjects [getpos player, ["LandVehicle"], 10] select 0);
if (_vcl in INV_VehicleArray) then
    {
if (player distance _vcl <10) then
    {
if (not(locked _vcl)) then
    {
format ["%1 lock true;", _vcl] call broadcast;
player sideChat localize "STRS_inv_items_vehiclelock_locked";
    } else {


format ["%1 lock false;", _vcl] call broadcast;
player sideChat localize "STRS_inv_items_vehiclelock_unlocked";
    } else {

player sideChat localize "STRS_inv_items_vehiclelock_closer";
    };

Hopefully anyone can help with this now.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×