• 0
Sign in to follow this  
Followers 0
Newbie Script

Please help me fix my script about update scores and moneys to DB.

Question

Spoiler

_playermoney = player getVariable ["ExileMoney", 0];

if (_playerMoney < 10000) exitwith
{
	[
		"ErrorTitleAndText",
		["Random crate fail", "You must have money $10000"]
	] call ExileClient_gui_toaster_addTemplateToast;	
};

	_playermoney = player getVariable ["ExileMoney", 0];
	_playermoney = _playermoney - 10000;
	player setVariable ["ExileMoney",_playermoney];
	player setVariable['PLAYER_STATS_VAR', [player getVariable ['ExileMoney', 0], _playermoney],true];
	format["setAccountMoney:%1:%2", _playermoney,getPlayerUID player] call ExileServer_system_database_query_fireAndForget;
	
	ExileClientPlayerMoney = _playermoney;
	(owner player) publicVariableClient "ExileClientPlayerMoney";
	ExileClientPlayerMoney = nil;
	player call ExileServer_object_player_database_update;
	
	[
			"ErrorTitleAndText",
			["Start random crate", "You pay $10000 for random crate"]
	] call ExileClient_gui_toaster_addTemplateToast;
	
// Respect
	if (random 1 > 0.3) then
	{
		_scores = round(random 5000);
		_playerscore = player getVariable ["ExileScore", 0];
		_playerscore = _playerscore + _scores;
		player setVariable ["ExileScore",_playerscore];
		player setVariable['PLAYER_STATS_VAR', [player getVariable ['ExileScore', 0], _playerscore],true];
		format["setAccountScore:%1:%2", _playerscore,getPlayerUID player] call ExileServer_system_database_query_fireAndForget;
		
		ExileClientPlayerScore = _playerscore;
		(owner player) publicVariableClient "ExileClientPlayerScore";
		ExileClientPlayerScore = nil;
		player call ExileServer_object_player_database_update;
		
		["InfoTitleAndText",
		[
			"You got respect scores",
			format ["You got respect %1 scores",_scores]
		]
	] call ExileClient_gui_toaster_addTemplateToast;
	};
	
// Money
		if (random 1 > 0.5) then
		{
			_moneys = round(random 30000);
			_playermoney = player getVariable ["ExileMoney", 0];
			_playermoney = _playermoney + _moneys;
			player setVariable ["ExileMoney",_playermoney];
			player setVariable['PLAYER_STATS_VAR', [player getVariable ['ExileMoney', 0], _playermoney],true];
			format["setAccountMoney:%1:%2", _playermoney,getPlayerUID player] call ExileServer_system_database_query_fireAndForget;
			
			ExileClientPlayerMoney = _playermoney;
			(owner player) publicVariableClient "ExileClientPlayerMoney";
			ExileClientPlayerMoney = nil;
			player call ExileServer_object_player_database_update;
			
			["InfoTitleAndText",
				[
					"You got moneys",
					format ["You got $ %1",_moneys]
				]
			] call ExileClient_gui_toaster_addTemplateToast;
		};
  };

 

I try to make random crate script and it only work before rejoin.

When i start random crate my money remove.

EX. I have $100,000 after start random crate i check in my gear correct remove money.

After rejoin by go to lobby and join again my money roll back to $100,000 that meaning not update to DB.

I need help about update to DB problem.

Thank you sir.

Share this post


Link to post
Share on other sites

0 answers to this question

There have been no answers to this question yet

Advertisement

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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.