VirusAM Posted April 30, 2020 Share Posted April 30, 2020 Hello every one i need some help from the lua and MP gurus here. Some time ago i realized (for myself) an export script to interact with Thrustmaster target. I used that to configure my target profile on the fly depending on the aircraft and its state (gear, speedbrakes, internal lighting which update throttle and mfd backlights etc etc). It does not work in multiplayer. Till now i didn't study how to make it work in multiplayer but i know that there has to be a way as multiple programs relies on export data to work and these are pretty popular also on multiplayer pilots (Dcs-bios, helios, SRS). So i did my research and found a lot of documents and i saw that the functions i used were the most banned in multiplayer (LoGetObjectById), and i adapted my script to make use of the same functions DCS-Bios and SRS use: LoGetSelfData. But also if i was quick to adapt my script and make it working in singleplayer, still it does not work in multiplayer (i tried hoggit and buddyspike servers). Now if SRS works (and it works we all know very well), why my script is not working????? The main data i need is this: Aircraft name (or some identifier for it) Gear state (i change some functions if the gear is up or down) Speedbrake (i lighten up the cougar mfd led lights with speedbrake on) Panel and instruments backlight (I change the backlight to the Warthog throttle and the MFDs accordingly). I don't think any of this data can pose a cheating threat on multiplayer servers (i am not interested in cheating still i would like my complex script to work in MP with every plane) so i think i still need to study a lot to understand how things works in multiplayer and dcs export Nice to have would be also for example for the Hornet, warning lights (fire, AI, SAM, CW, caution light) that i use with the mfd ligths....but i can be also fine if some of this will work in single player only So my question is: 1) Someone can help me figure out what to use to being able to export this data also in MP 2) Why this function _update.name = _data.UnitName _update.unit = _data.Name _update.unitId = LoGetPlayerPlaneId() work in SRS, but not in my script online? This is my code (much work in progress so a lot of things are for DEBUG). Also if someone is interested i can share my Target code (the C code for reading info from the file is quite simple anyway) local aircraft = "NONE" local selfData = LoGetSelfData() local aircraft_id ="U" --local MainPanel = GetDevice(0) local LED0, LED1, LED2, LED3 = 0, 0, 0, 0 local TLED0, TLED1, TLED2, TLED3, TLED4 = 0, 0, 0, 0, 0 local BATTERY = 0 local RWR1, RWR2, RWR3, RWR4 = 0, 0, 0, 0 local BACKLIGHTA, BACKLIGHTB = 0, 0 local lightspanel, lightsconsole = 5, 5 local gear = 0 local obj_data = LoIsObjectExportAllowed() -- returns the value of server.advanced.allow_object_export local sensor_data = LoIsSensorExportAllowed() -- returns the value of server.advanced.allow_sensor_export local own_data =LoIsOwnshipExportAllowed() -- returns the value of server.advanced.allow_ownship_export local obj = 0 local own = 0 local sensor =0 local uname = 0 local nname = 0 local unitid = 0 if obj_data then obj = obj_data end if sensor_data then sensor = sensor_data end if own_data then own = own_data end function LuaExportActivityNextEvent(t) --if (myInfo) then if selfData then aircraft = selfData["Name"] uname = selfData.UnitName nname = selfData.Name unitid = LoGetPlayerPlaneId() --ocal aircraft = myInfo.Name -- this give you the name of the aircraft end if (aircraft == "A-10C") then local MainPanel = GetDevice(0) aircraft_id ="W" --Console backlight LED0 = 0 --Master Caution Light LED1 = 0 --Launch Warning Light LED2 = 0 --(HOTAS Pinkie Switch) LED3 = 0 --Flaps LED4 = 0 --Gear Lock Lights LED5 = 0 --Console backlight TLED0 = math.ceil(MainPanel:get_argument_value(297)) --Master Caution Light TLED1 = MainPanel:get_argument_value(404) --Launch Warning Light TLED2 = MainPanel:get_argument_value(372) --Flaps TLED3 = math.ceil(MainPanel:get_argument_value(653)) --Gear Lock Lights TLED4 = (MainPanel:get_argument_value(659) and MainPanel:get_argument_value(660) and MainPanel:get_argument_value(661)) gear = MainPanel:get_argument_value(716) BATTERY = MainPanel:get_argument_value(246) elseif (aircraft == "M-2000C") then local MainPanel = GetDevice(0) aircraft_id ="M" --Console backlight LED0 = math.abs(math.ceil(MainPanel:get_argument_value(642))) --Master Caution Light LED1 = (MainPanel:get_argument_value(199) or MainPanel:get_argument_value(200)) --(Not Used) LED2 = 0 --Police light Switch LED3 = MainPanel:get_argument_value(449) --Conf Warning LED4 = MainPanel:get_argument_value(553) --Gear Lock Lights LED5 = (MainPanel:get_argument_value(417) and MainPanel:get_argument_value(418) and MainPanel:get_argument_value(419)) gear = MainPanel:get_argument_value(404) elseif (aircraft == "MiG-19P") then local MainPanel = GetDevice(0) aircraft_id ="P" gear = 0 elseif (aircraft == "F-5E-3") then local MainPanel = GetDevice(0) aircraft_id ="5" gear = 0 elseif (aircraft == "AJS37") then local MainPanel = GetDevice(0) aircraft_id ="V" gear = 0 elseif (aircraft == "F-86F Sabre") then local MainPanel = GetDevice(0) aircraft_id ="S" gear = 0 elseif ((aircraft.Name == "Su-33") or (aircraft.Name == "Su-27") or (aircraft.Name == "J-11A") or (aircraft.Name == "MIG-29S") or (aircraft.Name == "SU-25T")) then aircraft_id ="3" gear = 0 ---------------------------------- AV8B ----------------------- elseif (aircraft == "AV8BNA") then local MainPanel = GetDevice(0) aircraft_id ="8" gear = 0 ----------------------------------END AV8B ----------------------- --------------------------------- F/A-18C HORNET --------------------------------- elseif (aircraft == "FA-18C_hornet") then local MainPanel = GetDevice(0) aircraft_id ="H" --MFD LEDS --Speedbrake LED0 = MainPanel:get_argument_value(19) --Caution LED1 = MainPanel:get_argument_value(13) --Fire LED2 = (MainPanel:get_argument_value(10) or MainPanel:get_argument_value(26)) --RWR --LED3 = (MainPanel:get_argument_value(38) or MainPanel:get_argument_value(39) or MainPanel:get_argument_value(40) or MainPanel:get_argument_value(41)) --RWR Light RWR1 = MainPanel:get_argument_value(38) RWR2 = MainPanel:get_argument_value(39) RWR3 = MainPanel:get_argument_value(40) RWR4 = MainPanel:get_argument_value(41) -- right led logic if (RWR1 == 1) then LED3 = 1 elseif (RWR2 == 1)then LED3 = 1 elseif (RWR3 == 1) then LED3 = 1 elseif (RWR4 == 1) then LED3 = 1 elseif (RWR1 == 0) then LED3 = 0 elseif (RWR2 == 0) then LED3 = 0 elseif (RWR3 == 0) then LED3 = 0 elseif (RWR4 == 0) then LED3 = 0 end --THROTTLE LEDS -- battery BATTERY = MainPanel:get_argument_value(404) TLED0 = 4 TLED1 = 5 TLED2 = 6 --APU FIRE TLED3 = MainPanel:get_argument_value(30) --APU LIGHT TLED4 = MainPanel:get_argument_value(376) --Gear State gear = MainPanel:get_argument_value(226) BACKLIGHTA = MainPanel:get_argument_value(413) --console BACKLIGHTB = MainPanel:get_argument_value(414) --instruments panel -- Console Lights Logic if (BACKLIGHTA == 0) then lightsconsole = 0 elseif (BACKLIGHTA < 0.25) then lightsconsole = 1 elseif (BACKLIGHTA < 0.5) then lightsconsole = 2 elseif (BACKLIGHTA < 0.75) then lightsconsole = 3 elseif (BACKLIGHTA < 1) then lightsconsole = 4 elseif (BACKLIGHTA == 1) then lightsconsole = 5 end -- Panel Lights Logic if (BACKLIGHTB == 0) then lightspanel = 0 elseif (BACKLIGHTB < 0.25) then lightspanel = 1 elseif (BACKLIGHTB < 0.5) then lightspanel = 2 elseif (BACKLIGHTB < 0.75) then lightspanel = 3 elseif (BACKLIGHTB < 1) then lightspanel = 4 elseif (BACKLIGHTB == 1) then lightspanel = 5 end --------------------------------- END F/A-18C HORNET --------------------------------- --------------------------------- F-14B TOMCAT --------------------------------- elseif (aircraft == "F-14B") then local MainPanel = GetDevice(0) aircraft_id ="T" gear = MainPanel:get_argument_value(326) --GearLever LED0 =(MainPanel:get_argument_value(9355) or MainPanel:get_argument_value(9356)) --left and right engine stall LED1 = MainPanel:get_argument_value(15015) --LeftFire LED2 = MainPanel:get_argument_value(15014) --RightFire TLED0 = 5 TLED1 = 6 TLED2 = 7 TLED3 = 8 TLED4 = MainPanel:get_argument_value(15046) --Warning Flap RWR1 = MainPanel:get_argument_value(9357) --AI/SAM/AAA Light RWR2 = MainPanel:get_argument_value(9358) RWR3 = MainPanel:get_argument_value(9359) -- right led logic if (RWR1 == 1) then LED3 = 1 elseif (RWR2 == 1)then LED3 = 1 elseif (RWR3 == 1) then LED3 = 1 elseif (RWR1 == 0) then LED3 = 0 elseif (RWR2 == 0) then LED3 = 0 elseif (RWR3 == 0) then LED3 = 0 end BACKLIGHTA = MainPanel:get_argument_value(15008) --console BACKLIGHTB = MainPanel:get_argument_value(15007) --instruments panel if (BACKLIGHTA == 0) then lightsconsole = 0 elseif (BACKLIGHTA < 0.25) then lightsconsole = 1 elseif (BACKLIGHTA < 0.5) then lightsconsole = 2 elseif (BACKLIGHTA < 0.75) then lightsconsole = 3 elseif (BACKLIGHTA < 1) then lightsconsole = 4 elseif (BACKLIGHTA == 1) then lightsconsole = 5 end -- Panel Lights Logic if (BACKLIGHTB == 0) then lightspanel = 0 elseif (BACKLIGHTB < 0.25) then lightspanel = 1 elseif (BACKLIGHTB < 0.5) then lightspanel = 2 elseif (BACKLIGHTB < 0.75) then lightspanel = 3 elseif (BACKLIGHTB < 1) then lightspanel = 4 elseif (BACKLIGHTB == 1) then lightspanel = 5 end --------------------------------- END F14-B TOMCAT --------------------------------- --------------------------------- PROPS AND WW2 -------------------------------------- elseif (aircraft == "Yak-52") then aircraft_id ="Y" gear = 0 elseif ((aircraft == "SpitfireLFMkIX") or (aircraft.Name == "FW-190D9") or (aircraft.Name == "P-51D")) then aircraft_id ="2" gear = 0 elseif (aircraft == "Bf-109K-4") then aircraft_id ="K" gear = 0 --------------------------------- END PROPS AND WW2 -------------------------------------- end default_output_file = io.open(lfs.writedir().."/Logs/TargetScript.log", "w") default_output_file:write(string.format("%s", aircraft_id)) default_output_file:write(string.format("%d", gear)) default_output_file:write(string.format("%d%d%d%d", LED0, LED1, LED2, LED3)) default_output_file:write(string.format("%d%d%d%d%d", TLED0, TLED1, TLED2, TLED3, TLED4)) default_output_file:write(string.format("%d%d", lightsconsole, lightspanel)) default_output_file:write(string.format("%d", BATTERY)) default_output_file:write(string.format("\nlightsconsoleight=%s", BACKLIGHTA)) default_output_file:write(string.format("\nlightspanelight=%s", BACKLIGHTB)) default_output_file:write(string.format("\nRWR1=%s", RWR1)) default_output_file:write(string.format("\nRWR2=%s", RWR2)) default_output_file:write(string.format("\nRWR3=%s", RWR3)) default_output_file:write(string.format("\nRWR4=%s", RWR4)) default_output_file:write(string.format("\nAircraft name = %s", aircraft)) default_output_file:write(string.format("\nGear Lever = %s", gear)) default_output_file:write(string.format("\nSpeedbrake = %s", LED0)) default_output_file:write(string.format("\nUnit name = %s", uname)) default_output_file:write(string.format("\nUnit = %s", nname)) default_output_file:write(string.format("\nUnit ID = %s", tostring(unitid))) default_output_file:write(string.format("\nObject Export = %s", tostring(obj))) default_output_file:write(string.format("\nSensor Export = %s", tostring(sensor))) default_output_file:write(string.format("\nOwnship Export = %s", tostring(own))) --default_output_file:write(string.format("\nIndicated air speed = %s", ias)) default_output_file:close() return t + 0.1 end -------------------------------------------------------------- function LuaExportStop() default_output_file = io.open(lfs.writedir().."/Logs/TargetScript.log", "w") default_output_file:write("U200000000055100000000000") default_output_file:close() end R7-5800X3D 64GB RTX-4090 LG-38GN950 Meta Quest 3 VPForce Rhino FFB, Virpil F-14 (VFX) Grip, F-15EX Throttle, MFG Crosswinds v3, Razer Tartarus V2 SpeedMaster Flight Seat, JetSeat Link to comment Share on other sites More sharing options...
VirusAM Posted April 30, 2020 Author Share Posted April 30, 2020 (edited) Here are examples from the script: This is SinglePlayer Only the first row is relevant to the target script. The other part are raw values from the sim and i inserted for now only for debug reasons. H1000045600331 H is aircraft_id (for Hornet) 1 represent the gear value (in the Hornet 1 means gear up and 0 down) the all the other values represent something as seen in the script And this in multiplayer (all values to 0) Edited April 30, 2020 by VirusAM R7-5800X3D 64GB RTX-4090 LG-38GN950 Meta Quest 3 VPForce Rhino FFB, Virpil F-14 (VFX) Grip, F-15EX Throttle, MFG Crosswinds v3, Razer Tartarus V2 SpeedMaster Flight Seat, JetSeat Link to comment Share on other sites More sharing options...
VirusAM Posted April 30, 2020 Author Share Posted April 30, 2020 And here if someone is interested just a part of the target script to read the file int GetInfo() //work in progress { printf("Get Information Function\xa"); int file; char aircraft_id, gearstate, MLED0, MLED1, MLED2, MLED3, TLED0, TLED1, TLED2, TLED3, TLED4, battery, panel_light, console_light; file = fopen("C://Users//Vincent//Saved Games//DCS.openbeta//Logs//TargetScript.log", "r"); //file = fopen("TargetScript.log", "r"); //for testing purposes aircraft_id=fgetc(file); gearstate =fgetc(file); MLED0 =fgetc(file); MLED1 =fgetc(file); MLED2 =fgetc(file); MLED3 =fgetc(file); TLED0 =fgetc(file); TLED1 =fgetc(file); TLED2 =fgetc(file); TLED3 =fgetc(file); TLED4 =fgetc(file); console_light=fgetc(file); panel_light=fgetc(file); battery =fgetc(file); //battery fclose(file); if (aircraft_id =='U') { printf("Default\xa"); printf("No DCS or Export Disabled\xa"); battery='1'; console_light='5'; panel_light='5'; printf("Set Information Function\xa"); file = fopen("C://Users//Vincent//Saved Games//DCS.openbeta//Logs//TargetScript.log", "w"); fputc('H', file); fputc('3', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('0', file); fputc('5', file); fputc('5', file); fputc('1', file); fclose(file); //ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 255)); //ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 255)); //0 //ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 255)); } else if (aircraft_id == 'T') { printf("F-14B Tomcat Placeholder\xa"); //Tomcat //Console Lights /*if (console_light=='0') //{ ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 43)); //set Throttle backlight power to 0 //} else if (console_light=='1') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 87)); //set Throttle backlight power to 1 } else if (console_light=='2') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 130)); // 2 } else if (console_light=='3') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 180)); //3 } else if (console_light=='4') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 230)); //4 } else if (console_light=='5') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 255)); //FULL } //Instrument Lights if (panel_light=='0') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 20)); //0 ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 20)); } else if (panel_light=='1') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 63)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 43)); } else if (panel_light=='2') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 125)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 125)); } else if (panel_light=='3') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 161)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 161)); } else if (panel_light=='4') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 210)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 210)); } else if (panel_light=='5') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 255)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 255)); //FULL } */ } else if (aircraft_id == 'H') // F/A-18C Hornet { printf("F/A-18C Hornet Informations\xa"); printf("Aircraft id=%c, Gearstate=%c\xa",aircraft_id, gearstate); printf("MLED0-Speedbrake=%c, MLED1-Caution=%c, MLED2-Fire=%c, MLED3-RWR=%c\xa", MLED0, MLED1, MLED2, MLED3); printf("TLED0=%c, TLED1=%c, TLED2=%c, TLED3-APUFIRE=%c, TLED4-APU=%c\xa", TLED0, TLED1, TLED2, TLED3, TLED4); printf("battery=%c, panel_light=%c,console_light=%c\xa", battery, panel_light, console_light); //MFD LEDS if (MLED0 == '1') //speedbrake { ActKey(PULSE+KEYON+LED(&LMFD, LED_ONOFF, LED_CURRENT+LED1)); } else { ActKey(PULSE+KEYON+LED(&LMFD, LED_ONOFF, LED_CURRENT-LED1)); } if (MLED1 == '1') //caution light { ActKey(PULSE+KEYON+LED(&LMFD, LED_ONOFF, LED_CURRENT+LED2)); } else { ActKey(PULSE+KEYON+LED(&LMFD, LED_ONOFF, LED_CURRENT-LED2)); } if (MLED2 == '1') //RWR { ActKey(PULSE+KEYON+LED(&RMFD, LED_ONOFF, LED_CURRENT+LED2)); } else { ActKey(PULSE+KEYON+LED(&RMFD, LED_ONOFF, LED_CURRENT-LED2)); } if (MLED3 == '1') //fire { ActKey(PULSE+KEYON+LED(&RMFD, LED_ONOFF, LED_CURRENT+LED1)); } else { ActKey(PULSE+KEYON+LED(&RMFD, LED_ONOFF, LED_CURRENT-LED1)); } //Throttle LEDS //if (TLED4 == '1') //apu light //{ ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT+LED5)); //} //else //{ //ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED5)); //} //APU FIRE ///if (TLED3 == '1') //{ ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT+LED4)); //} //else //{ //ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED4)); //} //Console Lights and Instrument Lights backlighting management if (battery== '0') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0)); ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 0)); //0 ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 0)); } if (battery =='1') { //Console Lights if (console_light=='0') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 43)); //set Throttle backlight power to 0 } else if (console_light=='1') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 63)); //set Throttle backlight power to 1 } else if (console_light=='2') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 125)); // 2 } else if (console_light=='3') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 161)); //3 } else if (console_light=='4') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 210)); //4 } else if (console_light=='5') { ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 255)); //FULL } //Instrument Lights if (panel_light=='0') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 20)); //0 ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 20)); } else if (panel_light=='1') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 63)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 63)); } else if (panel_light=='2') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 125)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 125)); } else if (panel_light=='3') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 161)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 161)); } else if (panel_light=='4') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 210)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 210)); } else if (panel_light=='5') { ActKey(PULSE+KEYON+LED(&LMFD, LED_INTENSITY, 255)); ActKey(PULSE+KEYON+LED(&RMFD, LED_INTENSITY, 255)); //FULL } } } ...................... ................ R7-5800X3D 64GB RTX-4090 LG-38GN950 Meta Quest 3 VPForce Rhino FFB, Virpil F-14 (VFX) Grip, F-15EX Throttle, MFG Crosswinds v3, Razer Tartarus V2 SpeedMaster Flight Seat, JetSeat Link to comment Share on other sites More sharing options...
VirusAM Posted May 2, 2020 Author Share Posted May 2, 2020 Come on guys there are a lot of highly skilled people here. No one can point me out in the right direction? No one can have a look at my lua and validate it? R7-5800X3D 64GB RTX-4090 LG-38GN950 Meta Quest 3 VPForce Rhino FFB, Virpil F-14 (VFX) Grip, F-15EX Throttle, MFG Crosswinds v3, Razer Tartarus V2 SpeedMaster Flight Seat, JetSeat Link to comment Share on other sites More sharing options...
Recommended Posts