Jump to content
Sign in to follow this  
simonwa1

Addeventhandler problem

Recommended Posts

Hello!

I need to add an eventhandler to a vehicle. But I have i variable that I must evaluate in addEventHandler argument. I'll show you.

Syntax: (from Wiki)

Quote[/b] ]Number = object addEventHandler ["type", {code}]

I have a string-variable that needs to be evaluated and then put in as an argument to addEventHandler. Look..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_myString = "Weeeii";

vehicle1 addEventHandler ["getIn", { [ _this select 0, _myStringEvaluated(<----huh.gif)] };

So the arugument is parsed like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

["getIn", [_this select 0, "Weeeii"];

Can someone help? smile_o.gif Bye!

Share this post


Link to post
Share on other sites

Problem solved.

Solution:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_str = "[_this select 0, '" + _myString + "'] execVM 'veh_lock.sqf'";

_vcl addEventHandler ['getIn', _str];

Notice that there is no curled barces {};

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  

×