Jump to content
Sign in to follow this  
tryteyker

Display EHs and preprocessor commands

Recommended Posts

Hi,

finally back on track with my mission. Right now, I'm trying to include a simple Display EH. What it does is activate a siren provided the player presses the correct key and is in a vehicle. Problem is, it won't execute. The Display EH script (the one that adds it) gets executed properly. However, the actual EH doesn't function.

#include "definitions.sqf"

_display = _this select 0;
_keycode = _this select 1;
// Debug hint
hint "debug!";
// Exit if key pressed is not equal to H.
if (_keycode != DIK_H) exitWith {
hint "WRONG KEY PRESSED - DEBUG"; 
false
};
// Exit if player is not in vehicle.
if (vehicle player == player) exitWith {
hint "YOU HAVE TO BE IN A VEHICLE TO USE THE SIREN!";
false
};

sleep .5;

// Fetch vehicle of player.
_car = vehicle player;
// Spawn siren.
_siren = [_car,[0,0,6]] spawn TRT_fnc_siren;

true

The debug hint won't display at all, regardless of which key is pressed or not. The "definitions.sqf" is another problem of mine. In it are basically definitions that define keycodes. So 0x23 becomes DIK_H, so on so forth. Since .hpp didn't work I've switched over to .sqf. The file gets preprocessed in the init.sqf before the above script is called. The definitions.sqf itself doesn't seem to be a problem (as commenting it out doesn't help running the script either), but I'm still curious; Should I use .hpp for simple definitions or .sqf?

Back to the siren thingy though, this is how I add the EH.

SirenOn = (findDisplay 46) displayAddEventHandler ["onKeyDown","keys\sireninit.sqf"];

This is in an extra SQF script (thought that'd help, but it's a waste of space for now) that executes in init.sqf:

sleep 1;
createDialog "TRT_LSEL";
call compile preprocessFileLineNumbers "keys\definitions.sqf";
[] execvm "load\lbentries.sqf";
[] execvm "load\lbpics.sqf";
(driver sportscar) addAction ["Attempt arrest","driverarrest.sqf"];
[] execVM "keys\sirenload.sqf";

(Last script in line). Any ideas as to why this doesn't work?

EDIT

I just remembered why I made that extra sqf. To limit that EH to vehicles. YUP. Also the defintions.sqf was in an extra folder.. Moving it to mission root doesn't help though.

EDIT2

Solved, #include doesn't work and I had to rewrite the sireninit.sqf script to a function. Fixed it, although there were a few smaller errors.

Edited by tryteyker

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  

×