Hallo,
ich lasse Serverseitig die Anzahl der Items beim Abbauen generieren.
Dies ist mein Code:
_sss = life_skillLevel remoteExecCall ["TON_fnc_snickers",RSERV];
SQL: fn_gather.sqf
#include "..\..\script_macros.hpp"
/*
File: fn_gather.sqf
Author: Bryan "Tonic" Boardwine
Description:
Main functionality for gathering.
*/
if(isNil "life_action_gathering") then {life_action_gathering = false;};
private["_gather","_itemWeight","_diff","_itemName","_resourceZones","_zone","_sum","_dice","_sss","_player"];
_resourceZones = ["apple_1","apple_2","apple_3","apple_4","peaches_1","peaches_2","peaches_3","peaches_4","heroin_1","cocaine_1","weed_1","trauben_1","hopfen_1","froesche_1","chemie_1","uran_1","muscheln_1","kartoffel_1","salat_1","zimt_1","pfeffer_1","paprika_1"];
_zone = "";
if(life_action_inUse) exitWith {}; //Action is in use, exit to prevent spamming.
life_action_inUse = true;
//Find out what zone we're near
{
if(player distance (getMarkerPos _x) < 30) exitWith {_zone = _x;};
} foreach _resourceZones;
if(EQUAL(_zone,"")) exitWith {life_action_inUse = false;};
//Get the resource that will be gathered from the zone name...
switch(true) do {
case (_zone in ["apple_1","apple_2","apple_3","apple_4"]): {_gather = ["apple",1];};
case (_zone in ["peaches_1","peaches_2","peaches_3","peaches_4"]): {_gather = ["peach",1];};
case (_zone in ["heroin_1"]): {_gather = ["heroin_unprocessed",1];};
case (_zone in ["cocaine_1"]): {_gather = ["cocaine_unprocessed",1];};
case (_zone in ["weed_1"]): {_gather = ["cannabis",1];};
case (_zone in ["trauben_1"]): {_gather = ["trauben",1];};
case (_zone in ["uran_1"]): {_gather = ["uranium1",1];};
case (_zone in ["hopfen_1"]): {_gather = ["hopfen",1];};
case (_zone in ["froesche_1"]): {_gather = ["froesche",1];};
case (_zone in ["chemie_1"]): {_gather = ["chemie",1];};
case (_zone in ["gummi_1"]): {_gather = ["gummi",1];};
case (_zone in ["muschel_1"]): {_gather = ["muscheln",1];};
case (_zone in ["kartoffel_1"]): {_gather = ["kartoffels",1];};
case (_zone in ["salat_1"]): {_gather = ["kopfsalat",1];};
case (_zone in ["zimt_1"]): {_gather = ["zimtstange",1];};
case (_zone in ["pfeffer_1"]): {_gather = ["pfefferkorn",1];};
case (_zone in ["paprika_1"]): {_gather = ["paprika1",1];};
default {""};
};
//gather check??
if(vehicle player != player) exitWith {};
_sss = life_skillLevel remoteExecCall ["TON_fnc_snickers",RSERV];
_diff = [SEL(_gather,0),_sss,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff;
if(EQUAL(_diff,0)) exitWith {hint localize "STR_NOTF_InvFull"};
life_action_inUse = true;
for "_i" from 0 to 2 do {
player playMove "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";
waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";};
sleep 2.5;
};
if(([true,SEL(_gather,0),_diff] call life_fnc_handleInv)) then {
_itemName = M_CONFIG(getText,"VirtualItems",SEL(_gather,0),"displayName");
titleText[format[localize "STR_NOTF_Gather_Success",(localize _itemName),_diff],"PLAIN"];
};
_sender = player;
[steamid,life_skillLevel,life_skillExp,10,_sender] remoteExecCall ["TON_fnc_addExp",RSERV];
[format["<t color='#33cc33' size = '.8'>XP verdient...<br /></t><t size='.8'>%1/%2 XP</t>",life_skillExp,life_skillExpLeft],1,-1,4,1,0,789] spawn BIS_fnc_dynamicText;
life_action_inUse = false;
Alles anzeigen
Leider bekomme ich folgenden Error:
Code
16:33:02 Error in expression <Weight] call life_fnc_calWeightDiff;
if(_diff isEqualTo 0) exitWith {hint locali>
16:33:02 Error position: <_diff isEqualTo 0) exitWith {hint locali>
16:33:02 Error Nicht definierte Variable in Ausdruck: _diff
16:33:02 File mpmissions\__CUR_MP.Altis\core\actions\fn_gather.sqf, line 49
16:33:09 Error in expression <p 2.5;
};
if(([true,(_gather select 0),_diff] call life_fnc_handleInv)) then {
>
16:33:09 Error position: <_diff] call life_fnc_handleInv)) then {
>
16:33:09 Error Nicht definierte Variable in Ausdruck: _diff
16:33:09 File mpmissions\__CUR_MP.Altis\core\actions\fn_gather.sqf, line 58
Alles anzeigen
In der CfgRemoteExec natürlich eingetragen, life_skillLevel = 1; und das ist der serverseitige Code:
SQL
private ["_level","_tosend"];
_level = _this select 0;
/*
Mit einem Switch wird je nach _level die _tosend bestimmt. _tosend wird mit einem "selectRandom [1,2,3,4]" definiert. Kann man das auch anders machen? Aber egal erstmal...
*/
_tosend;
Leider bin ich mir nicht sicher wieso das alles nicht funktioniert. Serverseitige RPT:
Code
2016/11/04, 16:33:02 Error in expression <e ["_level","_tosend"];
_level = _this select 0;
switch _level do {
default {_>
2016/11/04, 16:33:02 Error position: <select 0;
switch _level do {
default {_>
2016/11/04, 16:33:02 Error Generic error in expression
2016/11/04, 16:33:02 File life_server\Functions\Skillsystem\fn_snickers.sqf, line 3
Alles anzeigen