Hey Leute,
ich brauche eure Hilfe, ich schreibe zur Zeit das Persistent Proficiency System um. Leider komme ich bei der fn_gather.sqf und bei der Fn_processaction.sqf nicht weiter airborne .
Hier sind mal meine 2 SQFs (die Source Codes stehen bei beiden dateien ganz unten):
Code: fn_processaction.sqf
#include "..\..\script_macros.hpp"
/*
File: fn_processAction.sqf
Author: Bryan "Tonic" Boardwine
Modified : NiiRoZz
Description:
Master handling for processing an item.
NiiRoZz : Added multiprocess
*/
private["_vendor","_type","_itemInfo","_oldItem","_newItemWeight","_newItem","_oldItemWeight","_cost","_upp","_hasLicense","_itemName","_oldVal","_ui","_progress","_pgText","_cP","_materialsRequired","_materialsGiven","_noLicenseCost","_text","_filter","_totalConversions","_minimumConversions"];
_vendor = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_type = [_this,3,"",[""]] call BIS_fnc_param;
//Error check
if (isNull _vendor || _type isEqualTo "" || (player distance _vendor > 10)) exitWith {};
life_action_inUse = true;//Lock out other actions during processing.
if (isClass (missionConfigFile >> "ProcessAction" >> _type)) then {
_filter = false;
_materialsRequired = M_CONFIG(getArray,"ProcessAction",_type,"MaterialsReq");
_materialsGiven = M_CONFIG(getArray,"ProcessAction",_type,"MaterialsGive");
_noLicenseCost = M_CONFIG(getNumber,"ProcessAction",_type,"NoLicenseCost");
_text = M_CONFIG(getText,"ProcessAction",_type,"Text");
} else {_filter = true;};
if (_filter) exitWith {life_action_inUse = false;};
_itemInfo = [_materialsRequired,_materialsGiven,_noLicenseCost,(localize format["%1",_text])];
if (count _itemInfo isEqualTo 0) exitWith {life_action_inUse = false;};
//Setup vars.
_oldItem = _itemInfo select 0;
_newItem = _itemInfo select 1;
_cost = _itemInfo select 2;
_upp = _itemInfo select 3;
_exit = false;
if (count _oldItem isEqualTo 0) exitWith {life_action_inUse = false;};
_totalConversions = [];
{
_var = ITEM_VALUE(_x select 0);
if (_var isEqualTo 0) exitWith {_exit = true;};
if (_var < (_x select 1)) exitWith {_exit = true;};
_totalConversions pushBack (floor (_var/(_x select 1)));
} forEach _oldItem;
if (_exit) exitWith {life_is_processing = false; hint localize "STR_NOTF_NotEnoughItemProcess"; life_action_inUse = false;};
if (_vendor in [mari_processor,coke_processor,heroin_processor]) then {
_hasLicense = true;
} else {
_hasLicense = LICENSE_VALUE(_type,"civ");
};
_cost = _cost * (count _oldItem);
_minimumConversions = _totalConversions call BIS_fnc_lowestNum;
_oldItemWeight = 0;
{
_weight = ([_x select 0] call life_fnc_itemWeight) * (_x select 1);
_oldItemWeight = _oldItemWeight + _weight;
} count _oldItem;
_newItemWeight = 0;
{
_weight = ([_x select 0] call life_fnc_itemWeight) * (_x select 1);
_newItemWeight = _newItemWeight + _weight;
} count _newItem;
_exit = false;
if (_newItemWeight > _oldItemWeight) then {
_netChange = _newItemWeight - _oldItemWeight;
_freeSpace = life_maxWeight - life_carryWeight;
if (_freeSpace < _netChange) exitWith {_exit = true;};
_minimumConversions = floor(_freeSpace / _netChange);
};
if (_exit) exitWith {hint localize "STR_Process_Weight"; life_is_processing = false; life_action_inUse = false;};
//Setup our progress bar.
disableSerialization;
5 cutRsc ["life_progress","PLAIN"];
_ui = uiNamespace getVariable "life_progress";
_progress = _ui displayCtrl 38201;
_pgText = _ui displayCtrl 38202;
_pgText ctrlSetText format["%2 (1%1)...","%",_upp];
_progress progressSetPosition 0.01;
_cP = 0.01;
life_is_processing = true;
if (_hasLicense) then {
for "_i" from 0 to 1 step 0 do {
sleep 0.28;
_cP = _cP + 0.01;
_profName = [_type] call life_fnc_profType;
_data = missionNamespace getVariable "_profName";
_progress progressSetPosition _cP;
_pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if (_cP >= 1) exitWith {};
if (player distance _vendor > 10) exitWith {};
};
if (player distance _vendor > 10) exitWith {hint localize "STR_Process_Stay"; 5 cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};
{
[false,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _oldItem;
{
[true,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _newItem;
5 cutText ["","PLAIN"];
if (_minimumConversions isEqualTo (_totalConversions call BIS_fnc_lowestNum)) then {hint localize "STR_NOTF_ItemProcess";} else {hint localize "STR_Process_Partial";};
life_is_processing = false; life_action_inUse = false;
} else {
if (CASH < _cost) exitWith {hint format[localize "STR_Process_License",[_cost] call life_fnc_numberText]; 5 cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};
if( _profName != "" ) then
{
switch ( _data select 0) do
{
case 1: { _time = 0.9; _cpUp = 0.01; };
case 2: { _time = 0.8; _cpUp = 0.01; };
case 3: { _time = 0.7; _cpUp = 0.01; };
case 4: { _time = 0.6; _cpUp = 0.01; };
case 5: { _time = 0.5; _cpUp = 0.01; };
case 6: { _time = 0.4; _cpUp = 0.01; };
case 7: { _time = 0.3; _cpUp = 0.01; };
case 8: { _time = 0.2; _cpUp = 0.01; };
case 9: { _time = 0.2; _cpUp = 0.02; };
case 10: { _time = 0.2; _cpUp = 0.03; };
};
};
while{true} do
{
for "_i" from 0 to 1 step 0 do {
sleep 0.9;
_cP = _cP + 0.01;
_progress progressSetPosition _cP;
_pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if (_cP >= 1) exitWith {};
if (player distance _vendor > 10) exitWith {};
};
if (player distance _vendor > 10) exitWith {hint localize "STR_Process_Stay"; 5 cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};
if (CASH < _cost) exitWith {hint format[localize "STR_Process_License",[_cost] call life_fnc_numberText]; 5 cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};
{
[false,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _oldItem;
{
[true,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _newItem;
5 cutText ["","PLAIN"];
if (_minimumConversions isEqualTo (_totalConversions call BIS_fnc_lowestNum)) then {hint localize "STR_NOTF_ItemProcess";} else {hint localize "STR_Process_Partial";};
CASH = CASH - _cost;
if( _profName != "" ) then
{
[_profName,40] call life_fnc_addExp;
};
[0] call SOCK_fnc_updatePartial;
life_is_processing = false;
life_action_inUse = false;
};
[] call life_fnc_hudUpdate;
/*
///////////////////////
Source code
//////////////////////
if(_hasLicense) then
{
_time = 0.3;
_cpUp = 0.01;
_profName = [_type] call life_fnc_profType;
_data = missionNamespace getVariable "_profName";
if( _profName != "" ) then
{
switch ( _data select 0 ) do
{
case 1: { _time = 0.4; _cpUp = 0.01; };
case 2: { _time = 0.35; _cpUp = 0.01; };
case 3: { _time = 0.3; _cpUp = 0.01; };
case 4: { _time = 0.25; _cpUp = 0.01; };
case 5: { _time = 0.2; _cpUp = 0.01; };
case 6: { _time = 0.2; _cpUp = 0.02; };
case 7: { _time = 0.2; _cpUp = 0.03; };
case 8: { _time = 0.2; _cpUp = 0.04; };
case 9: { _time = 0.15; _cpUp = 0.05; };
case 10: { _time = 0.1; _cpUp = 0.07; };
};
};
while{true} do
{
sleep _time;
_cP = _cP + _cpUp;
_progress progressSetPosition _cP;
_pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if(_cP >= 1) exitWith {};
if(player distance _vendor > 10) exitWith {};
};
if(player distance _vendor > 10) exitWith {hint localize "STR_Process_Stay"; 5 cutText ["","PLAIN"]; life_is_processing = false;};
if(!([false,_oldItem,_oldVal] call life_fnc_handleInv)) exitWith {5 cutText ["","PLAIN"]; life_is_processing = false;};
if(!([true,_newItem,_oldVal] call life_fnc_handleInv)) exitWith {5 cutText ["","PLAIN"]; [true,_oldItem,_oldVal] call life_fnc_handleInv; life_is_processing = false;};
5 cutText ["","PLAIN"];
titleText[format[localize "STR_Process_Processed",_oldVal,_itemName],"PLAIN"];
if( _profName != "" ) then
{
[_profName,40] call life_fnc_addExp;
};
life_is_processing = false;
}
else
{
if(life_cash < _cost) exitWith {hint format[localize "STR_Process_License",[_cost] call life_fnc_numberText]; 5 cutText ["","PLAIN"]; life_is_processing = false;};
_time = 0.9;
_cpUp = 0.01;
_profName = [_type] call life_fnc_profType;
_data = missionNamespace getVariable "_profName";
if( _profName != "" ) then
{
switch ( _data select 0) do
{
case 1: { _time = 0.9; _cpUp = 0.01; };
case 2: { _time = 0.8; _cpUp = 0.01; };
case 3: { _time = 0.7; _cpUp = 0.01; };
case 4: { _time = 0.6; _cpUp = 0.01; };
case 5: { _time = 0.5; _cpUp = 0.01; };
case 6: { _time = 0.4; _cpUp = 0.01; };
case 7: { _time = 0.3; _cpUp = 0.01; };
case 8: { _time = 0.2; _cpUp = 0.01; };
case 9: { _time = 0.2; _cpUp = 0.02; };
case 10: { _time = 0.2; _cpUp = 0.03; };
};
};
while{true} do
{
sleep _time;
_cP = _cP + _cpUp;
_progress progressSetPosition _cP;
_pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if(_cP >= 1) exitWith {};
if(player distance _vendor > 10) exitWith {};
};
if(player distance _vendor > 10) exitWith {hint localize "STR_Process_Stay"; 5 cutText ["","PLAIN"]; life_is_processing = false;};
if(life_cash < _cost) exitWith {hint format[localize "STR_Process_License",[_cost] call life_fnc_numberText]; 5 cutText ["","PLAIN"]; life_is_processing = false;};
if(!([false,_oldItem,_oldVal] call life_fnc_handleInv)) exitWith {5 cutText ["","PLAIN"]; life_is_processing = false;};
if(!([true,_newItem,_oldVal] call life_fnc_handleInv)) exitWith {5 cutText ["","PLAIN"]; [true,_oldItem,_oldVal] call life_fnc_handleInv; life_is_processing = false;};
5 cutText ["","PLAIN"];
titleText[format[localize "STR_Process_Processed2",_oldVal,_itemName,[_cost] call life_fnc_numberText],"PLAIN"];
life_cash = life_cash - _cost;
if( _profName != "" ) then
{
[_profName,40] call life_fnc_addExp;
};
life_is_processing = false;
};
*/
Alles anzeigen
Code: fn_gather.sqf
#include "..\..\script_macros.hpp"
/*
File: fn_gather.sqf
Author: Devilfloh
Description:
Main functionality for gathering.
*/
private["_maxGather","_resource","_amount","_maxGather","_requiredItem"];
if (life_action_inUse) exitWith {};
while {true} do {
if ((vehicle player) != player) exitWith {};
if (life_interrupted) exitWith {life_interrupted = false;};
if (player getVariable "restrained") exitWith {hint localize "STR_NOTF_isrestrained";};
if (player getVariable "playerSurrender") exitWith {hint localize "STR_NOTF_surrender";};
life_action_inUse = true;
_zone = "";
_requiredItem = "";
_time = 0;
_profName = [_gather] call life_fnc_profType;
_zoneSize = (getNumber(missionConfigFile >> "CfgGather" >> "zoneSize"));
_exit = false;
_resourceCfg = missionConfigFile >> "CfgGather" >> "Resources";
if( _profName != "" ) then
{
_data = missionNamespace getVariable (_profName);
_time = ( 3 - (0.25 * (_data select 0)));
};
for "_i" from 0 to count(_resourceCfg)-1 do {
_curConfig = _resourceCfg select _i;
_resource = configName _curConfig;
_maxGather = getNumber(_curConfig >> "amount");
_resourceZones = getArray(_curConfig >> "zones");
_requiredItem = getText(_curConfig >> "item");
{
if ((player distance (getMarkerPos _x)) < _zoneSize) exitWith {_zone = _x;};
} forEach _resourceZones;
if (_zone != "") exitWith {};
};
if (_zone isEqualTo "") exitWith {life_action_inUse = false;};
if (_requiredItem != "") then {
_valItem = missionNamespace getVariable "life_inv_" + _requiredItem;
if (_valItem < 1) exitWith {
switch (_requiredItem) do {
//Messages here
};
life_action_inUse = false;
_exit = true;
};
};
if (_exit) exitWith {life_action_inUse = false;};
_amount = round(random(_maxGather)) + 1;
_diff = [_resource,_amount,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff;
if (_diff isEqualTo 0) exitWith {
hint localize "STR_NOTF_InvFull";
life_action_inUse = false;
};
switch (_requiredItem) do {
case "pickaxe": {player say3D "mining";};
default {player say3D "harvest";};
};
for "_i" from 0 to 4 do {
player playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";
waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";};
sleep 0.5;
};
if ([true,_resource,_diff] call life_fnc_handleInv) then {
_itemName = M_CONFIG(getText,"VirtualItems",_resource,"displayName");
titleText[format[localize "STR_NOTF_Gather_Success",(localize _itemName),_diff],"PLAIN"];
if( _profName != "" ) then
{
[_profName,25] call life_fnc_addExp;
};
};
[] call life_fnc_hudUpdate;
sleep 1;
};
life_action_inUse = false;
/*
replace from life_action_inuse = true down
life_action_inUse = true;
_time = 0;
_profName = [_gather] call life_fnc_profType;
if( _profName != "" ) then
{
_data = missionNamespace getVariable (_profName);
_time = ( 3 - (0.25 * (_data select 0)));
};
for "_i" from 0 to 2 do
{
player playMove "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";
waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";};
sleep _time;
};
if(([true,_gather,_diff] call life_fnc_handleInv)) then
{
_itemName = [([_gather,0] call life_fnc_varHandle)] call life_fnc_varToStr;
titleText[format[localize "STR_NOTF_Gather_Success",_itemName,_diff],"PLAIN"];
if( _profName != "" ) then
{
[_profName,25] call life_fnc_addExp;
};
};
life_action_inUse = false;
/*
Alles anzeigen
Ich hoffe jemand kann mir weiterhelfen . Wenn diese 2 SQFs funktionieren könnte ich ein TUT für die 4.4 R3 machen.
Mfg
AmaZiinG