Jump to content
Ibragim A

[SOLVED] The mod works when launched from the command line, but does not work after uploading on Steam.

Recommended Posts

The problem is as follows. I made a mod that works well if I put it to the root Arma folder and run it from the command line. But when I upload it on Steam and run it as a mod from Steam, it appears in the list of connected mods, but it does not work in the game.
Have any of you faced such a problem and have you managed to solve it? The mod is very primitive, it only runs one script.

PBO folder contains:

$PBOPREFIX$.txt

prefix=mymod

config.cpp

class CfgPatches
	{
		class Mymod
			{
				name = "Mymod";
				author = "Ibragim A";
				requiredVersion = 1.0;
				requiredAddons[] = {"A3_Data_F"};
				units[] = {};
				weapons[] = {};
			};
	};

class Extended_preInit_EventHandlers 
	{
		mission_preinit = "[] execVM '\Mymod\function.sqf';";
	};

function.sqf

PC_DETONATE_EXPL_TEXT 			= 		localize "STR_PC_detonate_expl_text";

PC_fn_check_if_trigger_is_remote = 
	{
		params ["_magazine"];
		
		private _is_remote = false;
		
		private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
		
		private _trigger = gettext (configFile >> "CfgAmmo" >> _ammo >> "mineTrigger");
		
		if (_trigger in ["RemoteTrigger"]) then 
			{
				_is_remote = true;
			};

		_is_remote;		
	};

PC_loop_player_set_demo = 
	{		
		while {true} do 
			{				
				waitUntil 
					{
						sleep 0.5;
						
						/// Проверка, не нужно ли удалить какое-нибудь действие (если ВУ взорвалось без участия игрока, напр.)
						
						if (count (missionNamespace getVariable ["PC_all_charges_and_action_ids", []]) > 0) then 
							{
									{
										if (!alive (_x select 0) ) then 
											{
												(_x select 2) removeAction (_x select 1);
											
												(missionNamespace getVariable ["PC_all_charges_and_action_ids", []]) deleteAt _forEachIndex;
											};
											
									} forEach (missionNamespace getVariable ["PC_all_charges_and_action_ids", []]);
							};
							
						/// Проверка, имеет ли игрок этот обработчик событий:
						
						if (player getVariable ["PC_player_have_charge_eh", false]) then 
							{
								false; /// Ждет, пока игрок поменяется
							} else 
								{
									player setVariable ["PC_player_have_charge_eh", true, true];
									
									true; /// Нарушает ожидание
								};
					};					
				
				/// Добавление обработчика использования оружия:

				player addEventHandler ["Fired", 
					{
						params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
						
						if !([_magazine] call PC_fn_check_if_trigger_is_remote) exitWith 
							{
								/// Это не взрывчатка с дистанционным детонатором
							};
						
						/// Это взрывчатка с дистанционным детонатором:
						
						player setVariable ["PC_player_demo_charges", ((player getVariable ["PC_player_demo_charges", []]) + [_projectile]), true];
						
						_n = count (player getVariable ["PC_player_demo_charges", []]);
						
						_surname = ((name player splitString "([ ]/:)") select 1);
						
						if (isNil "_surname") then 
							{
								_surname = ((name player splitString "([ ]/:)") select 0);
							};
						
						_mine = "";
						
						_mine_short_name = getText (configFile >> "CfgMagazines" >> _magazine >> "displayNameShort");
						
						if (_mine_short_name != "") then 
							{
								_mine = _mine_short_name;
							} else 
								{
									_mine = getText (configFile >> "CfgMagazines" >> _magazine >> "displayName");
								};
						
						_action_id = player addAction 
							[format [PC_DETONATE_EXPL_TEXT + " #%1 (%2, %3)", _n, _mine, _surname], 
								{
									params ["_target", "_caller", "_actionId", "_arguments"];
									
									if (mineActive (_arguments select 1)) then 
										{
											_target removeAction _actionId;
											(_arguments select 1) setDamage 1;
										} else 
											{
												/// Мина деактивирована
											};									
								}, 
								[_n-1, _projectile, _mine], 
								0,false,true,"",
								""]; 

						/// Вносим взрывчатку в массив со всеми поставленными взрывчатками:
				
						missionNamespace setVariable ["PC_all_charges_and_action_ids", (missionNamespace getVariable ["PC_all_charges_and_action_ids", []]) + [[_projectile, _action_id, _unit]], true];
						
					}];
			};
	};
	
[] spawn PC_loop_player_set_demo;

Stringtable.xml

<?xml version="1.0" encoding="utf-8" ?>
<Project name="PC">
	<Package name="PC_TOUCH_OFF">		

		<Container name="Text">
			<Key ID="STR_PC_detonate_expl_text">
				<Russian>Взорвать бомбу</Russian>
				<Original>Touch off bomb</Original>
			</Key>
			
			<Key ID="STR_onebyone_name">
				<Russian>Детонация ДВУ по одному</Russian>
				<Original>Detonation of RED One by One</Original>
			</Key>
			<Key ID="STR_onebyone_description">
				<Russian>Мод позволяет детонировать любые взрывные устройства с дистанционным детонатором по одному</Russian>
				<Original>This mod allows you to detonate any explosive devices with a remote detonator one at a time</Original>
			</Key>
		</Container>		
		
	</Package>
</Project>


@TouchOffByOne:
https://files.fm/u/ztazjp84y

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

×