wyattwic 38 Posted February 1, 2017 Hello everyone! I have been working on the below code. Currently, if I were to run it via debug, it would work perfectly when I am in a vehicle. I have been attempting to move it over to its own sqf file, ran off of the vehicle's init. _playerEH1 = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw",{ _xnum = ((getNumber (configFile/"CfgVehicles"/typeOf vehicle player/"mapSize"))/50); (_this select 0) drawIcon [ getText (configFile/"CfgVehicles"/typeOf vehicle player/"Icon"), [0,0.1,1,0.5], visiblePosition vehicle player, _xnum/ctrlMapScale (_this select 0), _xnum/ctrlMapScale (_this select 0), direction vehicle player ]; }]; I am not sure what I am missing, but so far replacing "vehicle player" with "_veh" (vehicle's object within the sqf) is not working. It produces no error either. My next idea is to convert it back to text and have it get the object by netid, but I know that is not the most efficient way to do it. I would love any ideas, as I am stumped. PS: Inspired from KK's tutorial :) Share this post Link to post Share on other sites
NeoArmageddon 958 Posted February 1, 2017 I am always compiling the EH on the fly: _eh = call compile format["player addeventhandler [""Handler"",{[%1] call do_something;%2 setdamage 1;}]",_local,_var]; 1 Share this post Link to post Share on other sites
killzone_kid 1333 Posted February 1, 2017 1 hour ago, wyattwic said: _xnum = ((getNumber (configFile/"CfgVehicles"/typeOf vehicle player/"mapSize"))/50); you really don't want to do this each frame. Use _ctrl setVariable and _ctrl getVariable if you want to pass variables to the code of EH 1 Share this post Link to post Share on other sites
NeoArmageddon 958 Posted February 1, 2017 13 minutes ago, killzone_kid said: you really don't want to do this each frame. Use _ctrl setVariable and _ctrl getVariable if you want to pass variables to the code of EH Ah sorry, oversighted that his EH is bound to a display and on frame basis. My bad :( Share this post Link to post Share on other sites
killzone_kid 1333 Posted February 1, 2017 Delete it before anyone sees it ^^^^^^^^^ 2 Share this post Link to post Share on other sites
wyattwic 38 Posted February 2, 2017 Thanks for the input guys. Ill adjust and test, and let you know what happens. Share this post Link to post Share on other sites
wyattwic 38 Posted February 2, 2017 Quick question - I am tracking more than one object. Not sure how best to handle it in that case, since they share the same control. I think? Share this post Link to post Share on other sites
wyattwic 38 Posted February 3, 2017 It took me a while, but I figured out how to do it. I would love any suggestions on performance improvement. { if (_x getVariable ["mapit",false]) then { _x setvariable ["mapit",false]; _x setVariable [netid _x,[_x,((getNumber (configFile/"CfgVehicles"/typeOf _x/"mapSize"))/50),getText (configFile/"CfgVehicles"/typeOf _x/"Icon")]]; _command = format [" _arr = objectFromNetId '%1' getVariable '%1'; (_this select 0) drawIcon [ (_arr select 2), [0,0.1,1,0.5], visiblePosition (_arr select 0), (_arr select 1)/ctrlMapScale (_this select 0), (_arr select 1)/ctrlMapScale (_this select 0), direction (_arr select 0) ]; ",netId _x]; _EH1 = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw",_command]; }; } foreach vehicles select {((alive _x) && ((getNumber (configFile/"CfgVehicles"/typeOf _x/"side")) == 1))}; I do have one more related question. Right now the map shows positions about some of these based on the knowsabout value. Is there any way to prevent friendly forces from appearing on the map like that? EDIT: The above code was set up to be ran from the client. Here is what I made if I opted to have it initatied from the vehicles init. [_this,{ _this setVariable [netid _this,[_this,((getNumber (configFile/"CfgVehicles"/typeOf _this/"mapSize"))/50),getText (configFile/"CfgVehicles"/typeOf _this/"Icon")],true]; _command = format [" _arr = objectFromNetId '%1' getVariable '%1'; (_this select 0) drawIcon [ (_arr select 2), [0,0.1,1,0.5], visiblePosition (_arr select 0), (_arr select 1)/ctrlMapScale (_this select 0), (_arr select 1)/ctrlMapScale (_this select 0), direction (_arr select 0) ]; ",netId _this]; 0 = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw",_command]; }] remoteExec ["spawn",0,_this]; Share this post Link to post Share on other sites
wyattwic 38 Posted February 3, 2017 I have a problem, and I cant find out why. About 800 seconds after the second version of the code, my RPT gets spammed with the below error. After another two minutes, my RPT is over 1.5gbs. I've tried a few different variations and I cant seem to find a solution. 22:20:42 Error in expression < (_arr select 0); (_this select 0) drawIcon [ (_arr select 2), > 22:20:42 Error position: <drawIcon [ (_arr select 2), > 22:20:42 Error Type Number,Not a Number, expected Number Share this post Link to post Share on other sites
theend3r 83 Posted February 3, 2017 2 hours ago, wyattwic said: I have a problem, and I cant find out why. About 800 seconds after the second version of the code, my RPT gets spammed with the below error. After another two minutes, my RPT is over 1.5gbs. I've tried a few different variations and I cant seem to find a solution. 22:20:42 Error in expression < (_arr select 0); (_this select 0) drawIcon [ (_arr select 2), > 22:20:42 Error position: <drawIcon [ (_arr select 2), > 22:20:42 Error Type Number,Not a Number, expected Number It's quite obvious: it's expecting a number but you're giving it a number instead. :D But seriously, you're using "draw" to execute "drawIcon". Seems prety crazy. Share this post Link to post Share on other sites
wyattwic 38 Posted February 5, 2017 On 2/3/2017 at 1:20 AM, theend3r said: It's quite obvious: it's expecting a number but you're giving it a number instead. :D But seriously, you're using "draw" to execute "drawIcon". Seems prety crazy. I would love some elaboration. Messing with the UI is new to me, and all I have is KK's tutorial to base off of. Share this post Link to post Share on other sites