AGM icon indicating copy to clipboard operation
AGM copied to clipboard

bacpacks interaction hint

Open Tachii opened this issue 10 years ago • 11 comments

When someone is getting inside of your backpack you have no idea he did it. It's kinda annoying, for example a prisonier can steal a grenade from a bacpack and then throw it. So the request is can you create a hint or dialog with a name of person who is using your backpack.

For example:

John Doe is using your backpack John Doe is trying to access your backpack, but it's locked

Tachii avatar Jan 01 '15 13:01 Tachii

It was in ace 2, maybe u can see how they did it if u want

Tachii avatar Jan 01 '15 15:01 Tachii

I would like to completely replace backpack locking with this.

KoffeinFlummi avatar Jan 01 '15 15:01 KoffeinFlummi

Or leave backpack locking and just add messages?

jonpas avatar Jan 01 '15 16:01 jonpas

unitBackpack player addEventHandler ["ContainerOpened", {
    hint format ["%1 has opened your Backpack!", name (_this select 1)];
}]; 

Should it work?

Tachii avatar Jan 01 '15 17:01 Tachii

It should, just needs a check if the backpack is locked display the second message.

Also, is this kind of EH supposed to go into XEH or not? (Mostly asking because I don't quite get XEHs, Init XEH on Helicopter for example will run everytime someone connects, not just when helicopter is spawned, but Killed XEH...etc. get assigned only once or what?)

jonpas avatar Jan 01 '15 20:01 jonpas

I haven't figured it out yet :) I've got it from here: http://forums.bistudio.com/showthread.php?187141-How-to-check-who-is-using-my-backpack&p=2848215&viewfull=1#post2848215

I have no idea how one supposed to execute EH

Tachii avatar Jan 01 '15 20:01 Tachii

It's InventoryOpened, not ContainerOpened.

https://github.com/KoffeinFlummi/AGM/blob/master/AGM_Backpacks/config.cpp#L26

Also, is this kind of EH supposed to go into XEH or not? (Mostly asking because I don't quite get XEHs, Init XEH on Helicopter for example will run everytime someone connects, not just when helicopter is spawned, but Killed XEH...etc. get assigned only once or what?)

I'm not 100% sure about SLX' XEH, but the Init eventhandler does fire when:

  • the unit is initialized on that PC (including JIP)
  • the unit is NOT local and respawns.

Killed triggers when the unit is local and gets killed (and only if it was assigned on that machine, in contrast to MPKilled).

commy2 avatar Jan 01 '15 21:01 commy2

Hmh, interesting. What I have learnt about SLX' XEHs, they are basically just normal EHs, but they get "stacked" you could say. Normal EHs can get overwritten, XEHs won't. And then there is additional support for respawn...etc. within them.

jonpas avatar Jan 01 '15 21:01 jonpas

Problem with ContainerOpened is it's added to the object, so we have to remove/readd when player drops/picks up a new backpack. Also breaks on backpacks added by scripts. And it seems to only fire on the player doing the opening.

I think we can just use a lot of the same code we already have in AGM_Backpacks_fnc_openInventory which uses InventoryOpened

If player1 opens player2's backpack, then remoteFunc a message to player2

Edit: Can AI open your backpack?

PabstMirror avatar Jan 01 '15 21:01 PabstMirror

if (hasInterface) then {
    player addEventHandler ["InventoryOpened", {
        if (_this select 1 isKindOf "Bag_Base") then {
            BackpackEvent = _this;
            publicVariable "BackpackEvent";
        };
    }];
    "BackpackEvent" addPublicVariableEventHandler {
        if (BackpackEvent select 1 == unitBackpack player) then {
            hint format [
                "%1 has opened your Backpack!",
                name (BackpackEvent select 0)
            ];
        };
    };
};

Credits on code above go to Killzone_Kid

Tachii avatar Jan 02 '15 06:01 Tachii

Maybe instead of explicit message with pointer to the person that opened the backpack, you should only hear the opening noise (something like here: https://www.youtube.com/watch?v=3OsA8OFWFMc). It gives the opportunity for stealer to grab something if person wearing the backpack is not careful.

theYoursTruly avatar Feb 28 '15 00:02 theYoursTruly