49lone82 11 Posted December 11, 2015 Looking for a script or how to info. I want players to respawn with the exact same thing....... weapons, mags, gear that they had on them when they were killed. Aerosons's Get/Set Loadout no longer is supported or working so please dont give me that link. I am to the point of willing to pay to get this working. Share this post Link to post Share on other sites
Guest Posted December 11, 2015 Hello ! You can use addEventHandler with the killed event. I bet you can call your gear save right there Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 11, 2015 onPlayerKilled.sqf _unit = _this select 0; [_unit, [_unit, "SavedInventory"]] call BIS_fnc_saveInventory; onPlayerRespawn.sqf _unit = _this select 0; [_unit, [_unit, "SavedInventory"]] call BIS_fnc_loadInventory; Untested... Share this post Link to post Share on other sites
bull_a 44 Posted December 11, 2015 onPlayerKilled.sqf _unit = _this select 0; [_unit, [_unit, "SavedInventory"]] call BIS_fnc_saveInventory; onPlayerRespawn.sqf _unit = _this select 0; [_unit, [_unit, "SavedInventory"]] call BIS_fnc_loadInventory; Untested... I would add them to an EventHandler, you can only have one onPlayerXXX.sqf whereas you can have multiple event handlers for a unit. The theory and code is the same (or relatively similar) though, both ways will execute on the player onXXXX event. Bull Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 11, 2015 I would add them to an EventHandler, you can only have one onPlayerXXX.sqf whereas you can have multiple event handlers for a unit. The theory and code is the same (or relatively similar) though, both ways will execute on the player onXXXX event. Bull The onPlayerRespawn and onPlayerKilled are event scripts and are executed for every player that dies/respawns. It's the exact same as using an event handler, only easier. Share this post Link to post Share on other sites
bull_a 44 Posted December 11, 2015 The onPlayerRespawn and onPlayerKilled are event scripts and are executed for every player that dies/respawns. It's the exact same as using an event handler, only easier. So can the event handlers, I feel as though they offer more control over who executes the onXXX event :) I wouldn't agree with it being easier, it depends on how you prefer to script. I was only suggesting another alternative, as I would prefer to do it with event handlers. Both solutions would work :) Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 11, 2015 So can the event handlers, I feel as though they offer more control over who executes the onXXX event :) I wouldn't agree with it being easier, it depends on how you prefer to script. I was only suggesting another alternative, as I would prefer to do it with event handlers. Both solutions would work :) Ah right I thought you were saying that onPlayerRespawn.sqf only handles one player object so you'd have to make onXObjectRespawn.sqf etc.. lol Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted December 11, 2015 The onPlayerRespawn and onPlayerKilled are event scripts and are executed for every player that dies/respawns. It's the exact same as using an event handler, only easier. not quite the same event handlers store the expression in memory and don't have to compile the code again when its called. the event scripts are not stored in memory and the engine must compile the code each execution. performance-wise, you're better off using an event handler ... of course this is nitpicking though. both methods work as you say. 1 Share this post Link to post Share on other sites
irx 1 Posted December 11, 2015 Umm... I'm still using Aeroson's script, works perfectly on my mission. :ph34r: Haven't tried with "gear changing" mods tho. init.sqf // Compile scripts getLoadout = compile preprocessFileLineNumbers 'get_loadout.sqf'; setLoadout = compile preprocessFileLineNumbers 'set_loadout.sqf'; // Save loadout (including ammo count) every 2 seconds [] spawn { while{true} do { if(alive player) then { loadout = [player,["ammo","repetitive"]] call getLoadout; }; sleep 2; }; }; // Load saved loadout (including ammo count) on respawn player addEventHandler ["Respawn", { [player,loadout,["ammo"]] spawn setLoadout; } ]; Share this post Link to post Share on other sites
49lone82 11 Posted December 12, 2015 Umm... I'm still using Aeroson's script, works perfectly on my mission. :ph34r: Haven't tried with "gear changing" mods tho. init.sqf Are you just adding that to the main init? I'm trying to get this to work in Wasteland Share this post Link to post Share on other sites
irx 1 Posted December 12, 2015 Are you just adding that to the main init? I'm trying to get this to work in Wasteland Yes and I also added waitUntil {!isNull player}; before the script in init.sqf. And ofcourse those 2 script files 'get_loadout.sqf' and 'set_loadout.sqf' from Aeroson's script. Hope it helps. Share this post Link to post Share on other sites
49lone82 11 Posted December 14, 2015 Here is what my onKilled.sqf and onRespawn.sqf look like. what do I need to modify. onPlayerKilled.sqf _unit = _this select 0; [_unit, [_unit, "SavedInventory"]] call BIS_fnc_saveInventory; onPlayerRespawn.sqf _unit = _this select 0; [_unit, [_unit, "SavedInventory"]] call BIS_fnc_loadInventory; Untested... Here is what my onKilled.sqf and onRespawn.sqf look like. what do I need to modify. onKilled.sqf // ****************************************************************************************** // * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com * // ****************************************************************************************** // @file Version: 1.0 // @file Name: onKilled.sqf // @file Author: [404] Deadbeat, MercyfulFate, AgentRev // @file Created: 20/11/2012 05:19 _player = _this select 0; _presumedKiller = effectiveCommander (_this select 1); _killer = _player getVariable "FAR_killerPrimeSuspect"; if (isNil "_killer") then { _killer = _player call FAR_findKiller }; if (isNull _killer) then { _killer = _presumedKiller }; if (_killer == _player) then { _killer = objNull }; [_player, _killer, _presumedKiller] spawn { if (isServer) then { _this call server_PlayerDied; } else { PlayerCDeath = _this; publicVariableServer "PlayerCDeath"; }; }; if (_player == player) then { closeDialog 2001; // Close Gunstore closeDialog 2009; // Close Genstore closeDialog 5285; // Close Vehstore uiNamespace setVariable ["BIS_fnc_guiMessage_status", false]; // close message boxes // Load scoreboard in render scope ["A3W_scoreboard", "onEachFrame", { call loadScoreboard; ["A3W_scoreboard", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; }] call BIS_fnc_addStackedEventHandler; playerData_infoPairs = nil; playerData_savePairs = nil; //combatTimestamp = -1; // Reset abort timer }; _player setVariable ["FAR_killerPrimeSuspect", nil]; _player setVariable ["FAR_killerVehicle", nil]; _player setVariable ["FAR_killerAmmo", nil]; _player setVariable ["FAR_killerSuspects", nil]; _player connectTerminalToUAV objNull; //disconnect _player spawn { _player = _this; _money = _player getVariable ["cmoney", 0]; _player setVariable ["cmoney", 0, true]; _items = []; { _id = _x select 0; _qty = _x select 1; _type = (_id call mf_inventory_get) select 4; _items pushBack [_id, _qty, _type]; [_id, _qty] call mf_inventory_remove; } forEach call mf_inventory_all; // wait until corpse stops moving before dropping stuff waitUntil {(getPos _player) select 2 < 1 && vectorMagnitude velocity _player < 1}; // Drop money if (_money > 0) then { _m = createVehicle ["Land_Money_F", getPosATL _player, [], 0.5, "CAN_COLLIDE"]; _m setDir random 360; _m setVariable ["cmoney", _money, true]; _m setVariable ["owner", "world", true]; }; // Drop items _itemsDroppedOnDeath = []; { _id = _x select 0; _qty = _x select 1; _type = _x select 2; for "_i" from 1 to _qty do { _obj = createVehicle [_type, getPosATL _player, [], 0.5, "CAN_COLLIDE"]; _obj setDir random 360; _obj setVariable ["mf_item_id", _id, true]; _itemsDroppedOnDeath pushBack netId _obj; }; } forEach _items; itemsDroppedOnDeath = _itemsDroppedOnDeath; publicVariableServer "itemsDroppedOnDeath"; }; _player spawn fn_removeAllManagedActions; removeAllActions _player; // Same-side kills if (_player == player && (playerSide == side group _killer) && (player != _killer) && (vehicle player != vehicle _killer)) then { // Handle teamkills if (playerSide in [BLUFOR,OPFOR]) then { if (_killer isKindOf "CAManBase") then { pvar_PlayerTeamKiller = _killer; } else { pvar_PlayerTeamKiller = objNull; }; } else // Compensate negative score for indie-indie kills { if (isPlayer _killer) then { pvar_removeNegativeScore = _killer; publicVariableServer "pvar_removeNegativeScore"; }; }; }; onRespawn.sqf // ****************************************************************************************** // * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com * // ****************************************************************************************** // @file Version: 1.0 // @file Name: onRespawn.sqf // @file Author: [404] Deadbeat // @file Created: 20/11/2012 05:19 // @file Args: private ["_player", "_corpse"]; playerSetupComplete = false; 9999 cutText ["", "BLACK", 0.01]; 9123 cutRsc ["RscEmpty", "PLAIN"]; _player = _this select 0; _corpse = _this select 1; _corpse setVariable ["newRespawnedUnit", _player, true]; _player setVariable ["playerSpawning", true, true]; pvar_playerRespawn = _player; publicVariableServer "pvar_playerRespawn"; _group = _player getVariable ["currentGroupRestore", grpNull]; if (!isNull _group && {group _player != _group}) then { [_player] join _group; if (_player getVariable ["currentGroupIsLeader", false] && leader _group != _player) then { _group selectLeader _player; }; }; _respawnMarker = switch (playerSide) do { case BLUFOR: { "respawn_west" }; case OPFOR: { "respawn_east" }; case INDEPENDENT: { "respawn_guerrila" }; default { "respawn_civilian" }; }; _respawnMarkers = []; { if ([_respawnMarker, _x] call fn_startsWith) then { _respawnMarkers pushBack _x; }; } forEach allMapMarkers; _respawnPos = markerPos (_respawnMarkers call BIS_fnc_selectRandom); if !(_respawnPos isEqualTo [0,0,0]) then { _player setPos _respawnPos; }; _player call playerSetup; //[] execVM "client\clientEvents\onMouseWheel.sqf"; call playerSpawn; if (isPlayer pvar_PlayerTeamKiller) then { pDialogTeamkiller = pvar_PlayerTeamKiller; pvar_PlayerTeamKiller = objNull; [] execVM "client\functions\createTeamKillDialog.sqf"; }; Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 14, 2015 Well first off the files are named wrong... Share this post Link to post Share on other sites
49lone82 11 Posted December 14, 2015 This is what the files are named in wasteland. Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 14, 2015 This is what the files are named in wasteland. But it's wrong... Look at the event scripts, there's no reference to onRespawn or onKilled. Share this post Link to post Share on other sites
49lone82 11 Posted December 15, 2015 But it's wrong... Look at the event scripts, there's no reference to onRespawn or onKilled. This I know. What i need to do is merge the code in onPlayerkilled into onkilled and onPlayerRespawn into onRespawn. Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 15, 2015 But.. But.. It just won't work... I don't know how I can explain this any further... You HAVE to use onPlayerRespawn/onPlayerKilled... Share this post Link to post Share on other sites
Larrow 2823 Posted December 16, 2015 You HAVE to use onPlayerRespawn/onPlayerKilled...You can use anything you like. All depends how it is setup.If you have your own respawnTemplate you can call any file/function you like. If you monitor client deaths using addEventHandler["Killed".. again you can call anything you like. As for wasteland from a quick browse of the files on github i believe they use the second option e.g \client\functions\clientCompile.sqf onKilled = "client\clientEvents\onKilled.sqf" call mf_compile; and \client\init.sqf player addEventHandler ["Killed", { _this spawn onKilled }];For the saving you should just be able to add the code straight in the top of onKilled.sqf and change _unit for _player.. _player = _this select 0; [_player, [_player, "SavedInventory"]] call BIS_fnc_saveInventory; _presumedKiller = effectiveCommander (_this select 1); _killer = _player getVariable "FAR_killerPrimeSuspect";For respawning they use \client\functions\clientCompile.sqf onRespawn = "client\clientEvents\onRespawn.sqf" call mf_compile; and \client\init.sqf player addEventHandler ["Respawn", { _this spawn onRespawn }];So to restore the players gear you should just be able to place the code at the end of onRespawn.sqf again swapping _unit for _player if (isPlayer pvar_PlayerTeamKiller) then { pDialogTeamkiller = pvar_PlayerTeamKiller; pvar_PlayerTeamKiller = objNull; [] execVM "client\functions\createTeamKillDialog.sqf"; }; //Check to see if player has a saved inventory if ( _player getVariable ["bis_fnc_saveInventory_data",[]] find "SavedInventory" > -1 ) then { [_player, [_player, "SavedInventory"]] call BIS_fnc_loadInventory; };And ive added a check just to make sure the player has a "savedInventory" just incase wasteland uses this script for starting spawn.This should apply the saved gear after the default wasteland restore. Again only from a quick browse of the files so there maybe other things that need looking into. 1 Share this post Link to post Share on other sites
pvt. partz 248 Posted May 15, 2018 Interesting read but alas, my ability to take what is talked about and use it in a mission is pretty much a no-go. I would like to ask if a saved gear "onplayerkilled" and a load saved gear "onplayerspawn" could be made into a mod so that I (we who need our hands held) can just add it to our mods list,......or is that possible? In other words, when I get killed, I want to respawn with the gear I had on me when I died. Not a fresh (fully replenished) loadout. I have tried so many different scripts but nothing seems to work. Thanks in advance Share this post Link to post Share on other sites
gokitty1199 225 Posted May 16, 2018 3 hours ago, pvt. partz said: Interesting read but alas, my ability to take what is talked about and use it in a mission is pretty much a no-go. I would like to ask if a saved gear "onplayerkilled" and a load saved gear "onplayerspawn" could be made into a mod so that I (we who need our hands held) can just add it to our mods list,......or is that possible? In other words, when I get killed, I want to respawn with the gear I had on me when I died. Not a fresh (fully replenished) loadout. I have tried so many different scripts but nothing seems to work. Thanks in advance to make this simple do this. inside the missions folder, create a file called onPlayerRespawn.sqf and onPlayerKilled.sqf like this https://gyazo.com/41ad339d0bceb91620a09e7a8bcd2500 inside of onPlayerKilled paste this into it playersGear = getUnitLoadout player; inside of onPlayerRespawn paste this into it player setUnitLoadout playersGear; when the player is killed it saves his gear, when the player respawns it loads the variable(playersGear) that has the units loadout saved onto the player. make sense? 1 Share this post Link to post Share on other sites
pvt. partz 248 Posted May 16, 2018 Thanks very much for the reply. I did exactly that and it works wonderfully, however,... I found out the reason why I was having so much trouble. I'm playing the awesome mission called liberation, and come to find out that there is a load out script inside his mission, which didn't play nice with anything I wanted to add as far as loadout editing. I did a little tinkering and removed his load up script and added exactly what you said. I haven't died yet so we'll see fingers crossed. Share this post Link to post Share on other sites
pvt. partz 248 Posted May 17, 2018 Played a little bit more and being able to respond with the gear that I had when I died is pretty much hit and miss. After everything we've tried, there really doesn't seem to be a sure-fire way to accomplish what I'm after. .... Also, if I'm playing Co-op are there other parameters that are required so that my partner can also benefit from the same solution (when one is found)? We don't have a dedicated server we just play locally on my computer. Share this post Link to post Share on other sites