Jump to content
  • 0

Backpack Anti Theft - Whats wrong with this code?


Markokil321

Question

Hello,
 
Looking for some help with this Code i am trying to add to our server as a backpack theft protection when inside safezones. We had something similar up to now but it just didn't work very well.
I am adding this code to the bottom of my custom fn_gearMenuChecks.sqf which is called in the MPMission\compiles.sqf.
 
I've added comments trying to explain what it is doing (WE ALSO USE CUSTOM FRIENDLIST SYSTEM, so things may look strange)
 
THE CODE:

if (inSafeZone) then //if player inside a safezone
{
	_playerNear = (({isPlayer _x} count (nearestObjects [player, ['Man'],6])) > 1); //there is another player within 6m of you
	if (_playerNear) then  //if player within 6m
	{
		//define variables
		_puid 		= getPlayerUID player;
		_fuid 		= getPlayerUID cursorTarget;
		_playerID 	= player getVariable ["CharacterID", "0"];
		_targetid 	= cursorTarget getVariable ["CharacterID", "0"];
		_sFriends 	= player getVariable ["friendlies", []];
		_pfls 		= player getVariable ["AH_friendlist",[]];
		_tFriends 	= cursorTarget getVariable ["friendlies", []];
		_ffls 		= cursorTarget getVariable ["AH_friendlist",[]];

		_isFriend 	= (((_targetid in _sFriends)&&(_playerID in _tFriends)) || ((_fuid in _pfls)&&(_puid in _ffls))); //player is inside your friendslist
		_isLootpile     = (cursorTarget isKindOf "WeaponHolder"); //cursortarget is a lootpile
		

		if (!_isFriend || _isLootpile) then //if target not inside friendslist OR cursortarget is a lootpile
		{
			_display closeDisplay 1;   // do not allow gear access
			cutText ["\nANTI-THEFT: You cannot access non-friends gear/backpacks in safezone!","PLAIN DOWN"]; //text
		};
	};
};

Point is that if you are inside a safezone and there is another player within 6m:
- if target player is not inside your friendslist = you cannot access their gear/backpack
- if you target a lootpile = no gear access
 
The problem is that it does not let me access anyones gear if there is another player within 6m, no matter if they are in my friendslist or not.

 

Very tired trying to figure out what could be wrong, does this code look allright?
Here's my whole fn_gearMenuChecks.sqf: http://pastebin.com/znjtWC8R

 

Any help is appreciated

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

if you use infistar, try his safezone script: http://pastebin.com/ht7djVGH

 

if not, you can find there your solution :

if (inSafezone) then
                        {
                                if (_USE_AntiSteal) then
                                {
                                        _cnt = {isPlayer _x && _x != player} count (player nearEntities [['CAManBase'],4]);
                                        if ((_cnt > 0) && (!isNull (findDisplay 106))) then
                                        {
                                                (findDisplay 106) closedisplay 0;
                                                closeDialog 0;closeDialog 0;closeDialog 0;
                                                _log = format['%1 You are not allowed to open Gear while near another player!',name player];
                                                cutText [_log,'PLAIN'];
                                                hint _log;
                                        };
                                };

oh wait, i should thread trough the complete post first -.-"

 

Give me a second ^^

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...