snowsniper Posted May 14, 2016 Posted May 14, 2016 Hi, I need help for basic scripting I would like that the more client player there are in the mission, the more transportable troops appears. I've ever done it in duplicate the same trigger line for each aircraft with the condition "alive" but here i need an other way to do it : something like that My Flag '1000' is the number of "alive active" player : with a do script : do local t = trigger.misc.getUserFlag('1000') local i = 0 for i, t do ctld.spawnGroupAtTrigger("red",4, "base", 5) end not working so far. any idea or advice ? i7-10700KF CPU 3.80GHz - 32 GO Ram - - nVidia RTX 2070 - SSD Samsung EVO with LG TV screen 40" in 3840x2150 - cockpit scale 1:1 - MS FFB2 Joystick - COUGAR F16 throttle - Saitek Pro Flight Rudder Pedals
FSFIan Posted May 14, 2016 Posted May 14, 2016 1. The "do" at the beginning does not have a matched "end" 2. "for i, t do" is not a valid Lua statement. You probably mean "for i = 1, t do" If you didn't know better, I recommend reading the Reference Manual for Lua 5.1, which is the version that is used in DCS. Read through the entire thing! You don't have to understand everything you read, but you will remember where you can look things up. Take it with you on your phone and read it at the bus stop, on the toilet, while waiting in line at the grocery store... If you did know better but didn't spot the error, you should look into better ways to debug your code. I think your current solution should have generated an error message (either in a message box or in dcs.log). You may also be interested in the Lua Console in DCS Witchcraft (see link in my sig). And don't despair, but, practice, practice, practice. At some point you will have made all of the typical errors a few times and you'll spot those within seconds. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
snowsniper Posted May 14, 2016 Author Posted May 14, 2016 thanks a lot for the ressource link and the advice. I'll give it a try. i7-10700KF CPU 3.80GHz - 32 GO Ram - - nVidia RTX 2070 - SSD Samsung EVO with LG TV screen 40" in 3840x2150 - cockpit scale 1:1 - MS FFB2 Joystick - COUGAR F16 throttle - Saitek Pro Flight Rudder Pedals
snowsniper Posted May 14, 2016 Author Posted May 14, 2016 this works do local t = trigger.misc.getUserFlag('1000') local i = 0 for i=1, t do ctld.spawnGroupAtTrigger("red",4, "spawn4", 0) end end i7-10700KF CPU 3.80GHz - 32 GO Ram - - nVidia RTX 2070 - SSD Samsung EVO with LG TV screen 40" in 3840x2150 - cockpit scale 1:1 - MS FFB2 Joystick - COUGAR F16 throttle - Saitek Pro Flight Rudder Pedals
Quax456 Posted May 15, 2016 Posted May 15, 2016 You can delete the initital declaration of "local i = 0" this is not neccessary within a "for" loop. Regards My Rig: Windows 11 Pro, Intel i7-13700k@5.4GHz, 64GB DDR5 5200 RAM, Gigabyte Z790 AORUS Elite AX, 2TB Samsung 990 PRO, RTX4080, Thrustmaster HOTAS WARTHOG Stick + WINWING ORION 2 + MFG Crosswinds, LG 32" 4K 60FPS, ACER 30" 4K 60FPS GSync Display, HP Reverb G2 V2
Recommended Posts