KnatteAnka

Dynamic Locker

9 posts in this topic

Hi all now i have created a fun thing to att to your server to give the locker a dynamic value that rises with the more rank you get :)

Github improved and perfected version: 

ExileDynamicLocker by g0dsCookie inspired by me KnatteAnka

https://github.com/redned70/ExileDynamicLocker fork by RedNed from g0dsCookie version improved display of large values in bank!

4 files that is edited

Config.cpp

Spoiler

class CfgLocker
    {
        numbersOnly = "0123456789";
        maxDeposit = 60000;
        Respect_multiplyer =0.85;
    };
class CfgExileCustomCode 
{
	// Locker Respect
	ExileServer_system_locker_network_lockerDepositRequest = "Custom\Resp_Locker\ExileServer_system_locker_network_lockerDepositRequest.sqf";
	ExileClient_gui_lockerDialog_event_onDepositButtonClick = "Custom\Resp_Locker\ExileClient_gui_lockerDialog_event_onDepositButtonClick.sqf";
	ExileClient_gui_lockerDialog_show = "Custom\Resp_Locker\ExileClient_gui_lockerDialog_show.sqf";
};

 

meaning a level1 respect player gets 60k locker and a lvl 2 get 111k locker and so on.

ExileClient_gui_lockerDialog_show.sqf

Spoiler

/**
 * ExileClient_gui_lockerDialog_show
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_dialog", "_lockerAmount", "_lockerLimit", "_depositInput", "_withdrawInput", "_lockerAmountLabel", "_inventoryAmount", "_inventoryAmountString", "_inventoryAmountLabel","_requiredRespect","_Respect","_Respect_multiplyer","_Respectlevels"];
disableSerialization;
createDialog "RscExileLockerDialog";
_dialog = uiNameSpace getVariable ["RscExileLockerDialog", displayNull];
_lockerAmount = player getVariable ["ExileLocker", 0];
// Old  code: _lockerLimit = (getNumber(missionConfigFile >> "CfgLocker" >> "maxDeposit"));
//////////////////////////////////////
//New locker code by Knatte_Anka
//////////////////////////////////////
_Respect_multiplyer = getNumber(missionConfigFile >> "CfgLocker" >> "Respect_multiplyer");
_Respectlevels = Count (missionConfigFile >> "CfgTrading" >> "requiredRespect"	);
for "_i" from 1 to _Respectlevels do
	{
		_requiredRespect = getNumber(missionConfigFile >> "CfgTrading" >> "requiredRespect" >> format["Level%1",_i]);
		if (_requiredRespect < ExileClientPlayerScore) then
		{
			_Respect = _i-1;
		};
	};
	
_lockerLimit = round ((getNumber(missionConfigFile >> "CfgLocker" >> "maxDeposit"))	* (1+(_Respect_multiplyer*(_Respect))));

//////////////////////////////////////

_depositInput = _dialog displayCtrl 4006;
_depositInput ctrlSetText "";
_withdrawInput = _dialog displayCtrl 4005;
_withdrawInput ctrlSetText "";
_lockerAmountLabel = _dialog displayCtrl 4000;
_lockerAmountLabel ctrlSetStructuredText (parseText format["<t size='1.4'>%1 / %2 <img image='\exile_assets\texture\ui\poptab_inline_ca.paa' size='1' shadow='true' /></t>", _lockerAmount, _lockerLimit]);
_inventoryAmount = player getVariable ["ExileMoney", 0];
_inventoryAmountString = _inventoryAmount call ExileClient_util_string_exponentToString;
_inventoryAmountLabel = _dialog displayCtrl 4001;
_inventoryAmountLabel ctrlSetStructuredText (parseText format["<t size='1.4'>%1 <img image='\exile_assets\texture\ui\poptab_inline_ca.paa' size='1' shadow='true' /></t>", _inventoryAmountString]);
true call ExileClient_gui_postProcessing_toggleDialogBackgroundBlur;
true

 

ExileClient_gui_lockerDialog_event_onDepositButtonClick.sqf

Spoiler

/**
 * ExileClient_gui_lockerDialog_event_onDepositButtonClick
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_display", "_amountInput", "_alphabet", "_forbiddenCharacter", "_playerMoney", "_depositAmount", "_lockerLimit", "_lockerAmount", "_newLockerAmount","_requiredRespect","_Respect","_Respect_multiplyer","_Respectlevels"];
disableSerialization;
_display = uiNameSpace getVariable ["RscExileLockerDialog", displayNull];
_amountInput = ctrlText (_display displayCtrl 4006);
try
{
	if((count _amountInput) isEqualTo 0) then 
	{
		throw "Please enter a deposit amount.";
	};
	_alphabet = getText (missionConfigFile >> "CfgLocker" >> "numbersOnly");
	_forbiddenCharacter = [_amountInput, _alphabet] call ExileClient_util_string_containsForbiddenCharacter;
	if !(_forbiddenCharacter isEqualTo -1) then 
	{
		throw "Please enter only numbers.";
	};
	_playerMoney = player getVariable ["ExileMoney",0];
	_depositAmount = ceil (abs (parseNumber _amountInput));
	if (_playerMoney < _depositAmount) then
	{
		throw "You cannot deposit more pop tabs than you have.";
	};
	// Old  code: _lockerLimit = (getNumber(missionConfigFile >> "CfgLocker" >> "maxDeposit"));
	//////////////////////////////////////
	//New locker code by Knatte_Anka
	//////////////////////////////////////
	_Respect_multiplyer = getNumber(missionConfigFile >> "CfgLocker" >> "Respect_multiplyer");
	_Respectlevels = Count (missionConfigFile >> "CfgTrading" >> "requiredRespect"	);
	for "_i" from 1 to _Respectlevels do
		{
			_requiredRespect = getNumber(missionConfigFile >> "CfgTrading" >> "requiredRespect" >> format["Level%1",_i]);
			if (_requiredRespect < ExileClientPlayerScore) then
			{
				_Respect = _i-1;
			};
		};
	
	_lockerLimit = round ((getNumber(missionConfigFile >> "CfgLocker" >> "maxDeposit"))	* (1+(_Respect_multiplyer*(_Respect))));

	//////////////////////////////////////
	_lockerAmount = player getVariable ["ExileLocker", 0];
	_newLockerAmount = _depositAmount + _lockerAmount;
	if (_lockerLimit < _newLockerAmount) then
	{
		throw format ["Your locker can only hold %1 pop tabs.", _lockerLimit];
	};
	["lockerDepositRequest", [_amountInput]] call ExileClient_system_network_send;
}
catch
{
	["ErrorTitleAndText", ["Failed to deposit!", _exception]] call ExileClient_gui_toaster_addTemplateToast;
};
true

 

ExileServer_system_locker_network_lockerDepositRequest.sqf

Spoiler

/**
 * ExileServer_system_locker_network_lockerDepositRequest
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_sessionID", "_parameters", "_deposit", "_player", "_depositAmount", "_playerMoney", "_lockerLimit", "_lockerAmount", "_newLockerAmount", "_newPlayerMoney","_Respect_multiplyer","_Respectlevels","_ExileClientPlayerScore","_requiredRespect","_Respect"];
_sessionID = _this select 0;
_parameters = _this select 1;
_deposit = _parameters select 0;
try
{
	_player = _sessionID call ExileServer_system_session_getPlayerObject;
	if (isNull _player) then
	{
		throw "Null player";
	};
	if !(alive _player) then
	{
		throw "Dead player";
	};
	_depositAmount = parseNumber _deposit;
	_playerMoney = _player getVariable ["ExileMoney",0];
	if (_playerMoney < _depositAmount) then
	{
		throw "Not enough pop tabs";
	};

	// Old  code: _lockerLimit = (getNumber(missionConfigFile >> "CfgLocker" >> "maxDeposit"));
	//////////////////////////////////////
	//New locker code by Knatte_Anka
	//////////////////////////////////////
	_Respect_multiplyer = getNumber(missionConfigFile >> "CfgLocker" >> "Respect_multiplyer");
	_Respectlevels = Count (missionConfigFile >> "CfgTrading" >> "requiredRespect"	);
	for "_i" from 1 to _Respectlevels do
		{
			_ExileClientPlayerScore = _player getVariable ["ExileScore", 0];
			_requiredRespect = getNumber(missionConfigFile >> "CfgTrading" >> "requiredRespect" >> format["Level%1",_i]);
			if (_requiredRespect < _ExileClientPlayerScore) then
			{
				_Respect = _i-1;
			};
		};
	
	_lockerLimit = round ((getNumber(missionConfigFile >> "CfgLocker" >> "maxDeposit"))	* (1+(_Respect_multiplyer*(_Respect))));

	//////////////////////////////////////
	_lockerAmount = _player getVariable ["ExileLocker", 0];
	_newLockerAmount = _depositAmount + _lockerAmount;
	if (_lockerLimit < _newLockerAmount) then
	{
		throw "Not enough space in locker";
	};
	_player setVariable ["ExileLocker", _newLockerAmount, true];
	format["updateLocker:%1:%2", _newLockerAmount, getPlayerUID _player] call ExileServer_system_database_query_fireAndForget;
	_newPlayerMoney = _playerMoney - _depositAmount;
	_player setVariable ["ExileMoney", _newPlayerMoney, true];
	format["setPlayerMoney:%1:%2", _newPlayerMoney, _player getVariable ["ExileDatabaseID", 0]] call ExileServer_system_database_query_fireAndForget;
	[_sessionID, "toastRequest", ["SuccessTitleOnly", ["Deposited!"]]] call ExileServer_system_network_send_to;
	[_sessionID, "lockerResponse", []] call ExileServer_system_network_send_to;
}
catch 
{
	_exception call ExileServer_util_log;
};
true

 

 

Known Bugs:

if adding money to locker the max locker value is reset to respect level1, but still works to add more money to the locker. Fixed with Github version

Edited by KnatteAnka
Github version fixed
2 people like this

Share this post


Link to post
Share on other sites
Advertisement

Used it some now and the last settings i use is

Spoiler

class CfgLocker
    {
        numbersOnly = "0123456789";
        maxDeposit = 40000;
		Respect_multiplyer =2;
    };
class requiredRespect 
	{
		Level1 = 0;
		Level2 = 5000;
		Level3 = 10000;
		Level4 = 20000;
		Level5 = 40000;
		Level6 = 80000;
		Level7 = 160000;
		Level8 = 300000;
		Level9 = 600000;
		Level10 = 1000000;
	};

 

This gives my players some goal to work for and you start with less but get in the end more but the good thing is that you can tweek the limits :D and the more levels you have the higher the limit go no limit how many levels for my script :D

Share this post


Link to post
Share on other sites

I've fixed your visual bug when depositing poptabs to the locker. Also I've cleaned up your code a bit and uploaded everything into my github: ExileDynamicLocker

ATM the script doesn't check if the players respect level has decreased. So if the level decreases the poptabs stay in the locker and you can still withdraw all poptabs but you can't add more. As I like this behaviour I won't change this, unless someone asks for it. ;)

1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

On ‎13‎/‎12‎/‎2017 at 9:25 PM, g0dsCookie said:

I've fixed your visual bug when depositing poptabs to the locker. Also I've cleaned up your code a bit and uploaded everything into my github: ExileDynamicLocker

ATM the script doesn't check if the players respect level has decreased. So if the level decreases the poptabs stay in the locker and you can still withdraw all poptabs but you can't add more. As I like this behaviour I won't change this, unless someone asks for it. ;)

Hope you don't mind @g0dsCookie I forked your GiThub so I could upload some changes, you can pull if you like - changes are:

Tidied up display of long numbers
Added my owned 100 levels including last huge one to prevent issues

Download: https://github.com/redned70/ExileDynamicLocker

Follow previous instructions as I just replaced 3 files and added a little extra on the respect levels as I found as soon as you go past the final limit the system breaks so made level 100 huge!

 

ned

 

forgot a pic (using my 100 respect levels)

20180106192526_1.jpg

Edited by red_ned
2 people like this

Share this post


Link to post
Share on other sites

Hello,

ive installed this on my server even though i have 300k respect the locker only shows i can put in 40K anyone else having this problem or know how i can fix this.

Thanks,

TwiistsGaming

Share this post


Link to post
Share on other sites
1 hour ago, =TZI= TWIIST said:

Hello,

ive installed this on my server even though i have 300k respect the locker only shows i can put in 40K anyone else having this problem or know how i can fix this.

Thanks,

TwiistsGaming

Never mind ive got it working now i had Respect_multiplyer = 2;  instead of just multiplyer = 2;

Share this post


Link to post
Share on other sites
1 hour ago, =TZI= TWIIST said:

Never mind ive got it working now i had Respect_multiplyer = 2;  instead of just multiplyer = 2;

remember to @ someone or quote someone so they get an alert to look at a thread, glad you fixed it though :)

Share this post


Link to post
Share on other sites
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

  • Recently Browsing   0 members

    No registered users viewing this page.