Jump to content
  • 0

Backpack Anti Theft - Whats wrong with this code?


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)

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

Share this post

Link to post
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 ^^

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By Donnovan
      How do i know what is inside a player backpack?
      I found some functions in the WIKI BI but all of then are only to Arma 3.
    • Guest
      By Guest
      So i have watched the PC Gaming show E3 2015 Conference.
      And then suddenly this guy Brain Hicks comes up stage.. and i was like "Maybe i should stop watching.."
      But you know, i like to take a adventure, so im listen carefully to what he is saying while im listing to music....
      And then he starts telling about single player... and i have mixed opinions about this. 
      Offcourse its still a survival game, but i think isn't it the idea off survival that you work together (except when your a bandit) and stay alive and slowly start building up society again? 
      So i would like to hear your opinions about this, and things you dont agree with me.. 
      (And for the people who dont know what im talking about: 
      - a small video about it)  
      Thank you for taking the time to read this, and keep on surviving,
    • By meanbeandk
      Hi im trying to make a script that changes a players skin to a rocker skin with out loosing his backpack
      Here is my code
      private ["_bagType","_bagMagazines","_bagWeapons","_array1","_array2"]; _unitBag = unitBackpack player; _bagType = typeOf _unitBag; _bagWeapons = getWeaponCargo _unitBag; _bagMagazines = getMagazineCargo _unitBag; removeBackpack (vehicle player); sleep 1; [dayz_playerUID,dayz_characterID,'Rocker2'] spawn player_humanityMorph; sleep 1; if(_bagType == "CZ_VestPouch_EP1" || _bagType == "DZ_LargeGunBag_EP1" || _bagType == "DZ_ALICE_Pack_EP1" || _bagType == "DZ_Assault_Pack_EP1" || _bagType == "DZ_Backpack_EP1" || _bagType == "DZ_British_ACU" || _bagType == "DZ_CivilBackpack_EP1" || _bagType == "DZ_Czech_Vest_Pouch" || _bagType == "DZ_Patrol_Pack_EP1" || _bagType == "DZ_TK_Assault_Pack_EP1" || _bagType == "DZ_GunBag_EP1" || _bagType == "DZ_CompactPack_EP1" || _bagType == "DZ_TerminalPack_EP1") then { (vehicle player) addBackpack _bagType; sleep 0.1; _array1 = _bagWeapons select 0; _array2 = _bagWeapons select 1; for [{_i=0}, {_i < count _array1}, {_i=_i+1}] do { (unitBackpack player) addWeaponCargo [(_array1 select _i),(_array2 select _i)]; }forEach ARRAY; _array1 = _bagMagazines select 0; _array2 = _bagMagazines select 1; for [{_i=0}, {_i < count _array1}, {_i=_i+1}] do { (unitBackpack player) addMagazineCargo [(_array1 select _i),(_array2 select _i)]; }forEach ARRAY; }; i think my problem is that the sleep funtion don't work wile using  player_humanityMorph
      if i make this. 
      It takes off my backpack and put it on again.
      sleep 1; //[dayz_playerUID,dayz_characterID,'Rocker2'] spawn player_humanityMorph; sleep 1; Hope some one can help me  :)
    • By Ivlar
      //    @file Author: Ivlar.net [] spawn { while {1 == 1} do { waitUntil {!isnull (findDisplay 602)}; { if ((isPlayer _x && _x != player) && (alive _x)) then { _backpack=backpackContainer player; _backpack_x=backpackContainer _x; if(_backpack==_backpack_x)then{ hint "No Duping!"; removeBackpack player; }; }; } forEach nearestObjects [player, ["Epoch_Male_F","Epoch_Female_F"], 10]; sleep 1; }; };     Add to your init:
      if (hasInterface) then { [] execVM "InventoryOpened.sqf"; };   Maybe you have any ideas on how to improve the script?  
    • By F507DMT
      Anti-Theft from locked vehicles by F507DMT
      add in variables.sqf:
      GearStorags = ["WeaponHolder","WoodCrate_DZ","Wooden_shed_DZ","WoodShack_DZ","StorageShed_DZ","GunRack_DZ","VaultStorage","LockboxStorage"]; add in dayz_spaceInterrupt.sqf:
      //Esc if (_dikCode == 0x01) then { _nill = execvm "scripts\esc.sqf"; //if use Anti-Duping by F507DMT (http://epochmod.com/forum/index.php?/topic/32889-release-anti-duping-by-f507dmt-working/) DZE_cancelBuilding = true; call dayz_EjectPlayer; OpenGear = nil; }; //Anti-Theft from locked vehicles by F507DMT if ((_dikCode in actionKeys "Gear") && !(vehicle player != player)) then { if (isNil "OpenGear") then { (findDisplay 106) closeDisplay 1; if (!(cursorTarget isKindOf "Man") and (player distance cursorTarget <= 7) and ((typeOf cursorTarget in GearStorags) or (cursortarget isKindOf "AllVehicles"))) then { player action ["gear", cursortarget]; } else { createGearDialog [player, "RscDisplayGear"]; }; OpenGear = true; } else { (findDisplay 106) closeDisplay 1; OpenGear = nil; }; _handled = true; }; P.S.
      I recomend add "Open self Backpack" on button "H"
      add in  dayz_spaceInterrupt.sqf:
      //open backpack on H button if (_dikCode == 0x23) then { if (isNil "OpenGear") then { (findDisplay 106) closeDisplay 1; player action ["gear", unitBackpack player]; OpenGear = true; } else { (findDisplay 106) closeDisplay 1; OpenGear = nil; }; _handled = true; }; with: Losing connection, drop loot, Esc, exit yes and Esc + G, losing connection, drop loot, exit yes.
  • Advertisement
  • Supporters
  • Discord

  • Create New...