Jump to content
  • 0

Better Tag Friendlies


prominentalex

Question

Recommended Posts

  • 0

The SQF fairy

 

XD nice one. but as for getting this to work, a good amount of ppl wont help because these files aren't supposed to be public form what i can tell.

 

Try asking the server owners if they wouldn't mind helping you out, or letting you know where they go it from if they didn't create it, just to avoid any trouble.

Link to comment
Share on other sites

  • 0

Hello everyone.

 

So I checked out these files that our fellow poster uploaded and went through them. Implementation seemed simple enough, however, I wasn't able to get them to work. I managed to find a server where the mechanic is working (64.94.101.235:2302) but even after browsing through the mission files I couldn't see where I went wrong. If I had to guess, I'd say there's part of the script being run server side.

 

In any case, if the script maker doesn't want to share it's fine. You've got to look out for your own servers, right? Still, I'd like to ask for everyone's help trying to come up with our own script. And what better way to do that than deconstructing the one we already know is working and try to come up with a better one?

 

Before we begin, if you question the morality of this... I understand. However, the way I see it, the original script writer has implemented several community side scripts on his server (without which I'm sure it wouldn't be as populated as it is now) so I think we (the community) have the right to at least try to learn how he did what he did. Specially if we do it publicly so other servers can benefit from our work.

 

-------------

 

So well, here's what I've learned from his files (I'm by no way an expert in scripting so forgive me if I'm writing nonsense here):

 

 

The part of the script I can see has only two original files. The core script mechanics are called from the init.sqf while the second original file is called through an action menu that has been added to the fn_selfactions.sqf. The main file initiates three different arrays that serve as holders for the different friendlies you are tagging. I don't entirely comprehend how these arrays work, but I'm guessing one array holds the UID of all the players you've successfully tagged as friendlies (from which the main ESP mechanic reads to actually show the dots in the screen and map) and then the other two arrays hold temporary UIDs for people who haven't confirmed your request for friendly tag yet (an array for your request and the other one for other's requests on you).

 

The main script contains a addPublicVariableEventHandler that holds the mechanic for updating the different arrays. It seems that its updated through a publicVariableClient command. I guess that'd make sense, otherwise, everyone would share the same friendlies.

 

Also, this first script holds the main mechanic for the ESP, which are run by a spawn command. The mechanic itself is pretty similar to every other ESP script out there, the only particular thing about it is that it limits who it shows by making a UID check against the main array on the script (which holds who you've successfully tagged as friendly).

 

There's one thing that calls my attention though. The ESP script ends like this: "} forEach entities "AllVehicles";" ---I don't see "entities" defined anywhere. Not entirely sure if its relevant or not. I've been looking through the RPT logs (client and server side) but I see no errors leading to this.

 

Now, the second script that I see on these files I don't really understand that much. This is the one called from fn_selfactions and probably servers to update the arrays present on the first script. What I do see is a spawn call for a function called "update_tags" that I haven't seen anywhere else in the mission file. Again, like with the "entities" case, this might be the reason why the script doesn't work for people who have copied it.

 

Sadly that's all I can tell. My money is on part of the script's functionality buried server side, but I might be wrong.

 

Still, the concept of the script is very clear to me. You create a mechanic that pretty much emulates the built-in Epoch tag friend system and store that information in a variable which you then use to limit who you've got ESP on. Easier said than done... right?

 

Well, there's a ton of ESP scripts out there, so there's no need to reinvent ESP here. We just need to limit it to the "right" people in relation to the group of players who are friends with each other.

 

How we define that group of people is the difficult part. But... do we actually have to do that? Doesn't Epoch already have an array of who you've tagged as friendly using the in-game mechanics? It does, and it can be used (if you know how) to run checks.

 

For example, I've seen it done in AGN's Safezone script. Look at this block:

_if = false;
					if ( _ip ) then {
						_ctOwnerID = _ct getVariable["CharacterID","0"];
						_friendlies	= player getVariable ["friendlyTo",[]];
						if(_ctOwnerID in _friendlies) then {	
							if ( AGN_safeZone_Backpack_AllowFriendlyTaggedAccess ) then
							{
								_if = true;
							};
						};
					};

What this code is pretty much doing (if I don't get it wrong) is checking if the person you are targeting (the _ct variable is your cursorTarget) is part of the people who you've previously tagged as friendly using the epoch system.

 

So why go through the trouble of creating an entire new tag friend mechanic if we can just tap into the arrays provided by the mod itself? Can't we somehow condition a player's ESP to only show people he has tagged as friends with the built-in epoch system?

 

That's what I've been trying to do, but I'm not good enough with scripts to do it by myself. So I'd like to ask your help.

 

EDIT:

 

Something like this:

 

While {true} do
{      
    _friendlies = player getVariable ["friendlyTo",[]];

 

    if ((_x getVariable ["CharacterID","0"]) in _friendlies) then { ESP CODE HERE} forEach AllUnits;

    sleep 0.5;

};

 

But I'm getting an error with _x because it's not defined or something. Need to find a way to make it so it compares each and every player's (currently in game) character's ID with the player's (the one running the script client side) friendlyTo list and make it so it only shows ESP for those entries that check out.

Link to comment
Share on other sites

  • 0

Wouldn't that require the hacker to tailor the hack to the specific script we are using? If we were to warn people to switch around the variable names we are using, then any script kiddy who downloads the hack would have to go into his files and adjust it to work on each particular server he wants to use it... and we all know script kiddies usually don't even know how to open an .sqf file...

 

Or am I wrong?

Link to comment
Share on other sites

  • 0

I understand what you are saying EbayN00B but I really think it's worth it... I'll deal with the hackers after I get this working...

 

Anyway, here's what I've done so far... I'm trying to piggyback on the built-in friend system so we can use it's mechanics to update an array from which we'll pull the UIDs of the players that our ESP will show...

 

Here are the files I've modified so far:

 

Variables.sqf

 

Added in a new array (line 716+):

	DZE_Friends = [];
        DZE_Friends2 = [];

player_spawn_2.sqf

 

Created a new variable referencing said array (line 11+):

player setVariable["ESPFriends",DZE_Friends2,true];    

player_TagFriendly.sqf

 

Created new commands to grab the _target's and _caller's UID to store in the variable (line 13+):

_callerUID = getPlayerUID _caller;
_targetUID = getPlayerUID _target;

_ESPFriends = _caller getVariable ["ESPFriends", []];
_ESPFriends set [count _ESPFriends, _targetUID];
_caller setVariable ["ESPFriends", _ESPFriends, true];

friendlyESP.sqf

 

Basic ESP script. Trying to limit who it'll work with by using the variable I've created.

while {true} do {

                _ESPFriends = player getVariable ["ESPFriends", []];
    
                sleep 0.5;
		
		{
			clearGroupIcons group _x;
			if (((getPlayerUID _x) in _ESPFriends)) then {
				group _x addGroupIcon ["x_art"];
				group _x setGroupIconParams [[1, 0, 1 , 1], format ["%1", name _x], 0.7, true];
			};
		} forEach entities "AllVehicles";               
};

But...

 

It doesn't work.

 

My server's RPT logs are getting flooded with the following message:

4:13:45 Error in expression <ns group _x;

if (((getPlayerUID _x) in _ESPFriends)) then {

group _x addGroupI>
4:13:45 Error position: <_ESPFriends)) then {

group _x addGroupI>
4:13:45 Error Undefined variable in expression: _espfriends
4:13:45 File mpmissions\__cur_mp.Chernarus\coreFESP.sqf, line 20

I'm guessing I'm not using the variable right... or that I might have to condition the script to run only if the variable isn't Nil...

 

Any help would be great...

Link to comment
Share on other sites

  • 0

friendlyESP.sqf

 

Changed it to:

private["_ESPFriends"];

waitUntil {sleep 0.25;(!isNil "PVDZE_plr_LoginRecord")};
waitUntil {sleep 0.25;(!isNil 'dayz_Totalzedscheck') || (!isNil 'dayzplayerlogin') || (!isNil 'dayz_animalcheck')};
waitUntil {sleep 0.25; (!isNil "ESPFriends")};

setGroupIconsVisible [true, true];

while {true} do {

                _ESPFriends = player getVariable ["ESPFriends", []];  
                sleep 0.5;
		
		{
			clearGroupIcons group _x;
			if (((getPlayerUID _x) in _ESPFriends)) then {
				group _x addGroupIcon ["x_art"];
				group _x setGroupIconParams [[1, 0, 1 , 1], format ["%1", name _x], 0.7, true];
			};
		} forEach entities "AllVehicles";              
};

Now I don't get any more RPT spam, but it still doesn't work. I'm probably either not using the variables correctly or not updating them.

 

On a second note, I noticed that by using the script in this way, you can only tag your friends once... so if you log out and back in you'll lose your ESP (information on these arrays doesn't save to the database like the original "friendlies" variables) and you won't be able to get it back unless you die. I suppose this could be solved by making it so the player_tagFriendly script doesn't add entries at all. In this way, you'll always get the option to tag your friends and will be able to tag them back if you had to log out... Might brake other scripts though. Might have to create an entire new mechanic, but for now I'd like to make sure I've got at least a simple version of this working...

 

Again, any help would be appreciated.

 

EDIT: Thought a way top keep the original tag_friendly script intact... simply remove the check from fn_damageActions that makes it so you don't get the option if the cursorTarget is already in _friendlies. This way you can keep tagging all you want and get ESP back even if you log out. Might be a bit bothersome, but the DB only saves up to five entrances anyway.

Link to comment
Share on other sites

  • 0

Alright. I've got a somewhat functional version here...

 

Disregard previous posted code... had to scrap it. Here's the step by step.

 

1) Open up your mission.pbo and look for your init.sqf. Look for this block:

if (!isDedicated) then {
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");

Add in the call for our ESP inside this block like so:

execVM "custom\friendlyESP.sqf";

It can be right after what I posted or at the bottom, but always between the block's { }s. I'm not entirely sure it's necessary to put it inside, but that's how I've got it working.

 

2) Create an sqf file named "friendlyESP.sqf" and put the following code in it:

waitUntil {sleep 0.25;(!isNil "PVDZE_plr_LoginRecord")};
waitUntil {sleep 0.25;(!isNil 'dayz_Totalzedscheck') || (!isNil 'dayzplayerlogin') || (!isNil 'dayz_animalcheck')};

setGroupIconsVisible [true, true];

FriendlyESPArray = [];
AdminESPOff = true;

while {AdminESPOff} do {
                sleep 0.5;	
		{
			clearGroupIcons group _x;
			if (((getPlayerUID _x) in FriendlyESPArray)) then {
				group _x addGroupIcon ["x_art"];
				group _x setGroupIconParams [[1,0,0,1], format ["%1", name _x], 0.7, true];
			};
		} forEach entities "AllVehicles";              
};

3) Open up your fn_damageActions.sqf and look for this block (line 148 aprox):

		if (((isPlayer _unit) and !(_charID in _friendlies))) then {
			r_action = true;
			_action = _unit addAction ["Tag as friendly", "\z\addons\dayz_code\actions\player_tagFriendly.sqf", [], 0, false, true, "", ""];
			r_player_actions set [count r_player_actions,_action];
		};

Right below it add the following code:

                if (((isPlayer _unit) and (_charID in _friendlies) and !(_charUID in FriendlyESPArray))) then {
                        r_action = true;
                        _action = _unit addAction ["Establish Radio Contact", "custom\player_tagFriendly_2.sqf", [], 0, false, true, "", ""];
                        r_player_actions set [count r_player_actions,_action];
                };  

You'll have to set a bypass for fn_damageActions.sqf on your compiles.sqf file and move it to your mission pbo. You can find tutorials on how to do this on your own.

 

3)b. Forgot to mention. Open your fn_damageActions again and around line 58 paste:

_charID =        _unit getVariable ["CharacterID", 0]; (BELOW THIS)
_charUID =      getPlayerUID _unit;

4) Create a new file named player_tagFriendly_2.sqf and paste the following code in it:

private["_target", "_caller", "_callerUID", "_targetUID", "_name", "_rfriendlies"];
_target = _this select 0;
_caller = _this select 1;
_name = name _target;

call fnc_usec_medic_removeActions;
r_action = false;

_callerID = _caller getVariable "CharacterID";
_rfriendlies = _target getVariable ["friendlies", []];

if (_callerID in _rfriendlies) then {

        _callerUID = getPlayerUID _caller;
        _targetUID = getPlayerUID _target;

        FriendlyESPArray = FriendlyESPArray + [_targetUID];

        _caller publicVariableClient "FriendlyESPArray";

        titleText [format["You've established radio contact with %1.",_name], "PLAIN DOWN", 3];

        } else {
    
        titleText [format["You've to be friends with %1 before you can establish radio contact.",_name], "PLAIN DOWN", 3];          
                
    };

5) Repack mission PBO, upload to server. You are done.

Link to comment
Share on other sites

  • 0

How the current version works

 

Since the beginning I thought that the best way to accomplish this was by piggy backing on the established system present in Epoch, however, I just couldn't make it work. In the end, I came up with a similar co-dependent system that works in the following way:

 

1) Approach player. You'll get a "Tag Friendly" prompt on your menu.

2) Tag the player as friendly. You'll get an "Establish Radio Contact" prompt on your menu.

3) Now, if you try to ERC before the player you are looking at tags you as his friend, you will be told that you have to wait until he does. After he tags you as his friend, you'll be given ESP to him. It currently only shows a dot above his head (and on the map) and his name.

4) If you log out. You'll lose ESP to your friends, but they will still have it for you and viceversa.

5) You currently can't cancel radio contact. But it'll be wiped off if you die.

 

I've been thinking about conditioning ESP to having a radio and/or a GPS, just to make it more interesting. Also, it should be possible to further customize the ESP script to show distance and blood value, like the EnhancedESP on the admin tools does.

 

Talking about that, my admins noticed that the friendlyESP script collides with the admin one, so I included in a variable that shuts it off when you turn on the admin esp. I'm still testing that though. If you'd like to share ideas, I'm all ears.

 

So well... that's it. Not entirely debugged, but it works... somewhat. Enjoy.

 

EDIT: Not entirely sure how the 5 entry limit on the regular tag_Friendly script affects the new one... Will have to test it out.

Link to comment
Share on other sites

  • 0

I'm not good with making videos... but you can check how it works on our server: 198.27.83.214:2402

 

Just bring a buddy with you. It should be relatively easy to reach each other, we've got a script in place that allows you to buy a motorcycle as soon as you spawn. Just open your gear screen, look for the wad of cash on your toolbelt and right click the option to buy bike.

 

It should be relatively easy to limit execution until the player has a GPS or a radio item... something like:

waitUntil {sleep 0.25;(!isNil "PVDZE_plr_LoginRecord")};
waitUntil {sleep 0.25;(!isNil 'dayz_Totalzedscheck') || (!isNil 'dayzplayerlogin') || (!isNil 'dayz_animalcheck')};

setGroupIconsVisible [true, true];

FriendlyESPArray = [];
AdminESPOff = true;

_playerMagazines = magazines player;
_hasRadio = "ItemRadio" in _playerMagazines;

while {(AdminESPOff) and (_hasRadio)} do {
                sleep 0.5;	
		{
			clearGroupIcons group _x;
			if (((getPlayerUID _x) in FriendlyESPArray)) then {
				group _x addGroupIcon ["x_art"];
				group _x setGroupIconParams [[1,0,0,1], format ["%1", name _x], 0.7, true];
			};
		} forEach entities "AllVehicles";              
};

Though there would have to be a mechanic in place to prevent you from ERCing if you don't have radio and then send messages when you stop having one or wipe out the array or... well, complicated...

Link to comment
Share on other sites

  • 0

Most likely not out of the box Vlad_Belza because the script is dependent on the Epoch built-in friend system to operate, but I'm sure it could be easily adapted to bypass that requirement.

 

On a second note, I forgot to said that you have to add:

 

_charUID =      getPlayerUID _unit;

 

As a variable in the fn_selfActions.sqf, should be below _charID =        _unit getVariable ["CharacterID", 0]; (line 58 aprox)

 

I've corrected the original instructions.

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
  • Advertisement
  • Discord

×
×
  • Create New...