• 0
[RG] Salutesh

Update Player poptabs and respect in 1.0.0?!

Question

Hello Exile Mod Team,

Maybe you can give me a helping hand on a little  project i am working on because i am still a noob in scripting.

I look for an easy way to update poptabs and respect for players with the needed database update within a function that is calling a script.

Here is a simple sample what i am trying to do with the new bis_fnc_holdActionAdd function. :

Thats my try to give them the money:

Quote

/*

	Gives (or removes) a player's respect/poptabs for hacking pc.

	Usage:
	_playerObj call exile_fnc_pcEvent;

*/

params ["_playerObj"];

private _playerUID = getPlayerUID _playerObj;

if ((!isNull _playerObj) && {(_playerUID != "") && {_playerObj isKindOf "Exile_Unit_Player"}}) then
{

	private _playerMoney = _playerObj getVariable ["ExileMoney", 0];
	private _playerRespect = _playerObj getVariable ["ExileScore", 0];

	// Set client's money and respect
	_moneyChange = 1000;
	_repChange = 1000;
	_playerMoney = (_playerMoney + _moneyChange) max 0;
	_playerRespect = _playerRespect + _repChange;
	_playerObj setVariable ["ExileMoney",_playerMoney,true];
	_playerObj setVariable ["ExileScore",_playerRespect,true];

	// Create and send message to player
	private _msgParams =
		if (_moneyChange > 0) then
		{
			["SuccessTitleOnly",[format ["Gained %1 poptabs and %2 repect for hacking the bandits.",abs _moneyChange, _repChange]]] call ExileClient_gui_toaster_addTemplateToast;
		}
		else
		{
			["ErrorTitleOnly",[format ["Lost %1 poptabs and %2 repect for hacking the bandits.",abs _moneyChange, _repChange]]] call ExileClient_gui_toaster_addTemplateToast;
		};

		// Update money and respect in database
		format["setPlayerMoney:%1:%2", _playerMoney, _playerObj getVariable ["ExileDatabaseID", 0]] call ExileServer_system_database_query_fireAndForget;
		format["setAccountScore:%1:%2", _playerRespect, _playerUID] call ExileServer_system_database_query_fireAndForget;
};
params ["_playerObj"];

 

Thank you <3

1 person likes this

Share this post


Link to post
Share on other sites

1 answer to this question

  • 1

The code you posted looks fine, but you are executing it on the client. You need to execute that on the server! :) 

Only the server "talks" to the database, so your ExileServer_system_database_query_fireAndForget will not work on the client.

2 people like this

Share this post


Link to post
Share on other sites
Advertisement

  • Recently Browsing   0 members

    No registered users viewing this page.