Jump to content
  • 0

[BASIC GUIDE] 4 ways to add scroll menu options


juandayz

Question

This is a very simple and basic guide to make your own scroll menu options and execute your scripts.

Please fell free to put other ways or whatever do you want about it :) hope help you with it.

Execute an script through fn_selfactions.sqf  Using nearest players from objet or AI

*If u wanna execute an script using an objet or AI as a trigger then at buttom of your custom fn_selfactions  use this structure:

 

Spoiler

private["_playerPos","_nearestVariable"];//this section is for put the private variables for this script

_playerPos = getPosATL player;//obtain the player position
_nearestVariable = count nearestObjects [_playerPos, ["OBJET ID OR AI ID"], 3] > 0;//check if thers an specific objet near Xdistance(3mts in this case)  from player
 
if (_nearestVariable) then { //here proceed if _nearestVariable is present (player position from objet/AI )
        if (s_player_action < 0) then { // you can use any other name.. i use _action here
            s_player_action = player addaction[("<t color=""#F7D708"">" + ("THE NAME TO PUT IN SCROLL MENU") +"</t>"),"path\to\script.sqf"]; //here you define the text  you put in the scroll menu option, the color and the path where script is located
        };
    } else {
    /////////////this section is for remove the scroll menu option if _nearestVariable is not present
        player removeAction s_player_action;
        s_player_action = -1;
    };        


    
So to complete the structure from above  we gonna use a "TK_CIV_Woman01_EP1" AI id to get the option:

Structure: (at bottom of your fn_selfactions.sqf)

Spoiler

private["_playerPos","_neartrader"];

_playerPos = getPosATL player;
_neartrader = count nearestObjects [_playerPos, ["TK_CIV_Woman01_EP1"], 4] > 0;
 
if (_neartrader) then {
        if (s_player_tk_trader < 0) then {
            s_player_tk_trader = player addaction[("<t color=""#F7D708"">" + ("Buy") +"</t>"),"path\to\script.sqf"];
        };
    } else {
        player removeAction s_player_tk_trader;
        s_player_tk_trader = -1;
    };


//In this case u dont need add nothing more.    

Using cursor target on specific AI/Objet to launch the script. (aim the objet/AI and get a scroll menu option)

First you will need find this in your custom selfactions.sqf

if (_canDo && (speed player <= 1) && (_cursorTarget isKindOf "Plastic_Pole_EP1_DZ")) then {

//the line above says if _canDo variable is present and if the speed player is less or equal to 1 and if cursor target is on the plot pole then { then blabla
you can use the same syntax to make your own scroll menu option... for example if u wanna execute an script each time you put your cursor on a medical tent..("GUE_WarfareBFieldhHospital")


above of

if (_canDo && (speed player <= 1) && (_cursorTarget isKindOf "Plastic_Pole_EP1_DZ")) then {

put:

 

Spoiler

if (_canDo && (speed player <= 1) && (_cursorTarget isKindOf "GUE_WarfareBFieldhHospital")) then {
if (s_player_actiontent < 0) then {
    s_player_actiontent = player addAction ["<t color='#ff5200'>HEAL ME</t>", "path\to\script.sqf", [], 5, false];
    };
    } else {
    player removeAction s_player_actiontent;
    s_player_actiontent = -1;
    };


    
so each time you aim to GUE_WarfareBFieldhHospital you will got a "HEAL ME" option in your scroll menu.

//In this case you will need add yours
player removeAction s_player_actiontent;
s_player_actiontent = -1;

near the end of fn_selfactions.sqf  so find this lines:

Spoiler

{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
    s_player_repair_crtl = -1;
    {player removeAction _x} count s_player_combi;s_player_combi = [];
    dayz_myCursorTarget = objNull;
    s_player_lastTarget = [objNull,objNull,objNull,objNull,objNull];
    {player removeAction _x} count s_player_parts;s_player_parts = [];
    s_player_parts_crtl = -1;
    {player removeAction _x} count s_player_lockunlock;s_player_lockunlock = [];
    s_player_lockUnlock_crtl = -1;
    player removeAction s_player_checkGear;


  And add above put:

Spoiler

player removeAction s_player_actiontent;
s_player_actiontent = -1;

this two ways are easy and you can create a new stuff using it.


GET A NEW SCROLL MENU OPTION IF URE INTO A VEHICLE

Well first you will need find it in your custom fn_selfActions.sqf
 

Spoiler

} else {
    player removeAction s_player_grabflare;
    player removeAction s_player_removeflare;
    s_player_grabflare = -1;
    s_player_removeflare = -1;
};

bellow it add this structure:
 

Spoiler

 if (_inVehicle && (driver _vehicle == player)) then { //_inVehicle and _vehicle are variables of fn_selfactions you can find what they mean at top of the selfactions.sqf

    if (s_player_action < 0) then { //"_action" use any other name
        dayz_action = _vehicle; //dayz_action i give the name you can use other one
        s_player_action = dayz_action addaction[("<t color=""#F7D708"">" + ("Vehicle New Option") +"</t>"),"path\to\script.sqf"]; //defiine the color, the name of the option and the path to execute your script
        };
    } else {
    //remove the option if player is not inside
        dayz_action removeAction s_player_action;
        s_player_action = -1;
    };

 


Other way to get a scroll menu option, for example if u wanna get the option all time to use for show rules or something:

create a new sqf.  (name it as you want.. for example  no_use_for_a_name.sqf) and paste inside:

Spoiler

waituntil {!isnull (finddisplay 46)};
sleep 15;
setview = player addaction [("<t color=""#6599FF"">" + ("RULE") +"</t>"),"Path\to\rule.sqf","",5,false,true,"",""];

now go to your init.sqf and in very bottom paste:

[] execVM "path\to\no_use_for_a_name.sqf";

Now all players get the "RULE" option all time.

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Any idea how to remove the scroll option?
 

Trying to remove get in as pilot if the vehicle is MH6J_DZ. I added this into server_monitor.sqf and it creates another "Get in as pilot" dialog.

 

My code...
    

			while {(alive player) and (typeOf(vehicle player) == "MH6J_DZ")} do {
_vehicle removeAction [localize "str_actions_helipilotseat", "\z\addons\dayz_code\actions\veh_seatActions.sqf",["MoveToPilot",_driver], 0, false, true];
	}; 

 

Link to comment
Share on other sites

  • 0

In your custom self actions file  around line 250, put this:

if (_typeOfCursorTarget == "MH6J_DZ") then {_cursorTarget lockDriver true;}; // Remove the "get in pilot" option.

This will probably not work if the server spawned the vehicle because it says. "This command must be executed where vehicle is local " in the wiki. Then use this:

if (_typeOfCursorTarget == "MH6J_DZ") then {
		if (local _cursorTarget) then {
			PVDZE_veh_Lock spawn local_lockUnlock
		} else {
			publicVariable "PVDZE_veh_Lock";
		};
	};

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...