mzgr 8 Posted April 9, 2020 I am making a PvP mission, bluefor vs. opfor. Each side has an APC which is used as teleport starting point. Players get teleported into an ATV with this kind of script: APC init: Quote this addAction["Teleport to ATV_Alpha", "teleportMHQbluefor.sqf", "ATV_Alpha"]; and the .sqf is: Quote params[ "_target", "_caller", "_id", "_args" ]; _teleportTo = missionNamespace getVariable [ _args, objNull ]; if ( !isNull _teleportTo && { alive _teleportTo } ) then { _caller moveInCargo _teleportTo; _caller vehicleChat format ["You have been deployed at %1", _teleportTo]; } else { _caller groupChat format ["Unable to deploy to %1 at this time.", _teleportTo]; }; Problem is, both sides can use both teleporters, instead of each its own. So i am looking for a way to limit ''teleport into a vehicle'' for only one faction Share this post Link to post Share on other sites
RCA3 590 Posted April 9, 2020 Hi, please edit your message and use the Code or Quote buttons on your message top bar and move your code lines inside. And remove your color. Thanks. 1 Share this post Link to post Share on other sites
RCA3 590 Posted April 9, 2020 (edited) Thanks. (Was hurting my eyes 😝). Try this: params[ "_target", "_caller", "_id", "_args" ]; private _realVehicleSide = [_target, true] call BIS_fnc_objectSide; private _friendsides = _realVehicleSide call BIS_fnc_friendlySides; // can return [FRIENDLY,WEST,GUER,CIV] if !(side _caller in _friendsides) exitWith{}; _teleportTo = missionNamespace getVariable [ _args, objNull ]; if ( !isNull _teleportTo && { alive _teleportTo } ) then { _caller moveInCargo _teleportTo; _caller vehicleChat format ["You have been deployed at %1", _teleportTo]; } else { _caller groupChat format ["Unable to deploy to %1 at this time.", _teleportTo]; }; Edited April 9, 2020 by RCA3 Fixed. Had a mistake on _friendsides line. Share this post Link to post Share on other sites
mzgr 8 Posted April 9, 2020 😅 sorry man, as you can see i am very new at this. I copiy-pasted you code in the sqf but unfortunatly, both side can still use all teleports. Do i need to rename something maybe? 1 Share this post Link to post Share on other sites
RCA3 590 Posted April 9, 2020 It's ok. Did you use the "fixed" version? I'll test this out later if no one comes up with a better solution. Cheers. Share this post Link to post Share on other sites
mzgr 8 Posted April 9, 2020 Yes I did. I will give you some more information. I have 2 .sqf files. teleportMHQbluefor.sqf and teleportMHQopfor.sqf and each APC calls it's own in init. When i copy paste your code in each of them, i can still teleport from both APC with both factions. i also tried with a single file called teleport.sqf with your script. I changed APC init to: Quote this addAction["Teleport to ATV_Alpha", "teleport.sqf", "ATV_Alpha"]; and for some reason i get the msg: script teleport.sqf not found ty Share this post Link to post Share on other sites
mzgr 8 Posted April 9, 2020 and please, if you have enough patience, imagine you are explaining this to an idiot... Share this post Link to post Share on other sites
RCA3 590 Posted April 9, 2020 (edited) Looks like your script was faulty from the get go: 13 hours ago, mzgr said: this addAction["Teleport to ATV_Alpha", "teleportMHQbluefor.sqf", "ATV_Alpha"]; First, we must correct the argument on this line and pass an object instead of string. Objects have names without spaces (edit: and quotes). this addAction["Teleport to ATV_Alpha", "teleportMHQbluefor.sqf", ATV_Alpha]; 13 hours ago, mzgr said: _teleportTo = missionNamespace getVariable [ _args, objNull ]; Here you are asking the mission "space" for a variable, which was the string variable you were passing, "ATV_Alpha" inside the action "space" through the _args parameter. Since we already have the parameter we want through _args, we don't need to ask for it again, and would also return nil because the mission "space" does not have that variable defined as anything, it's just an "empty" string at this point. If it were to become a missionNameSpace variable it would have to be defined at some point through missionNameSpace setVariable ["ATV_Alpha", (some value)]. So, that line is irrelevant and we remove it. For readability sake we make a copy of _args using _quad = _args. From there on we just replace _teleportTo with _quad and we should be done 🙂. I replaced alive with damage just in case the quad would be on fire but still not totally destroyed (damage >= 0.9). params[ "_target", "_caller", "_id", "_args"]; private _quad = _args; private _realVehicleSide = [_target, true] call BIS_fnc_objectSide; private _friendsides = _realVehicleSide call BIS_fnc_friendlySides; if !(side _caller in _friendsides) exitWith{}; if (!isNull _quad && {(damage _quad) < 0.9}) then { _caller moveInCargo _quad; _caller vehicleChat format ["You have been deployed at %1", _quad]; }else { _caller groupChat format ["Unable to deploy to %1 at this time.", _quad]; }; As for the sides part we're just running two BI Functions that helps us get relationships between objects and/or sides. First we ask what's the side of the vehicle (_target) we're interacting with, and second we ask what sides are friendly to that side. Finally, if the side of the person interacting with the vehicle (_caller), is not on the friendly sides of the vehicle, we exit the script and don't teleport. Also, always search the Scripting Commands page when using any unknown command (or the link above for Functions). Cheers. Edited April 10, 2020 by RCA3 4 1 Share this post Link to post Share on other sites
mzgr 8 Posted April 9, 2020 Well, it works like a charm! This is one big step towards completing the mission. Thank you very much man, oh and also thank you for the explanation, after i read it slowely few hundred more times maybe i will understand this magic 🙂 1 Share this post Link to post Share on other sites
mzgr 8 Posted May 15, 2020 Hello again, I need to change this last scipt to teleport into a car UAZ 3151 from RHS AFRF (rhs_uaz_vdv) instead of a quad. It was suggested to me to: Quote pass the "_args" variable to the function, the 3rd index needs to be the classname of the vehicle you want to teleport to However, this advice is not enough to help a person with my level of scripting knowledge. All my attempts so far have failed. So, RCA3 if you have the time to jump to the rescue once again that'd be awsome... Share this post Link to post Share on other sites
Harzach 2517 Posted May 15, 2020 Just follow the same format @RCA3 provided. Name your UAZ as you did your ATV (UAZ_ALPHA or whatever) then use that as your argument. 1 Share this post Link to post Share on other sites
mzgr 8 Posted May 15, 2020 ''Use that as your argument.'' I never wrote a script, so this is exactly what I need help on. Share this post Link to post Share on other sites
Harzach 2517 Posted May 15, 2020 https://community.bistudio.com/wiki/addAction Quote this addAction ["Teleport to ATV_Alpha", "teleportMHQbluefor.sqf", ATV_Alpha]; ATV_Alpha is the argument in your original addAction code. I'm assuming the UAZ is for REDFOR to spawn into? In that case, you would use this code in your REDFOR APC (again, making assumptions about the naming of objects and scripts): this addAction ["Teleport to UAZ_Alpha", "teleportMHQredfor.sqf", UAZ_Alpha]; Share this post Link to post Share on other sites
mzgr 8 Posted May 15, 2020 I dont think renaming is the problem. This script worked on ATV's, once I changed the ATV object type in attributes into UAZ, it stopped working. All variable names stayed the same Share this post Link to post Share on other sites
Harzach 2517 Posted May 15, 2020 Share all of your code, please, including variable names of the relevant objects. 1 Share this post Link to post Share on other sites
Harzach 2517 Posted May 15, 2020 I just put together a repro mission. On BLUFOR: one NATO rifleman one NATO Marshall with the init this addAction ["Teleport to ATV_Alpha", "teleportMHQ.sqf", ATV_Alpha]; one NATO ATV with variable name ATV_Alpha On OPFOR: one CSAT rifleman one CSAT Marid with the init this addAction ["Teleport to UAZ_Alpha", "teleportMHQ.sqf", UAZ_Alpha]; one MSV UAZ 3151 with variable name UAZ_Alpha ONE script named "teleportMHQ.sqf" containing @RCA3's script above. Works great. One thing I would change is adding a show condition to the addActions so that each side can't see the addAction on the opposing side's MHQ (though thanks to RCA3's script, it is not functional for the opposing side anyway). 1 Share this post Link to post Share on other sites
mzgr 8 Posted May 16, 2020 Hi, finnaly found the thing that was blocking the script, thank you very much for your help @Harzach Share this post Link to post Share on other sites