Jump to content
Sign in to follow this  
EagleByte

Add Action Parameters Issues

Recommended Posts

I have an info stand that has this in it's init line:

this allowDamage false; this addaction[("<t color=""#0074E8"">" + ("Spawn Resources") +"</t>"),"scripts\vehicleConfig.sqf","blu_spawn_1"];

"blu_spawn_1" is a marker that is about 5 meters away where I want the vehicle to spawn.

scripts\vehicleConfig.sqf:

_currentShop = _this select 3;
player setVariable ["currentSpawnPoint", _currentShop];

For some reason when the script runs it is giving me Zero Divisor errors which means I am trying to access a position in an array that doesn't exist...

Any ideas?

Share this post


Link to post
Share on other sites

It is very weird, because when I test it in the editor it gives me the right values, in the format I want. But when using this script on a multiplayer environment using this script. The error is taking place right before _this select 3;

Here is the code:

_currentStore = _this select 3;
player setVariable ["currentSpawnPoint", _currentStore, true];

createDialog "vehicleShop";

fnc_fetchVehInfo = {
private["_class","_scope","_picture","_displayName","_vehicleClass","_side","_faction","_superClass","_speed","_armor","_seats","_hp","_fuel"];
_class = [_this,0,"",[""]] call BIS_fnc_param;
if(_class == "") exitWith {[]}; //Bad class passed.
if(!isClass (configFile >> "CfgVehicles" >> _class)) exitWith {[]}; //Class doesn't exist in CfgVehicles

//Predefine some stuff.
_scope = -1;
_picture = "";
_displayName = "";
_vehicleClass = "";
_side = -1;
_faction = "";
_speed = 0;
_armor = 0;
_seats = 0;
_hp = 0;
_fuel = 0;

//Fetch
_scope = getNumber(configFile >> "CfgVehicles" >> _class >> "scope");
_picture = getText(configFile >> "CfgVehicles" >> _class >> "picture");
_displayName = getText(configFile >> "CfgVehicles" >> _class >> "displayName");
_vehicleClass = getText(configFile >> "CfgVehicles" >> _class >> "vehicleClass");
_side = getNumber(configFile >> "CfgVehicles" >> _class >> "side");
_faction = getText(configFile >> "CfgVehicles" >> _class >> "faction");
_superClass = configName(inheritsFrom (configFile >> "CfgVehicles" >> _class));
_speed = getNumber(configFile >> "CfgVehicles" >> _class >> "maxSpeed");
_armor = getNumber(configFile >> "CfgVehicles" >> _class >> "armor");
_seats = getNumber(configFile >> "CfgVehicles" >> _class >> "transportSoldier");
_hp = getNumber(configFile >> "CfgVehicles" >> _class >> "enginePower");
_fuel = getNumber(configFile >> "CfgVehicles" >> _class >> "fuelCapacity");

//Return
[_class,_scope,_picture,_displayName,_vehicleClass,_side,_faction,_superClass,_speed,_armor,_seats,_hp,_fuel];
};

//Fetch the shop config.
switch (side player) do {
case WEST: {
	vehicleList = 
	[
		["B_Heli_Light_01_F",50],						//Hummingbird
		["B_Heli_Light_01_armed_F",250],				//Pawnee
		["B_Heli_Attack_01_F",500],						//Blackfoot
		["B_Heli_Transport_01_F",150],					//Ghost Hawk
		["B_MBT_01_cannon_F",500],						//Slammer
		["B_APC_Wheeled_01_cannon_F",250],				//Marshall
		["B_MRAP_01_F",75],								//Hunter
		["B_MRAP_01_gmg_F",200],						//Hunter GMG
		["B_MRAP_01_hmg_F",150],						//Hunter HMG
		["B_G_Offroad_01_F",25],						//Offroad
		["B_G_Offroad_01_armed_F",75]					//Offroad Armed	
	];
};

case EAST: {
	vehicleList =
	[
		["B_Heli_Light_01_F",50],						//Hummingbird
		["O_Heli_Light_02_F",250],						//Orca Armed
		["O_Heli_Attack_02_F",500],						//Kajman
		["O_Heli_Light_02_unarmed_F",150],				//Orca
		["O_MBT_02_cannon_F",500],						//T-100
		["O_APC_Tracked_02_cannon_F",250],				//Kamysh
		["O_MRAP_02_F",75],								//Ifrit
		["O_MRAP_02_gmg_F",200],						//Ifrit GMG
		["O_MRAP_02_hmg_F",150],						//Ifrit HMG
		["O_G_Offroad_01_F",25],						//Offroad
		["O_G_Offroad_01_armed_F",75]					//Offroad Armed	
	];
};
};

disableSerialization;
_control = ((findDisplay 2300) displayCtrl 2302);
lbClear _control; //Flush the list.
ctrlShow [2330,false];
ctrlShow [2304,false];

//Loop through
{
_className = _x select 0;
_basePrice = _x select 1;

_vehicleInfo = [_className] call fnc_fetchVehInfo;
_control lbAdd (_vehicleInfo select 3);
_control lbSetPicture [(lbSize _control)-1,(_vehicleInfo select 2)];
_control lbSetData [(lbSize _control)-1,_className];
_control lbSetValue [(lbSize _control)-1,_ForEachIndex];
} foreach vehicleList;

---------- Post added at 15:56 ---------- Previous post was at 15:15 ----------

I have fixed the issue... Quite a dumb one too.

as the dialog loads it runs the vehicleConfig.sqf. So every time the dialog opens, it is trying to run those first couple lines, which should only be run once. So it makes a one dialogs every frame and is an infinite loop. I seperated the first couple lines into another file called openVehicleSpawn that handles the spawn of the dialog.

Guess that is what happens when you code from 8 am to 2 am and wake up at 7 am every morning...

A moderator can close or delete this topic.

Edited by FatPiggy

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×