Jump to content
Sign in to follow this  
drunken officer

starting a script by user action command

Recommended Posts

Hello.

I want to start a script, if the player actived the action. I tested with the "class EventHandler" and the script was running. But if i try to start the script by user action, nothing happends.

In my script i wrote

_cam = _this select 0;
_LTI = _cam animationPhase ""LTI"";
waitUntil {_LTI == 1};
while {true} do
{player sideChat format ["speedgun: %1, LTI: %2", _cam, _LTI];};

%1 = return my camera >> ok

%2 = return my animationPhase >> ok

Here is my config code. It's doesnt matter, is the object a thing or building. Both times same effect.

I tryed more settings. With statement = [_this select 0] ....., the script starting, but %1 call "any" because it's setting "select 0;" in the config.cpp

class speedgun : Base_Object	

	{

	scope = 2;
	class Library {libTextDesc = "A speedcheck camera, based on laser technologie" };
	model="\speedcamera\speedgun.p3d";
	picture="\speedcamera\picture_icon_ca.paa";
	displayName = "Speedgun";
	magazines[] = {};
	/*class EventHandlers
         { init = "_this execVM ""\speedcamera\scripts\speedgun.sqf""; ";   };*/
	 class AnimationSources 
                    {

		class LTI
		{
			source = "user";
			scope = 2;
			animPeriod = 0.2; 
			initPhase = 0; 
		}; 
	};
		class UserActions
               {
		class LTION
		{
		scope = 2;
		displayName="LTI ON";
		onlyforplayer = true;
		position="apLTI";
		radius=5; 
		condition="this animationPhase ""LTI"" == 0 ";
		//statement="this animate [""LTI"", 1] ";
		//statement="handel = [_this select 0] execVM ""\speedcamera\scripts\speedgun.sqf""; ";
			statement="this execVM ""\speedcamera\scripts\speedgun.sqf""; "; 
                    };
            };

Can anybody help my, to start a simple script by user action?

And how can i start a script by a weapon? Becaue the speedgun is normaly a "pistol". EventHandlers classes DONT work by cfgweapons. :(

Edited by Drunken Officer

Share this post


Link to post
Share on other sites

thx for the web site.

I'm a little bit confused.

I found a post, there are a EventHandler called "fired".

Now, if i do this in my cfgweapon config

class cfgweapon
{
class all;
class pistolcore;
class m9;
class speedgunbasic : m9
{class EventHandlers;};
class speedgun : speedgunbasic
{
bla
bla
bla
class Eventhandler
   {fired = "_this execVM ""\speedcamera\scrits\speedgun.sqf""; "};
};

nothing happends.

Now i'm going to the editor. In the init line i post this

this addEventHandler ["fired",{"_this execVM \speedcamera\scrits\speedgun.sqf"}];

the script starts, when the player put the trigger. In the editor i can start the script by init command! Normaly not possible by cfgweapons.

Can somebody tell me, what i'm doing wrong? For me it's important to start the script addon side not in mission!

And could it be, that hiddenseletions dont work by cfgweapon?

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  

×