Stank4K 2 Posted January 17, 2020 @Larrow Upon uploading this to my server in the mission. It does not work in multiplayer. Something to do with the "player" command doesn't work for MP. Which is odd, since it works in the MP in the editor. I also tried this where the character's variable name is sLead. But I guess Variable Name for a player controlled unit doesn't matter. _desPos = laserTarget sLead; I also tried setting all the variables to public ones. Thinking the server would pickup desPos after the client sets it. But no luck. I plan on changing those back to private vars if I can once it works. //sendArtToLaserDes.sqf desPos = laserTarget sLead; if !( isNull desPos ) then { mortar11G setVehicleAmmo 1; mortar12G setVehicleAmmo 1; mortar13G setVehicleAmmo 1; mortar14G setVehicleAmmo 1; mortar11 doArtilleryFire[ getPosATL desPos, "8Rnd_82mm_Mo_shells", 3 ]; etaRaw = mortar11 getArtilleryETA [position desPos, currentMagazine mortar11]; eta = round etaRaw; mortar11G sideChat (format ["Rounds Inbound to Designated Location. ETA: %1 s", str(eta)]); sleep .5; mortar12 doArtilleryFire[ getPosATL desPos, "8Rnd_82mm_Mo_shells", 3 ]; sleep .5; mortar13 doArtilleryFire[ getPosATL desPos, "8Rnd_82mm_Mo_shells", 3 ]; sleep .5; mortar14 doArtilleryFire[ getPosATL desPos, "8Rnd_82mm_Mo_shells", 3 ]; }else{ mortar11G sideChat "No Target Acquired!"; }; This is the full script I have. Doesn't work in MP as it stands. I also tried using Param[1] in place of "Player", but same effect. Nothing. Share this post Link to post Share on other sites
Larrow 2820 Posted January 17, 2020 From laserTarget Quote Return Value: Object - laser target or objNull if no laser target exists Spoiler //sendArtToLaserDes.sqf _target = laserTarget player; if !( isNull _target ) then { mortar11 doArtilleryFire[ getPosATL _target, "8Rnd_82mm_Mo_shells", 3 ]; }else{ mortar11G sideChat "No Target Acquired!"; }; 3 Share this post Link to post Share on other sites
Stank4K 2 Posted January 17, 2020 I'm gonna explode if that works. Testing tonight around 730 cst. I never saw that on the lazerTarget page. I think I messed with isNull a couple times. Once desPos has been set, does it return to isNull after the script completes, or do I need to set it back to isNull? Otherwise the player could accidentally recall a mortar strike on the last position they lased. @Larrow Share this post Link to post Share on other sites
Play3r 147 Posted January 17, 2020 i'm just following this, have been looking for something like this for a mission of mine. 1 Share this post Link to post Share on other sites
Larrow 2820 Posted January 17, 2020 2 hours ago, Stank4K said: Once desPos has been set, does it return to isNull after the script completes, or do I need to set it back to isNull? Don't use desPos at all, as per my post just use a local variable( _target ). Then you have no problems with having to reset anything. 1 Share this post Link to post Share on other sites
Stank4K 2 Posted January 17, 2020 Finished script with rounded ETA in seconds: //sendArtToLaserDes.sqf _desPos = laserTarget player; if !( isNull _desPos ) then { mortar11 doArtilleryFire[ getPosATL _desPos, "8Rnd_82mm_Mo_shells", 3 ]; _etaRaw = mortar11 getArtilleryETA [position _desPos, currentMagazine mortar11]; _eta = round _etaRaw; mortar11G sideChat (format ["Rounds Inbound to Designated Location. ETA: %1 s", str(_eta)]); }else{ mortar11G sideChat "No Target Acquired!"; }; Thanks @Larrow you legend! Bailed me out a 3rd time as of now! I tried to do _mortar = mortar11 and replace all the mortar11's with _mortar but it didn't work for me. But, this will do for sure. Not too big of a script to change them manually when needed! Share this post Link to post Share on other sites
Stank4K 2 Posted January 18, 2020 (edited) I don't know if it notify's you of edits @Larrow, so here is a reply to maybe catch the eye of the almighty himself. The script in it's updated form, (edited original post), does not work in MP. And I'm lost on how to replace player with something that works in MP. Quote In MP player is different on each computer and on dedicated server it is objNull by default (however this doesn't mean there couldn't be one). When user is joining dedicated server mission, at the moment of onPlayerConnected the player object is remote to the joining client, as the player unit is created on the server, but once control of the unit is passed to the user moments later, the player objects becomes local to the client and stays local. Looking into setVariable and publicVariableServer. And maybe groupOwner. Since only the squad lead can call this in anyways. All units are synched to him in editor. Edited January 18, 2020 by Stank4K Share this post Link to post Share on other sites
Larrow 2820 Posted January 18, 2020 8 hours ago, Stank4K said: Since only the squad lead can call this in anyways. How does he call it? 1 Share this post Link to post Share on other sites
Stank4K 2 Posted January 18, 2020 1 hour ago, Larrow said: How does he call it? Via addAction ["words", thisscript] Turn on laser, scroll and use the action to run the arty script. Share this post Link to post Share on other sites
Larrow 2820 Posted January 18, 2020 4 hours ago, Stank4K said: Via addAction ["words", thisscript] Turn on laser, scroll and use the action to run the arty script. Then player should be fine. As its an addAction then the code it runs is always going to be local to the user( player ), unless you are doing some weird remoteExec. 1 Share this post Link to post Share on other sites
Stank4K 2 Posted January 18, 2020 (edited) The script I have in the original post is the one I am using. The mortars are not local. They are AI placed in editor. So server side only. (Dedicated Server). I tried with a few clients, one being myself, but the AI don't seem to want to fire. I added the setAmmo command to the script to ensure they have it. An ETA does get returned in side chat, but it's only visible to the client that called it in. Which is odd, since the AI didn't actually fire, I'm not sure how the server returned and ETA. waitUntil {Alive sLead}; sLead addAction ["Bring the Rain", "scripts\sendArtToLazerDes.sqf"]; I have this in a trigger temporarily that covers the spawn area. I plan on moving to the bottom of my init once it works. It successfully waits for the Var Name to be logged in and ready and then assigns the sLead (Squad Leader) the ability to call the script. So anyone can activate it, but only the sLead will, once alive, get it. And to prevent mass scrolling, here is the code as it stands: //sendArtToLaserDes.sqf _desPos = laserTarget player; if !( isNull _desPos ) then { mortar11G setVehicleAmmo 1; mortar12G setVehicleAmmo 1; mortar13G setVehicleAmmo 1; mortar14G setVehicleAmmo 1; mortar11 doArtilleryFire[ getPosATL _desPos, "8Rnd_82mm_Mo_shells", 3 ]; etaRaw = mortar11 getArtilleryETA [position _desPos, currentMagazine mortar11]; eta = round etaRaw; mortar11G sideChat (format ["Rounds Inbound to Designated Location. ETA: %1 s", str(eta)]); sleep .5; mortar12 doArtilleryFire[ getPosATL _desPos, "8Rnd_82mm_Mo_shells", 3 ]; sleep .5; mortar13 doArtilleryFire[ getPosATL _desPos, "8Rnd_82mm_Mo_shells", 3 ]; sleep .5; mortar14 doArtilleryFire[ getPosATL _desPos, "8Rnd_82mm_Mo_shells", 3 ]; sleep 10; mortar11G addEventHandler ["fired", "mortar11G setVehicleAmmo 1"]; mortar12G addEventHandler ["fired", "mortar12G setVehicleAmmo 1"]; mortar13G addEventHandler ["fired", "mortar13G setVehicleAmmo 1"]; mortar14G addEventHandler ["fired", "mortar14G setVehicleAmmo 1"]; }else{ mortar11G sideChat "No Target Acquired!"; }; TL;DR - sideChat only (somehow) shows up for the client that calls the code. And the Mortars, which are editor placed with AI on it, do nothing. @Larrow I believe that since the AI/Mortars are server side only, and the player command returns as isNull for the server, this script doesn't return laserTarget to _desPos since _desPos = laserTarget player; is trying to pull an array from Null. So the only way to get this to work would be to somehow get _desPos client side, then send that data to the server for it to process it with the script. I was considering setVariable and/or remoteExecutedOwner with remoteExec. But I am no expert. I'm gonna mess with things when I get home, but I'm almost certain @Larrow, being the legend he is, will probably figure this out way faster than I can. Side note: Would getting _desPos from player in the addAction then sending that var to the script work best? And how would I send that var to the server with it's data intact. I assume setVariable? Haven't put too much research into setVar just yet. Edited January 18, 2020 by Stank4K Share this post Link to post Share on other sites
Larrow 2820 Posted January 18, 2020 10 minutes ago, Stank4K said: The mortars are not local. They are AI placed in editor. So server side only. (Dedicated Server). Not Server Side Only, rather their locality is the server. Distinct difference. 11 minutes ago, Stank4K said: An ETA does get returned in side chat, but it's only visible to the client that called it in. Which is correct. An addAction is local where the addAction's command is run. Any code the action runs will also be local, so the actions user sees the ETA sideChat, as sideChat is EL( effect local ). 14 minutes ago, Stank4K said: I believe that since the AI/Mortars are server side only, and the player command returns as isNull for the server, this script doesn't return laserTarget to _desPos since _desPos = laserTarget player; is trying to pull an array from Null. So the only way to get this to work would be to somehow get _desPos client side No, the addAction is local where the addAction command is run, any code the action runs is also local, so player will be the user of the action. As _desPos is in the actions code and the actions code is run on the machine where the user used the addAction then _desPos is client side( local to the addAction's user ). I'm going to guess that doArtilleryFire is AL( argument local )( wiki does not state the locality of this command ) which the mortars are not, their locality is the server. ....5 minutes laterrrr.... TEST_MISSION 2 1 Share this post Link to post Share on other sites
Stank4K 2 Posted January 19, 2020 That's the winner! @Larrow Works in MP perfectly. Made a few adjustments to fit my needs, but out of box that works perfectly! For those who want the completed project, (just in case the dropbox ever goes down.) Here it is: init.sqf: //Function to call remotely to make artillery fire TAG_fnc_doArtilleryFire = { params[ "_laserTarget" ]; //passed laser designator object //AL( argument must be local( mortar11G )) mortar11G setVehicleAmmo 1; //AL( argument must be local( mortar11 )) mortar11 doArtilleryFire[ getPosATL _laserTarget, "8Rnd_82mm_Mo_shells", 3 ]; }; initPlayerLocal.sqf player addAction ["Bring the Rain", "scripts\sendArtToLazerDes.sqf"]; scripts\sendArtToLazerDes.sqf: //sendArtToLaserDes.sqf _laserTarget = laserTarget player; if !( isNull _laserTarget ) then { _etaRaw = mortar11 getArtilleryETA[ getPosATL _laserTarget, currentMagazine mortar11 ]; //Tell actions user about ETA mortar11G sideChat format[ "Rounds Inbound to Designated Location. ETA: %1 s", round _etaRaw ]; //remote call the function TAG_fnc_doArtilleryFire where mortar11 is local [ _laserTarget ] remoteExec[ "TAG_fnc_doArtilleryFire", mortar11 ]; }else{ //Tell actions user that no laser target is available mortar11G sideChat "No Target Acquired!"; }; Mortars Variable name is Mortar11. Mortar11G is the unit on the mortars name natively when the mortar is set to Mortar11. Thanks once again to @Larrow. He wrote this and figured everything out. I take no credit. 1 Share this post Link to post Share on other sites