Jump to content

[Release] Scroll, Click, or Key press -Server info


oSoDirty

Recommended Posts

This is just a really simple script i wrote to display rules for my server. My 1st script so dont be too harsh  ^_^

 

How it works: It detects if you are moving or not and adds a menu to your scroll wheel.  If unedited it will be red and read "rules"

When the action is toggled, more menus (categories) come up, each of these menus triggers a small script to read some messages, or in this case, rules. 

Once the player starts moving again then all menus disappear, Rules is the only menu that remains persistent when stopped

again, rules will again have to be toggled to bring up the other menus. (New Options now included)

 

Before you continue, make sure you have a custom variables.sqf and the custom file for your method of choice before proceeding. If not. Check forums for the tutorial you need and return when prepared.

 

This version HERE has to be closed manually.

 

This version HERE closes the display when you move. 

 

If you have added this already and personalized it you may just want to add this:

waitUntil  { speed player > 0 };
	if (speed player > 0) then {
		(findDisplay 72) closeDisplay 0;
	};	
};

a space below the last closing bracket in each of the files you personalized.  

 

 

 

Screenshots: Menu 1   Menu 2  Menu 3

 

Method 1 - Scroll Wheel

 

This method requires a custom fn_selfActions.sqf  - If you don't have this, look it up and return once you do.

 

Inside fn_selfActions find the line (its very close to the top)

_canDo = (!r_drag_sqf && !r_player_unconscious && !_onLadder);

 and underneath it place this

//rules start
if(speed player <= 1) then {
    if (s_rules < 0) then {
        s_rules = player addaction[("<t color=""#c70000"">" + ("Rules") +"</t>"),"custom\rules\rules_init.sqf","",-3,false,false,"",""];
    };
} else {
    player removeAction s_rules;
    s_rules = -1;
    };
//rules end

So you should have something similar to this

_onLadder =		(getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf && !r_player_unconscious && !_onLadder);

//rules start
if(speed player <= 1) then {
    if (s_rules < 0) then {
        s_rules = player addaction[("<t color=""#c70000"">" + ("Rules") +"</t>"),"custom\rules\rules_init.sqf","",-3,false,false,"",""];
    };
} else {
    player removeAction s_rules;
    s_rules = -1;
    };
//rules end

_nearLight = 	nearestObject [player,"LitObject"];

 

Method 2 - Right Click

 

This method require a custom Extra_Rc.hpp

 

Add this to the bottom of your Extra_Rc.hpp:

class ItemMap {
        class serverRules {
            text = "Rules";
            script = "execVM 'custom\rules\rules_init.sqf'";
        };
    };

 

Method 3 - Tab Key   Can be changed, just look up dik keycodes and replace the code with one of your choice. Just be careful not to use a banned key if using an anti-hack tool.

 

This method requires a custom dayz_spaceInterrupt.sqf

 

Add this to your dayz_spaceInterrupt.sqf:

if (_dikCode == 0x0F) then {
   execVM 'custom\rules\rules_init.sqf'
    _handled = true;
};

 

Once you have chosen and completed one of the methods above, open variables.sqf and find:

dayz_resetSelfActions = {

and add

s_rules = -1;

in to the array.

 

 

Once you are done with that simply create a folder called custom in you MPMissions folder then place rules folder inside the custom folder. If you have a folder called custom already just use yours.

 

It can be placed in any folder including the root of MPMissions, but you would have to go into fn_selfActions and rules_init and change the paths in the addActions.

 

 

Thanks to, -Ree- for the request post for something like this that made me want to do it.

Thanks to, -Gr8Boi-  for added options found in this post and for showing me how to make this much prettier.

Thanks to,  -Sandbird-  for some tips and helping me debug some last minute issues.

Thanks to,  -CordIAsis-  for the auto removal code.

 

 

Thats all folks!

 

 

Feel free to use, abuse edit, and release any variation you like. Just give us a shout out!

Link to comment
Share on other sites

Try this Method, looks way better

private["_separator1","_txt"];
cutText ["HOLD LEFT-CLICK ON TEXT AND DRAG UP AND DOWN, PRESS ESCAPE TO CLEAR OR CONTINUE ON BOTTOM!", "PLAIN DOWN"];
sleep 1;
"Hints & Tips" hintC [
                                                            "*No Camping and No Killing Inside or within 400m of Safezones",
                                                            "*No Griefing and No Stealing While inside Safezones",
                                                            "*No unattended vehicles",
                                                            "*They will be deleted",
                                                            "*XX",
                                                            "*XX",
                                                            "*XX",
                                                            "*XX"
];
Link to comment
Share on other sites

 

Try this Method, looks way better

private["_separator1","_txt"];
cutText ["HOLD LEFT-CLICK ON TEXT AND DRAG UP AND DOWN, PRESS ESCAPE TO CLEAR OR CONTINUE ON BOTTOM!", "PLAIN DOWN"];
sleep 1;
"Hints & Tips" hintC [
                                                            "*No Camping and No Killing Inside or within 400m of Safezones",
                                                            "*No Griefing and No Stealing While inside Safezones",
                                                            "*No unattended vehicles",
                                                            "*They will be deleted",
                                                            "*XX",
                                                            "*XX",
                                                            "*XX",
                                                            "*XX"
];

 

It is indeed. Thank you!

Link to comment
Share on other sites

Images, pls! :)

Right now it just displays Title Text on screen like a mission would. Nothing special. But i am working on one last thing before i drop the update to make it a bit more prettier (thanks to Gr8Boi)

 

Once i upload the new files ill add some screenshots of the menus. Its kind of personalized as well so ill have to make it a bit more basic before i upload it. Will be out soon!

Link to comment
Share on other sites

What i should edit if I want that the "rules" will be vanished too if I'm moving?

 

Everything lol. Since the dialog is in game it has preset ways for closing it, escape is the fastest way to close it. Unless there is a way to emulate a keypress with commands, which i have not found a way to do. All i have found on the subject is an unanswered forum on Bohemia Interactive. Thus leading me to believe it's not possible to send a keystroke with a command. (would love to be corrected). So unless someone would like to enlighten me on the subject on how to make the hintC dialog go away using  waitUntil or anything similar. Im left to believe the only way is to create your own dialog and write a script to use them instead. I honestly have no intention of doing this. Simply because it goes against what i had planned for this. Which was for it to be simple, small, and not give players access to certain dialogs.

Link to comment
Share on other sites

 

Not tried it but it should work.

if (player is moving too fast) then {
    (findDisplay 72) closeDisplay 0;
};

 

Well, it's weird lol. The 1st time i tried it i totally derped and put  "<= 0"  for some reason. But it was making it go away and just pop the usual after hint, then realizing my mistake, full of hope i set it to  "> 0". So i tried it and it didn't work. I checked to see if somehow i magically messed it up again. Didn't see anything. So i get the idea to click the action and immediately start running before the display shows up. Well, lol it just flashed and popped the other hint. But if I actually let the display load before proceeding to walk forward it just stays until i cancel it out manually.

Link to comment
Share on other sites

Mmm, maybe because it wasn't in a loop? Or was it? If it wasn't in some sort of loop then it'd only check the player's speed once and never again which may be the reason why <=0 worked, because you were standing still when the one and only speed check occured.

Try this-

// Your hintC stuff goes here.
[] spawn
{
    waitUntil {!isNull (findDisplay 72)};
    waitUntil {(speed player) > 0};
    (findDisplay 72) closeDisplay 0;
};

EDIT:
If you haven't already and want to remove the standard hint that appears on closing the hintC display you can place this code just underneath your hintC call-

clearhint = (findDisplay 72) displayAddEventHandler ['unload','_this spawn {hintSilent ''; (_this select 0) displayRemoveEventHandler ['unload',clearhint];};']

EDIT2:

You can rename the clearhint, that's not really important, it's just a variable name. Just be sure to rename both instances of it!

 

EDIT3:!! Made a typo, updated it. I used isNil instead of isNull

Link to comment
Share on other sites

The derps are strong in me tonight. XD

 

I actually did use a waitUntil the first time i tried it.... with  <= 0  lol 

but i removed the waitUntil before i caught the mess up. So the loop was closed before i stopped then? I did take a small walk of shame when it didnt close ^^  

 

Thank you!!!!

 

As far as the clearing of the 2nd hint, when i added it in it just broke the closeDisplay. 

Link to comment
Share on other sites

Sweet Deal thank you =)

 

I will have to add this in the morning =D

 

question any chance for a Toggle key like "Tab" ("0x0F")  https://community.bistudio.com/wiki/DIK_KeyCodes

"Tab" Brings up Menu

"Tab" Closes Menu

"Move" Closes Menu

 

 

I have special players... had to change Scroll Suicide to a right click action lol

 

 

p.s. you left your .git folders in the zip =) (" in case someone is wondering what they should do with them just remove them =) ")
 

Link to comment
Share on other sites

lol, i tried to use github, im clueless lol. But as far as i know someone is working on a right click version using maca's right click functions. And at my skill level in coding, i could probably get the actions to show/remove with tab, but im not sure how to make the menu them self without using the scroll. Pretty sure that would require a dialog.

Link to comment
Share on other sites

Add this to the OP if you want:

 

Right Click Activate :

 

Add this to your Extra_Rc.hpp :

class ItemMap {
        class serverRules {
            text = "Rules";
            script = "execVM 'custom\rules\rules_init.sqf'";
        };
    };

For TAB Key Activate

 

add this to your custom dayz_spaceInterrupt.sqf

if (_dikCode == 0x0F) then {
   execVM 'custom\rules\rules_init.sqf'
    _handled = true;
};
Link to comment
Share on other sites

Hey guys if im trying to add new tab what would i add here, trying to add the message tab i have it inserted into this text cant try test it yet...to many players online.

also i notice the "-insertnumber ,false,true,"",""]; " keeps going higher what would i put for the message tab? P.S how do ya do the spoiler tabs for code?

 

 

 

 

///////////////////////////////////////////////////////////////////
// Detailed scroll rules ///////////////////////////////////////////
// By oSoDirty ////////////////////////////////////////////////////
// rules initialization  ///////////////////////////////////////////
///////////////////////////////////////////////////////////////////

if(speed player <= 0) then {
    _isDirty = true;
        if(_isDirty) then {
        _rule_set1 = player addAction["PVP","custom\rules\pvp.sqf","",-5,false,true,"",""];
        _rule_set2 = player addAction["mods","custom\rules\mods.sqf","",-6,false,true,"",""];
        _rule_set3 = player addAction["Chat","custom\rules\chat.sqf","",-7,false,true,"",""];
        _rule_set4 = player addAction["Building","custom\rules\building.sqf","",-8,false,true,"",""];
        _rule_set5 = player addAction["Cheating","custom\rules\cheating.sqf","",-9,false,true,"",""];
        _rule_set6 = player addAction["Thanks","custom\rules\thanks.sqf","",-9,false,true,"",""];
        _rule_set7 = player addAction["message","custom\rules\message.sqf","",-9,false,true,"",""];
        waitUntil { speed player > 0 };
            player removeAction _rule_set1;
            player removeAction _rule_set2;
            player removeAction _rule_set3;
            player removeAction _rule_set4;
            player removeAction _rule_set5;
            player removeAction _rule_set6;
            player removeAction _rule_set7;
            _rule_set1 = -1;
            _rule_set2 = -1;
            _rule_set3 = -1;
            _rule_set4 = -1;
            _rule_set5 = -1;
            _rule_set6 = -1;
            _rule_set7 = -1;
            };
        };
    };
};

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...