Jump to content

Ajouter la bourse !


Recommended Posts

Bonjour à tous, aujourd'hui je vais traduire un tutoriel pour ajouter la bourse, source : altisliferpg.com

1 - Allez dans votre functions.h et ajouter ceci à la fin :

class Market{	file = "core\market";	class openMarketView;	class refreshMarketView;	class marketShortView;	class marketBuy;	class marketSell;	class marketGetBuyPrice;	class marketGetSellPrice;	class marketconfiguration;	class marketReset;	class marketChange;	class marketGetRow;	class marketGetPriceRow;	class marketSetPriceRow;};

Dans le fichier functions.h à nouveau, ajouter ceci en dessous de la class functions :

class Functions{	file = "core\functions";				class randomRound {}; // <--------- add this};

2 - Allez dans le dossier Dialog et copier les 2 fichiers disponibles dans le .zip et ouvrer votre MasterHandler.h et ajouter ceci :

#include "common_EditorWrapper.hpp"#include "market.hpp"

3 - Ouvrez votre fn_virt_sell.sqf dans core/shops

Ajoutez à private ceci ["_marketprice"];
Comme ceci :

private["_type","_index","_price","_var","_amount","_name","_marketprice"];

Maintenant trouver cette ligne :

_price = (__GETC__(sell_array) select _index) select 1;_var = [_type,0] call life_fnc_varHandle;

Ajoutez ceci en dessous :

_marketprice = [_type] call life_fnc_marketGetSellPrice;if(_marketprice != -1) then{	_price = _marketprice;};

Trouvez cette ligne :

life_cash = life_cash + _price;

Ajoutez ceci en dessous :

if(_marketprice != -1) then { 	[_type, _amount] spawn	{		sleep 120;		[_this select 0,_this select 1] call life_fnc_marketSell;	};};

4- Fermer le fichier et ouvrer le fichier fn_virt_update.sqf dans le même dossier

Ajoutez à private ceci ["_marketprice"];
Comme ceci :

private["_type","_index","_price","_var","_amount","_name","_marketprice"];

Maintenant trouvez cette ligne :

_price = (__GETC__(buy_array) select _index) select 1;

Ajoutez ceci en dessous:

marketprice = [_x] call life_fnc_marketGetBuyPrice;if(_marketprice != -1) then{	_price = _marketprice;};

A la fin du fichier ajoutez ceci :

//Call short view here[_shop_data select 1] spawn life_fnc_marketShortView;

Comme ceci :

if(_val > 0) then	{		_gear_list lbAdd format["%1x %2",_val,_name];		_gear_list lbSetData [(lbSize _gear_list)-1,_x];	};} foreach (_shop_data select 1); //Call short view here // this its the new line to add[_shop_data select 1] spawn life_fnc_marketShortView; // this its the new line to add

5 - Fermer le fichier et ouvrez fn_virt_buy.sqf aussi dans le même dossier

Ajoutez à private ceci :

"_marketprice"

Comme ceci :

private["_type","_price","_amount","_diff","_name","_hideout","_marketprice"];

Trouvez cette ligne :

_amount = ctrlText 2404;

Ajoutez ceci en dessous:

_marketprice = [_type] call life_fnc_marketGetBuyPrice;if(_marketprice != -1) then{	_price = _marketprice;};

Trouvez cette ligne :

__SUB__(life_cash,(_price * _amount));

Ajoutez ceci en dessous:

if(_marketprice != -1) then { 	//##94	[_type, _amount] spawn	{		sleep 120;		[_this select 0,_this select 1] call life_fnc_marketBuy;	};			};

6 - Ouvrer le fichier dialog\player_inv.hpp

En dessous de ceci :

class ButtonSyncData : life_RscButtonMenu {	idc = -1;	//shortcuts[] = {0x00050000 + 2};	text = "$STR_PM_SyncData";	onButtonClick = "[] call SOCK_fnc_syncData;";	x = 0.1;	y = 0.805;	w = (6.25 / 40);	h = (1 / 25);};

Ajoutez ceci :

class ButtonMarket : Life_RscButtonMenu {	idc = -1;	text = "Bourse";	onButtonClick = "[] spawn life_fnc_openMarketView;";	//x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));	x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));	y = 0.805;	w = (6.25 / 40);	h = (1 / 25);};

Ouvrez le fichier init.sqf dans VOTRENOMDEMISSION\init.sqf et en dessous de :

[] execVM "briefing.sqf"; //Load Briefing[] execVM "KRON_Strings.sqf";

Ajoutez ça :

if(isDedicated && isNil("life_market_prices")) then{[] call life_fnc_marketconfiguration;diag_log "Market prices generated!"; "life_market_prices" addPublicVariableEventHandler{diag_log format["Market prices updated! %1", _this select 1];}; //Start server fsm[] execFSM "core\fsm\server.fsm";diag_log "Server FSM executed";};

Et pour la dernière étape allez dans core\fsm and déplacer le fichier server.fsm dispo dans le .zip

Désormais vous avez votre système de bourse, enjoy :)

Pour le kick par BattlEye, il suffit d'ajouter ces lignes dans Battleye\publicvariable.txt :

1 "" !="life_HC_isActive" !="HC_UID"7 "" !="life_market_shortnames" !="life_fnc_MP_packet" !="BIS_fnc_MP_packet" !="JipTimeNow" !="life_HC_isActive" !="HC_UID" !="life_gang_list" !="bank_addfunds" !="life_market_prices" !="IL_SetMass" !="IL_SetScore" !="IL_SetDir" !="life_market_resources" !="bis_fnc_execvm" !="Life_fnc_execvm"

Maintenant pour la version 3.1.4.6+ changez le fichier fn_virt_sell.sqf danscore/shops remplacez le par ceci :

#include <macro.h>/*    File: fn_virt_sell.sqf    Author: Bryan "Tonic" Boardwine        Description:    Sell a virtual item to the store / shop*/ private["_type","_index","_price","_var","_amount","_name","_marketprice"];if((lbCurSel 2402) == -1) exitWith {};_type = lbData[2402,(lbCurSel 2402)];_index = [_type,__GETC__(sell_array)] call fnc_index;if(_index == -1) exitWith {};_price = (__GETC__(sell_array) select _index) select 1;_var = [_type,0] call life_fnc_varHandle;_marketprice = [_type] call life_fnc_marketGetSellPrice;if(_marketprice != -1) then{    _price = _marketprice;}; _amount = ctrlText 2405;if(!([_amount] call fnc_isnumber)) exitWith {hint localize "STR_Shop_Virt_NoNum";};_amount = parseNumber (_amount);if(_amount > (missionNameSpace getVariable _var)) exitWith {hint localize "STR_Shop_Virt_NotEnough"}; _price = (_price * _amount);_name = [_var] call life_fnc_vartostr;if(([false,_type,_amount] call life_fnc_handleInv)) then{    hint format[localize "STR_Shop_Virt_SellItem",_amount,_name,[_price] call life_fnc_numberText];    life_cash = life_cash + _price;    if(_marketprice != -1) then        {            [_type, _amount] spawn            {                sleep 120;                [_this select 0,_this select 1] call life_fnc_marketSell;            };    };    [] call life_fnc_virt_update;	}; if(life_shop_type == "heroin") then{    private["_array","_ind","_val"];    _array = life_shop_npc getVariable["sellers",[]];    _ind = [getPlayerUID player,_array] call fnc_index;    if(_ind != -1) then    {        _val = (_array select _ind) select 2;        _val = _val + _price;        _array set[_ind,[getPlayerUID player,profileName,_val]];        life_shop_npc setVariable["sellers",_array,true];    }        else    {        _array set[count _array,[getPlayerUID player,profileName,_price]];        life_shop_npc setVariable["sellers",_array,true];    };};

Merci à : Linxy pour son aide

Touts les fichiers nécessaire (.zip) : https://mega.co.nz/#!fZFQjJbB!OGIlZTYFW-ZT-czIiOE8k6GPBFa056TcJTR8u9T6jS8


Patch 3.1.4.8: Copiez les fichiers suivant spécifiques :

fn.Virt_sell.sqf

#include <macro.h>/*	File: fn_virt_sell.sqf	Author: Bryan "Tonic" Boardwine		Description:	Sell a virtual item to the store / shop*/private["_type","_index","_price","_var","_amount","_name","_marketprice"];if((lbCurSel 2402) == -1) exitWith {};_type = lbData[2402,(lbCurSel 2402)];_index = [_type,__GETC__(sell_array)] call TON_fnc_index;if(_index == -1) exitWith {};_price = (__GETC__(sell_array) select _index) select 1;_var = [_type,0] call life_fnc_varHandle;////Marktsystem Anfang////_marketprice = [_type] call life_fnc_marketGetSellPrice;if(_marketprice != -1) then{	_price = _marketprice;};////Marktsystem Ende//// _amount = ctrlText 2405;if(!([_amount] call fnc_isnumber)) exitWith {hint "You didn't enter an actual number";};_amount = parseNumber (_amount);if(_amount > (missionNameSpace getVariable _var)) exitWith {hint "You don't have that many items to sell!"}; _price = (_price * _amount);_name = [_var] call life_fnc_vartostr;if(([false,_type,_amount] call life_fnc_handleInv)) then{	hint format["You sold %1 %2 for $%3",_amount,_name,[_price] call life_fnc_numberText];	life_cash = life_cash + _price;	////Marktsystem Anfang////	if(_marketprice != -1) then 	{ 		[_type, _amount] spawn		{			sleep 120;			[_this select 0,_this select 1] call life_fnc_marketSell;		};	////Marktsystem Ende////	};	[] call life_fnc_virt_update;	}; if(life_shop_type == "heroin") then{	private["_array","_ind","_val"];	_array = life_shop_npc getVariable["sellers",[]];	_ind = [getPlayerUID player,_array] call TON_fnc_index;	if(_ind != -1) then	{		_val = (_array select _ind) select 2;		_val = _val + _price;		_array set[_ind,[getPlayerUID player,profileName,_val]];		life_shop_npc setVariable["sellers",_array,true];	}		else	{		_array pushBack _array,[getPlayerUID player,profileName,_price]];		life_shop_npc setVariable["sellers",_array,true];	};};

fn.virt_update.sqf

#include <macro.h>/*	File: fn_virt_update.sqf	Author: Bryan "Tonic" Boardwine		Description:	Update and fill the virtual shop menu.*/private["_display","_item_list","_gear_list","_shop_data","_name","_price","_marketprice"];disableSerialization; //Setup control vars._display = findDisplay 2400;_item_list = _display displayCtrl 2401;_gear_list = _display displayCtrl 2402; //Purge listlbClear _item_list;lbClear _gear_list; _shop_data = [life_shop_type] call life_fnc_virt_shops;ctrlSetText[2403,format["%1", _shop_data select 0]]; {	_name = [([_x,0] call life_fnc_varHandle)] call life_fnc_vartostr;	_index = [_x,__GETC__(buy_array)] call TON_fnc_index;	if(_index != -1) then	{		_price = (__GETC__(buy_array) select _index) select 1;		////Marktsystem Anfang////		_marketprice = [_x] call life_fnc_marketGetBuyPrice;		if(_marketprice != -1) then		{			_price = _marketprice;		};		////Marktsystem Ende////		_item_list lbAdd format["%1  ($%2)",_name,[_price] call life_fnc_numberText];		_item_list lbSetData [(lbSize _item_list)-1,_x];		_item_list lbSetValue [(lbSize _item_list)-1,_price];	};} foreach (_shop_data select 1); {	_var = [_x,0] call life_fnc_varHandle;	_val = missionNameSpace getVariable _var;	_name = [_var] call life_fnc_vartostr;		if(_val > 0) then	{		_gear_list lbAdd format["%1x %2",_val,_name];		_gear_list lbSetData [(lbSize _gear_list)-1,_x];	};} foreach (_shop_data select 1); //Call short view here[_shop_data select 1] spawn life_fnc_marketShortView;

And a little exemple for fix the xxxxxx in the market:

["apple", 100, 50, 150, 4, 2,		[			["peach",1] <------- no coma 		]	],  and for long line["cement", 2250, 250, 4250, 4, 2,		[ 			["diamondc",1], <------- coma			["oilp",1],  <------- coma			["iron_r",1],  <------- coma			["copper_r",1],  <------- coma			["salt_r",1],  <------- coma			["glass",1] <------- no coma		] 	],  Last items in your configurationmarket ["heroinp", 7000, 3000, 10000, 4, 4,   		[ 			["marijuana",1],   <------- coma			["turtle",1],  <------- coma			["cocainep",1] <------- no coma		] 	]  <------- no coma

Crédit : _Fuzz pour le tutoriel sur altisliferpg.com et EdgeKiller pour la traduction !

Edited by edgekiller
Link to post
Share on other sites
  • 10 months later...
  • 3 months later...
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...