soundblaster 12 Posted April 6, 2016 Hey everyone! I have a question about a script that I saw in action on a few server. My question is how do you block players looting for corpses these corpses can be teammates or enemies Bluefor, Indep or Opfor. I seen a few thread where people say you can strip down someone naked onkill but I don't want to have a bunch of naked dead people, nor do I want to remove the corpses (I already got a script running doing this every 15 minutes). I literally just want to block access to the inventory of dead corpses. Hopefully someone here can help me or point me to the right direction! Thank you. 2 Share this post Link to post Share on other sites
Nikander 123 Posted April 6, 2016 My question is how do you block players looting for corpses these corpses can be teammates or enemies Bluefor, Indep or Opfor. Hi soundblaster, try this in your mission init: player addEventHandler ["InventoryOpened",{ if (_this select 1 isKindOf "Man") then {closeDialog 602; true} }]; Hope this helps, Nikander 9 Share this post Link to post Share on other sites
Bnae 1431 Posted April 6, 2016 player addMPEventHandler ["MPKilled",{_unit = _this select 0; removeAllWeapons _unit; removeAllAssignedItems _unit; clearMagazineCargo _unit}]; This can be used to limit what you can take 2 1 Share this post Link to post Share on other sites
esfumato 75 Posted April 6, 2016 How can you limit to not allow others to take uniforms and helmets from enemy sides? 2 Share this post Link to post Share on other sites
soundblaster 12 Posted April 6, 2016 Hi soundblaster, try this in your mission init: player addEventHandler ["InventoryOpened",{ if (_this select 1 isKindOf "Man") then {closeDialog 602; true} }]; Hope this helps, Nikander You're a genious thank you! 3 Share this post Link to post Share on other sites
soundblaster 12 Posted April 14, 2016 I've noticed that it does work for players but not AI's that are spawned in the mission. Is there a reason behind it I am using Nikander his code. 1 Share this post Link to post Share on other sites
iV - Ghost 50 Posted April 15, 2017 I'm looking for something like this too. I wanna stop or reduced looting the ALiVE-spawned Ai's and Players on my server. Would be glad about some help. Greetz Share this post Link to post Share on other sites
Asmodeuz 54 Posted June 25, 2017 On 6.4.2016 at 0:35 PM, Nikander said: Hi soundblaster, try this in your mission init: player addEventHandler ["InventoryOpened",{ if (_this select 1 isKindOf "Man") then {closeDialog 602; true} }]; Hope this helps, Nikander This nicely prevents accessing the inventory of a killed AI soldier when testing the mission through the in-game editor (multiplayer game mode). But when testing the same mission in a dedicated (multiplayer) environment the code doesn't prevent opening the inventory dialog (with a killed AI soldier). And for human players it only seems to work for one side only: my friend wasn't able to open inventory after killing me but when I killed him I got to his inventory. Is there any way to prevent accessing the inventory of both of human and AI players alike in a dedicated server environment? 1 Share this post Link to post Share on other sites
das attorney 858 Posted June 25, 2017 I think the problem is that the inventory takes a while (like a few ms) to initialise. So in effect, you're trying to close it before it has had time to open. Try this modified version of Nikanders script. It should wait for the opening and close it immediately: player addEventHandler ["InventoryOpened",{ _this spawn { waitUntil { not isNull findDisplay 602 }; if (_this select 1 isKindOf "Man") then {closeDialog 602} } }]; 2 2 Share this post Link to post Share on other sites
Asmodeuz 54 Posted June 25, 2017 1 hour ago, das attorney said: I think the problem is that the inventory takes a while (like a few ms) to initialise. So in effect, you're trying to close it before it has had time to open. Try this modified version of Nikanders script. It should wait for the opening and close it immediately: player addEventHandler ["InventoryOpened",{ _this spawn { waitUntil { not isNull findDisplay 602 }; if (_this select 1 isKindOf "Man") then {closeDialog 602} } }]; That was an out-of-the-box solution das attorney! That now works for both human (no matter of the side or faction) and AI players alike in a dedicated server environment! Thank you and have a good day sir! Just as a small edit: that code there prevents human players from opening inventories (or to be more precise the inventory dialog) of dead human and AI soldiers. 2 Share this post Link to post Share on other sites
das attorney 858 Posted June 25, 2017 no probs man :) I think the issue is that if you test it in the editor (60fps at least) then everything is golden; but when the script is used on DS, (which have a very variable frame rate), then things take longer and go out of sequence. Credit to Nikander though - it's his script to be honest - I just tinkered with it a bit. 1 Share this post Link to post Share on other sites
killzone_kid 1330 Posted June 25, 2017 Here is another solution, should go into init field of every player in editor this addEventHandler ["Put", { if (!alive (_this select 0)) then { _this select 1 addEventHandler ["ContainerOpened", { _this select 1 playActionNow "Gear"; titleText ["You are not allowed to loot\ndead soldiers", "plain"]; }]; _this select 1 spawn { sleep 0.5; waitUntil {velocity _this isEqualTo [0,0,0]}; _this enableSimulation false; }; }; }]; Of course if you have respawn then you need to somehow re-execute this 1 Share this post Link to post Share on other sites
bad benson 1733 Posted June 26, 2017 maybe putting it all into an "EntityKilled" mission EH could be good. like the adding of the inventory related EHs themselves and not just the code inside them. could make it more universal and easier to maintain. 1 Share this post Link to post Share on other sites
Asmodeuz 54 Posted June 26, 2017 19 hours ago, killzone_kid said: Here is another solution, should go into init field of every player in editor this addEventHandler ["Put", { if (!alive (_this select 0)) then { _this select 1 addEventHandler ["ContainerOpened", { _this select 1 playActionNow "Gear"; titleText ["You are not allowed to loot\ndead soldiers", "plain"]; }]; _this select 1 spawn { sleep 0.5; waitUntil {velocity _this isEqualTo [0,0,0]}; _this enableSimulation false; }; }; }]; Of course if you have respawn then you need to somehow re-execute this I am indeed using respawn in my mission(s), so for me trying to think of some way to re-execute that gives a dead feeling inside (read: only empty "thoughts" :) ) 13 minutes ago, bad benson said: maybe putting it all into an "EntityKilled" mission EH could be good. like the adding of the inventory related EHs themselves and not just the code inside them. could make it more universal and easier to maintain. Here's one I found by @serena That EH nicely prevents picking up the weapon that goes flying through the air when the player kills a character. But there's a but for me at least: I'm using Iron Front lite (IFA3_AIO_LITE) to test these eventhandlers while I'm building the missions. And even if that serena's EH script prevents from picking up the weapon that dropped on the ground it doesn't prevent the player picking up occasional rifle (Kar98) cartridges or hand grenades. Would there be some way to incorporate that EH with some other code that would prevent picking up stuff (rifle cartridges, hand grenades) that seems to get occasionally dropped by the dead characters? 2 Share this post Link to post Share on other sites
Asmodeuz 54 Posted June 26, 2017 14 minutes ago, Asmodeuz said: I'm using Iron Front lite (IFA3_AIO_LITE) to test these eventhandlers while I'm building the missions. And even if that serena's EH script prevents from picking up the weapon that dropped on the ground it doesn't prevent the player picking up occasional rifle (Kar98) cartridges or hand grenades. Would there be some way to incorporate that EH with some other code that would prevent picking up stuff (rifle cartridges, hand grenades) that seems to get occasionally dropped by the dead characters? I did a couple of tests and it is so that the player can only pick up or "rearm" the exact same type of ammunition he/she happens to be carrying. Any pointers where this might lead? Need to start thinking of preventing rearming from dead characters or? Share this post Link to post Share on other sites
iV - Ghost 50 Posted June 26, 2017 I'm using this: // DELETE ALL WEAPONS & AMMO (EAST) if ((side _this == east) and (!isPlayer _this)) then { _this addEventHandler ["Killed", { _this = _this select 0; removeAllWeapons _this; removeAllItems _this; removeAllAssignedItems _this; deleteVehicle (nearestObject [_this, "WeaponHolderSimulated"]); }]; }; Now the players can only loot or ream on Syndicate. All CSAT stuff get deleted after the unit is killed. Share this post Link to post Share on other sites
Phantomx2 0 Posted October 25, 2017 On 6/26/2017 at 10:46 PM, iV - Ghost said: I'm using this: // DELETE ALL WEAPONS & AMMO (EAST) if ((side _this == east) and (!isPlayer _this)) then { _this addEventHandler ["Killed", { _this = _this select 0; removeAllWeapons _this; removeAllItems _this; removeAllAssignedItems _this; deleteVehicle (nearestObject [_this, "WeaponHolderSimulated"]); }]; }; Now the players can only loot or ream on Syndicate. All CSAT stuff get deleted after the unit is killed. So you add this to the init.sqf in the mission folder? Share this post Link to post Share on other sites
iV - Ghost 50 Posted October 26, 2017 It was a part of a file called HandleAi.sqf and activated in the description.ext with: // LOADOUT MANAGEMENT class Extended_Init_EventHandlers { class Man { init = "_this call (compile preprocessFileLineNumbers 'scripts\misc\HandleAi.sqf')"; }; }; But people tell me that this was not the best way. Now I've making a own file called LootStop.sqf and activated this in the init.sqf. LootStop.sqf // DELETE ALL WEAPONS & AMMO addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer", "_instigator"]; if (isPlayer _killed) exitWith {}; if !(_killed isKindOf "Man") exitWith {}; // HANDLE AAF if (faction _killed == "IND_F") then { removeAllWeapons _killed; removeAllItems _killed; removeAllAssignedItems _killed; deleteVehicle (nearestObject [_killed, "WeaponHolderSimulated"]); }; // HANDLE CSAT if (faction _killed == "OPF_F") then { removeAllWeapons _killed; removeAllItems _killed; removeAllAssignedItems _killed; deleteVehicle (nearestObject [_killed, "WeaponHolderSimulated"]); }; // HANDLE CSAT PACIFIC if (faction _killed == "OPF_T_F") then { removeAllWeapons _killed; removeAllItems _killed; removeAllAssignedItems _killed; deleteVehicle (nearestObject [_killed, "WeaponHolderSimulated"]); }; // HANDLE NATO if (faction _killed == "BLU_F") then { removeAllWeapons _killed; removeAllItems _killed; removeAllAssignedItems _killed; deleteVehicle (nearestObject [_killed, "WeaponHolderSimulated"]); }; // HANDLE NATO PACIFIC if (faction _killed == "BLU_T_F") then { removeAllWeapons _killed; removeAllItems _killed; removeAllAssignedItems _killed; deleteVehicle (nearestObject [_killed, "WeaponHolderSimulated"]); }; }]; init.sqf execVM "scripts\misc\LootStop.sqf"; 2 Share this post Link to post Share on other sites
Tajin 349 Posted October 26, 2017 I don't like the idea of making stuff magically disappear. addMissionEventHandler ["EntityKilled", { params["_killed"]; if (_killed isKindOf "Man") then { private _holder = nearestObject [_killed, "WeaponHolderSimulated"]; [_holder,_killed] spawn { params ["_holder","_killed"]; sleep 2; _holder lock true; _killed lock true; sleep 1; _holder enableSimulation false; _killed enableSimulation false; }; }; }]; 1 1 Share this post Link to post Share on other sites
iV - Ghost 50 Posted October 26, 2017 But only on this way the survival factor becomes more weight. And we have to organize the supplies. :-) The only faction who can looted is the syndicate with the AK's. No NVG's, no Titan's, ... . Share this post Link to post Share on other sites
pierremgi 4853 Posted October 26, 2017 7 hours ago, Tajin said: I don't like the idea of making stuff magically disappear. This should simply block any interaction with them. addMissionEventHandler ["EntityKilled", { params["_killed"]; if (_killed isKindOf "Man") then { private _holder = nearestObject [_killed, "WeaponHolderSimulated"]; _killed enableSimulation false; _holder enableSimulation false; }; }]; I'm sure you didn't test it! That can't be fine as is! Share this post Link to post Share on other sites
Tajin 349 Posted October 27, 2017 ^^ certainly not. I was pretty sure disabling the sim would also disallow looting. Guess I mixed that up with something. Anyway, changed it. Works now. Sadly, locking the inventories seems to be a bit bugged and is not 100% reliable. Share this post Link to post Share on other sites
pierremgi 4853 Posted October 27, 2017 Here is a working code for any loot on corpse and lost weapons on ground: inGameUISetEventHandler ["action", " _cont = _this select 0; _act = _this select 3; if ( {cursorTarget isKindOf _x} count ['CAManBase','weaponHolderSimulated'] > 0 && _act in ['Rearm','TakeWeapon','Gear','Inventory'] ) then {true} else {false} " ]; 4 Share this post Link to post Share on other sites
Tajin 349 Posted October 27, 2017 You could still look at the corpse and open your inventory. I guess the only reliable solution is a combination of both an inGameUI-Eventhandler and a "inventoryOpened"-EH. Maybe also combined with a "Take"-EH (for safety) and a "Put"-EH (to make sure player doesn't accidentially drop his own equipment into a locked container) Oh and you really shouldn't block all "weaponHolderSimulated", attach a variable to the ones from dead people so they can be recognized as such. It's a pitty that using "lock" seems to be so unreliable, would've been much easier to use. Not sure whats wrong with that command. - - - - - (untested) So the following in combination might be reliable enough: addMissionEventHandler ["EntityKilled", { params["_killed"]; if (_killed isKindOf "Man") then { private _holder = nearestObject [_killed, "WeaponHolderSimulated"]; _killed setVariable ["holder",_holder]; _holder setVariable ["corpse",_killed]; _killed lock true; _holder lock true; }; }]; inGameUISetEventHandler ["action"," params ["","","","_act"]; if ( !(cursorTarget getVariable ['holder',false]) && !(cursorTarget getVariable ['corpse',false]) ) exitWith { false }; if ( _act in ['Rearm','TakeWeapon','Gear','Inventory'] ) then {true} else {false}; "]; player addEventHandler ["InventoryOpened", { params ["","_cont"]; if ( !(_cont getVariable ["holder",false]) && !(_cont getVariable ["corpse",false]) ) then { false } else { true }; } player addEventHandler ["Put", { params ["","_cont"]; if ( !(_cont getVariable ["corpse",false]) ) exitWith { false }; clearMagazineCargoGlobal _cont; clearWeaponCargoGlobal _cont; clearItemCargoGlobal _cont; clearBackpackCargoGlobal _cont; _cont setVariable ["corpse",nil,true]; }]; Dropping items into a weaponholder that belongs to a corpse, will wipe it clean first. 2 Share this post Link to post Share on other sites
katipo66 94 Posted October 27, 2017 On 6 April 2016 at 4:04 AM, Bnae said: player addMPEventHandler ["MPKilled",{_unit = _this select 0; removeAllWeapons _unit; removeAllAssignedItems _unit; clearMagazineCargo _unit}]; This can be used to limit what you can take Could that some how be modified to leave one or 2 magazines no matter how many magazines the killed unit has? This is an interesting thread for me as I found the only solution for looting a dead a body is completely removing its inventory or disabling the option to search it all together which both seem wrong, what about some middle ground that rewards the killer but does not make searching a boring chore due to the fact they all carry the same equipment, maybe something that can leave a mag or 2 and maybe a chance of some defined equipment To replicate what I see when watching Day Z or Escape Takarov videos where player never knows what he might get. apologies I get its probably out of the scope of this thread, but it's subject is along the lines of what I'm currently searching for. Share this post Link to post Share on other sites