Jump to content

Recommended Posts

14 hours ago, iV - Ghost said:

save the money

 

With a variable and add a onPlayerRespawn.sqf to load , add to your inventory

Share this post


Link to post
Share on other sites

I have tried with a respawn EventHandler in the initPlayerLocal.sqf but doesn't work.

Maybe I have to save the money in the onPlayerKilled.sqf and give the player back in the eventHandler or onPlayerRespawn.sqf?

 

That was the not working eventHandler:

player addEventHandler ["Respawn", {

    // VARIABLES
    params ["_newBody", "_oldBody"];
  
  
    // SAVE HEROS MONEY
    private _money = _oldBody getVariable "Heros_L_Money";
    _newBody setVariable ["Heros_L_Money", "_money"];
  
  
    // DELETE PLAYER CORPSE
    deleteVehicle _oldBody;
	
}];

 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, iV - Ghost said:

onPlayerKilled.sqf

 

To save the money when you are killed :

 

Create an onPlayerKilled.sqf and add:

missionNamespace setVariable ["GF_Save_Her_L_Money", Her_L_Money];

and create an onPlayerRespawn.sqf and add:

missionNamespace getVariable "GF_Save_Her_L_Money";
Her_L_Money = GF_Save_Her_L_Money;

 

Share this post


Link to post
Share on other sites

OK thanks so far. But will this variable not be overwritten if another player gets killed?

  • Like 1

Share this post


Link to post
Share on other sites
36 minutes ago, iV - Ghost said:

But will this variable not be overwritten

 

To be honest , i don't have any idea !

But since it is onplayerespawn it should be fine .

Can you test this?

Share this post


Link to post
Share on other sites
4 hours ago, iV - Ghost said:

I will test it.

 

 

Would you like to check also for this?

 

onPlayerKilled.sqf

missionNamespace setVariable ["GF_Save_Her_L_Money", Her_L_Money, false];

 

onPlayerRespawn.sqf

missionNamespace getVariable ["GF_Save_Her_L_Money", false];
Her_L_Money = GF_Save_Her_L_Money;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

The missionNamespace is global. If you wanna use it you have to create a own variable for every player.

You can add the UID or something else.

 

But it looks like you can do this with the profileNamespace.

 

 

 

onPlayerKilled.sqf

// SAVE MONEY
profileNamespace setVariable ["TAG_yourVariable", Her_L_Money];

 

onPlayerRespawn.sqf

// LOAD MONEY
Her_L_Money = profileNamespace getVariable "TAG_yourVariable";

 

 

Thanks for helping.

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×