Jump to content
  • 0

EPOCH_playerCrypto


second_coming

Question

13 answers to this question

Recommended Posts

  • 0

To check Bank Balance use 

hintC format ["You Have %2 Crypto in your bank", [player], EPOCH_bankBalance];
hintC_EH = findDisplay 57 displayAddEventHandler ["unload", {
0 = _this spawn {
_this select 0 displayRemoveEventHandler ["unload", hintC_EH];
hintSilent "";
};
}];

Transfer player crypto to bank :

_amount = 500;
EPOCH_storeCrypto_PVS = [player, [_amount], Epoch_personalToken];
publicVariableServer "EPOCH_storeCrypto_PVS";

Hope this helps :-)

 

for a quick check on crypto balance and bank balance just use below :-)

//bank balance
hint format ["You Have %2 Crypto in your bank", [player], EPOCH_bankBalance];
hintC_EH = findDisplay 57 displayAddEventHandler ["unload", {
0 = _this spawn {
_this select 0 displayRemoveEventHandler ["unload", hintC_EH];
hintSilent "";
};
}];

sleep 2;

//cryto balance
hint format ["You Have %2 Crypto on you", [player], EPOCH_playerCrypto];
hintC_EH = findDisplay 57 displayAddEventHandler ["unload", {
0 = _this spawn {
_this select 0 displayRemoveEventHandler ["unload", hintC_EH];
hintSilent "";
};
}];
Link to comment
Share on other sites

  • 0

Thanks for this.

So on the server side, we can simply and directly manipulate the two variables:

EPOCH_bankBalance

&

EPOCH_playerCrypto

and Epoch server module will take care of timely database write of any changes we might make.

right?

(I will try later this week when I wrap up basic functionality but would be good if I get confirmation on the above)

Link to comment
Share on other sites

  • 0

Thanks for this.

So on the server side, we can simply and directly manipulate the two variables:

EPOCH_bankBalance

&

EPOCH_playerCrypto

and Epoch server module will take care of timely database write of any changes we might make.

right?

(I will try later this week when I wrap up basic functionality but would be good if I get confirmation on the above)

 

yes should work.  let me know how you get on . will try a few ideas myself later today :-)

Link to comment
Share on other sites

  • 0

Would be cool if you could combine this with an animation hotkey so when the player presses it, they pull out their phone, check their balance and the script displays the output for the player, then the player puts their phone away and continues on.  That would tie into the fact that when you die you lose your phone on the ground which can be picked up by other players and then they can steal your Crypto.  

Link to comment
Share on other sites

  • 0

I know this topic is old but is there any way to edit the player's bank balance serverside?

 

For instance, say I have a bike building script that I want to charge 50 crypto out of the player's bank to build.

 

I tried this last night and had moderate success:

 

assume _newBalance = 5000;

_return=["Bank",_plyrUID,EPOCH_expiresBank,[_newBalance]]call EPOCH_server_hiveSETEX;

This will indeed alter the balance of the player in ram but it doesn't seem to make the change the redis.

 

When I call the following to check the player's balance, it reports, 5000:

GetPlayersBankBalance = {
        private["_playerUID","_balance","_query"];
        _playerUID = _this select 0;
        _balance = 0;                
        diag_log format["getting bank balance for playeruid: %1", _playerUID];        
        _response=["Bank",_playerUID]call EPOCH_server_hiveGET;
        diag_log format ["Response: %1", _response];       
		
		if((_response select 0)==1 && typeName(_response select 1)=="ARRAY")then{            
			_bankData=_response select 1;
			_bankBalance=0;
			_bankBalanceBefore=0;
			
            diag_log format["got into the if _bankData: %1", _bankData];
            if !(_bankData isEqualTo[])then {
				_balance=_bankData select 0;				
			};					            
    	};
        _balance;
    };

return:

 


15:06:13 "BANK: B Alpha 1-2:2 (XXXX) REMOTE (XXXXXXXXXXXXXXXX) TRADE: []"
15:06:54 "getting bank balance for playeruid: any"
15:06:54 "Response: [1,[5000]]"
15:06:54 "got into the if _bankData: [5000]"
15:06:54 "WE GOT A BALANCE NOW: 5000"

 

So it is returning a new balance of 5000, Great!  But, when I check redis...  I get

 

 

[31800]

 

and ingame it shows the same.

 

 

 

 

edit:  I think I found the problem, it is with

"getting bank balance for playeruid: any"
Link to comment
Share on other sites

  • 0

ok some more...

 

so I got the bugs fixed (I think).  But I am still having issues setting a player's bank data:

 

check balance code (working)

GetPlayersBankBalance = {
        private["_playerUID","_balance"];
        _playerUID = _this select 0;
        _balance = 0;        
        
        diag_log format["getting bank balance for playeruid: %1", _playerUID];        
        _response=["Bank",_playerUID]call EPOCH_server_hiveGET;
        diag_log format ["Response: %1", _response];
        
if((_response select 0)==1 && typeName(_response select 1)=="ARRAY")then{            
_bankData=_response select 1;
_bankBalance=0;
_bankBalanceBefore=0;
 
            diag_log format["got into the if _bankData: %1", _bankData];
            if !(_bankData isEqualTo[])then {
_balance=_bankData select 0; 
};             
     };
        _balance;
    };

This gets old balance, adds 5000 to it, and attempts to save to redis

_oldBalance = [_playerUID] call GetPlayersBankBalance;                    
_newBalance = _oldBalance + 5000;
diag_log format["_oldBalance: %1 _newBalance: %2", _oldBalance,_newBalance];
_return=["Bank",_playerUID,EPOCH_expiresBank,[_newBalance]]call EPOCH_server_hiveSETEX;

any ideas?

 

 

 

edit:  appears to be working now???  

[qoute]

16:08:54 "getting bank balance for playeruid: 765611XXXXXXXXXXX"
16:08:54 "Response: [1,[2243]]"
16:08:54 "GMS: got into the if _bankData: [2243]"
16:08:54 "_oldBalance: 2243 _newBalance: 7243"
16:08:54 "getting bank balance for playeruid: 765611XXXXXXXXXXX"
16:08:54 "Response: [1,[7243]]"
16:08:54 "GMS: got into the if _bankData: [7243]"
16:08:54 "WE GOT A BALANCE NOW: 7243"

Link to comment
Share on other sites

  • 0

<snip>

edit:  appears to be working now???

<snip>

Confirmed with player it worked!   redis says:

 

Going to leave this and code up here unless Devs ask me to remove it.  This should help others with their banking modifications serverside

Cool, man, thanks for reporting success. I will use your code then. I will need it soon.

Link to comment
Share on other sites

  • 0

Does anyone know whether checking a players 'EPOCH_playerCrypto' in a script is just the amount they have on them or does it include their bank balance also?

<snip>

 

 

 

To check Bank Balance use 

<snip> 

 

 

I know this topic is old but is there any way to edit the player's bank balance serverside?

<snip>

Hey guys, working on this code tonight, wanted to take a moment to thank you all for this thread - very helpful! vehicles will give you 50% discount, I promise :D

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...