Jump to content

Force goldcoins update onplayerDisconnect


Recommended Posts

Force update money on disconnect:

Potential for decreasing amount of communication gameserver <-> hive <-> database

 

in: variables.sqf

Find:

if(isNil "DZE_maintainRange") then {
    DZE_maintainRange = ((DZE_PlotPole select 0)+35);
};

Add below:

if(isNil "DZE_fUpdateMoney") then {
    DZE_fUpdateMoney = false;
};

Note: you can set it here to true or use the variable in init.sqf

In: server_onPlayerDisconnect.sqf

Find:

[_playerObj,_magazines,true,true,_isplayernearby] call server_playerSync;

Replace with:

[_playerObj,_magazines,true,true,_isplayernearby,DZE_fUpdateMoney] call server_playerSync;

in: server_playerSync.sqf

Find:

if( isNil "_headShotsZupa") then{
    _headShotsZupa = 0;
};

Add below:

_fUpdateMoney = false;
if ((count _this) > 5) then {
    _fUpdateMoney = _this select 5;
};

Find:

if(_isChanged > 0)then{        
_key = format["CHILD:999:UPDATE `character_data` SET `HeadshotsZ` = %1 WHERE `CharacterID` = %2:[0]:",_headShotsZupa,_characterID];            
_result = _key call server_hiveReadWrite;        
_character setVariable ["moneychanged",0,true];            
};

Replace with:

if((_isChanged > 0) || _fUpdateMoney)then{    
_key = format["CHILD:999:UPDATE `character_data` SET `HeadshotsZ` = %1 WHERE `CharacterID` = %2:[0]:",_headShotsZupa,_characterID];            
_result = _key call server_hiveReadWrite;        
_character setVariable ["moneychanged",0,true];            
};

Link to comment
Share on other sites

Force update money on disconnect:

Potential for decreasing amount of communication gameserver <-> hive <-> database

 

in: variables.sqf

Find:

if(isNil "DZE_maintainRange") then {
    DZE_maintainRange = ((DZE_PlotPole select 0)+35);
};

Add below:

if(isNil "DZE_fUpdateMoney") then {
    DZE_fUpdateMoney = false;
};

Note: you can set it here to true or use the variable in init.sqf

In: server_onPlayerDisconnect.sqf

Find:

[_playerObj,_magazines,true,true,_isplayernearby] call server_playerSync;

Replace with:

[_playerObj,_magazines,true,true,_isplayernearby,DZE_fUpdateMoney] call server_playerSync;

in: server_playerSync.sqf

Find:

if( isNil "_headShotsZupa") then{
    _headShotsZupa = 0;
};

Add below:

_fUpdateMoney = false;
if ((count _this) > 5) then {
    _fUpdateMoney = _this select 5;
};

Find:

if(_isChanged > 0)then{        
_key = format["CHILD:999:UPDATE `character_data` SET `HeadshotsZ` = %1 WHERE `CharacterID` = %2:[0]:",_headShotsZupa,_characterID];            
_result = _key call server_hiveReadWrite;        
_character setVariable ["moneychanged",0,true];            
};

Replace with:

if((_isChanged > 0) || _fUpdateMoney)then{    
_key = format["CHILD:999:UPDATE `character_data` SET `HeadshotsZ` = %1 WHERE `CharacterID` = %2:[0]:",_headShotsZupa,_characterID];            
_result = _key call server_hiveReadWrite;        
_character setVariable ["moneychanged",0,true];            
};

Good job. I believe this would also fix a lot of duping problems as well.

Link to comment
Share on other sites

Great idea, only problem i see whit this (if you are going to make that an && and only save on disconnect) is that when server restarts with players still on it, their cast will not get saved, cus server is not running anymore.

 

This could be solved maybe with a force disconnect script ofcoruse that handles like 30secs before the actual restart.

Link to comment
Share on other sites

Great idea, only problem i see whit this (if you are going to make that an && and only save on disconnect) is that when server restarts with players still on it, their cast will not get saved, cus server is not running anymore.

This could be solved maybe with a force disconnect script ofcoruse that handles like 30secs before the actual restart.

Simple way to fix that would be have a acript that will save it based on the time the user puts. (e.g server restarts every 3 hours have the server save it at 2 hours and 59 minutes)
Link to comment
Share on other sites

you could use server uptime

but if the server was restarted manually that would cause problems.

 

or we could use the hive's getDateTime module to get system time and work of that.

wich should be far more reliable.

Link to comment
Share on other sites

  • 1 month later...

Ok I've followed every step here and I still cannot get my coin to save to the player. Nothing shows up for errors in the RPT file. I really am at a loss here for trying to get this currency to work. I've re-installed the DLL files many times, this page here I thought for sure was going to help, but still nothing. Can someone please help me. Everything else for the currency works fine. If I buy other currency such as gold bars or briefcases or whatever, it all saves upon a disconnect. It's just that if I have any coin on me or in bank, it won't save it.

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...