Kubas94CZ 0 Posted April 11, 2020 Hello, I'm making rally point script (based of many diferent scripts), but I have problem with number of squad leaders (number of variable names). Spoiler _unit = (_this select 0); if ((_unit == SQA) && (r1Cooldown == 1)) exitWith { hint parseText format ["<t size = '1.5' color = '#FF0000'>Not Available!</t><br/><br/>You must wait 5 minutes after placing a rally to deploy another!"]; }; if ((_unit == SQA) && (r1Cooldown == 0)) then { deleteVehicle rally1; r1Cooldown=1; rally1 = createVehicle ["Misc_Backpackheap", position SQA]; rally1 enableSimulation false; rally1 addEventHandler ["HandleDamage",{0}]; "respawn_guerrila_SQA" setMarkerPos position SQA; hint parseText format ["<t size = '1.5' color = '#4DB0E2'>Squad Rally Point Placed!</t><br/><br/>It will be moved to base in 10 minutes!"]; sleep 300; r1Cooldown = 0; hint parseText format ["<t size = '1.5' color = '#4DB0E2'>Squad Rally Point Available!</t><br/><br/>You Can Deploy It Through Scroll Menu!"]; sleep 300; deleteVehicle rally1; "respawn_guerrila_SQA" setMarkerPos getMarkerPos "respawn_guerrila_BASE"; hint parseText format ["<t size = '1.5' color = '#4DB0E2'>Squad Rally Point Moved to Base!</t><br/><br/>You Can Deploy A New One Through Scroll Menu!"]; }; if ((_unit == SQB) && (r2Cooldown == 1)) exitWith { hint parseText format ["<t size = '1.5' color = '#FF0000'>Not Available!</t><br/><br/>You must wait 5 minutes after placing a rally to deploy another!"]; }; .... it repeats until 8th squad leader SQH I have problem with variables SQA ... SQB ... SQC, these variables are variable names of each squad leader. But I never know how many squad leaders I will need (it depends on number of players and so on) so let's say that I have 3 squad leaders (SQA, SQB, SQC) but when they use this script via addAction it will show error message: "undefined variable sqd in line if ((_unit == SQD) && (r2Cooldown == 1)) exitWith {" So unless I have all squad leader this error will show up on each use. Script works, but these error messages are annoying. Is there way to solve this? I know there is way by dividing script for each squad leader, but I don't think it is THE WAY. Or is it possible to use variable name in each line such as: Spoiler _unit = (_this select 0); if ((_unit)Cooldown == 1) exitWith { hint parseText format ["<t size = '1.5' color = '#FF0000'>Not Available!</t><br/><br/>You must wait 5 minutes after placing a rally to deploy another!"]; }; if (r1Cooldown == 0) then { deleteVehicle (_unit)rally; (_unit)Cooldown=1; (_unit)rally = createVehicle ["Misc_Backpackheap", position SQA]; (_unit)rally enableSimulation false; (_unit)rally addEventHandler ["HandleDamage",{0}]; "respawn_guerrila_(_unit)" setMarkerPos position (_unit); hint parseText format ["<t size = '1.5' color = '#4DB0E2'>Squad Rally Point Placed!</t><br/><br/>It will be moved to base in 10 minutes!"]; sleep 300; (_unit)Cooldown = 0; hint parseText format ["<t size = '1.5' color = '#4DB0E2'>Squad Rally Point Available!</t><br/><br/>You Can Deploy It Through Scroll Menu!"]; sleep 300; deleteVehicle (_unit)rally; "respawn_guerrila_(_unit)" setMarkerPos getMarkerPos "respawn_guerrila_BASE"; hint parseText format ["<t size = '1.5' color = '#4DB0E2'>Squad Rally Point Moved to Base!</t><br/><br/>You Can Deploy A New One Through Scroll Menu!"]; }; Thanks for any answers, Kuba Share this post Link to post Share on other sites
opusfmspol 282 Posted April 11, 2020 Before proceeding into its code, you should do some verification on _unit to ensure 1) it's not null, like when AI are disabled or get deleted in a cleanup, and 2) it's still alive, not dead. if (!isNull SQA && {Alive SQA}) then { if ((_unit == SQA) && (r1Cooldown == 0)) then { Share this post Link to post Share on other sites
Larrow 2822 Posted April 12, 2020 13 hours ago, opusfmspol said: you should do some verification on _unit to ensure 1) it's not null, make sure it is not nil first if ( !isNil "SQA" && { _unit == SQA && r1Cooldown == 0 } ) then { Share this post Link to post Share on other sites