Open Tachii opened 9 years ago
It was in ace 2, maybe u can see how they did it if u want
I would like to completely replace backpack locking with this.
Or leave backpack locking and just add messages?
unitBackpack player addEventHandler ["ContainerOpened", {
hint format ["%1 has opened your Backpack!", name (_this select 1)];
}];
Should it work?
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?)
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
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:
Killed triggers when the unit is local and gets killed (and only if it was assigned on that machine, in contrast to MPKilled).
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.
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?
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
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.
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