mia389 10 Posted July 10, 2010 I have this in a object init line nul = [this] execVM "repair.sqf" Is there anyway I can have this run for only units named alpha_1 bravo_1 charlie_1 Would I have to run this inside the script? repair.sqf if (!isServer) exitWith {}; _unit = _this select 0; _delay = if (count _this > 1) then {_this select 1} else {10}; _damage = if (count _this > 2) then {_this select 2} else {0}; _times = if (count _this > 3) then {_this select 3} else {0}; _noend = true; _run = true; _rounds = 0; if (_delay < 0) then {_delay = 0}; if (_damage < 0) then {_damage = 0}; if (_times == 0) then {_noend = true;} else {_noend = false;}; if (_times < 0) then {_times = 0; _noend = true;}; while {_run} do { waitUntil {getDammage _unit > _damage}; sleep _delay; _unit setDamage 0; if !(_noend) then {_rounds = _rounds + 1}; if ((_rounds == _times) and !(_noend)) then {_run = false;}; }; Share this post Link to post Share on other sites
shuko 59 Posted July 10, 2010 Dumb question, why not only add that to the init field of those three units? Share this post Link to post Share on other sites
KC Grimes 79 Posted July 10, 2010 Dumb question, why not only add that to the init field of those three units? Other than the dumb question comment, I agree with this. But, mia could be trying to do something else with this. It looks like you want this done at mission start, right? Share this post Link to post Share on other sites
CarlGustaffa 4 Posted July 10, 2010 Execute script for all local players, then just verify that the player is allowed to run parts of it. Chances are high that you might want to expand this idea of having other players run "other scripts". This way you can include everything in a single script, same for all, but everyone can still be unique. See x_setupplayer.sqf in Domination for more on what I mean: All players run the script, but only fractions of it. Share this post Link to post Share on other sites
mia389 10 Posted July 10, 2010 Oh, I thought this script had to go into the vehicle init. I try putting it in player init. Share this post Link to post Share on other sites
shuko 59 Posted July 10, 2010 player/playable and all other men are "vehicles" to the game engine. Share this post Link to post Share on other sites
mia389 10 Posted July 10, 2010 Ya putting it in the units init did nothing. I have already tried to grab it from domination but I get lost with the X_func part of the script in playersetup. That is way over my head. ---------- Post added at 11:52 PM ---------- Previous post was at 11:44 PM ---------- By bad guys, I am trying different repair scripts and the one above was the wrong one. This is the one I am trying use I put this in vehicle init: _repair = this addAction ["Repair", "repair.sqf"]; Repair.sqf _unit = _this select 0; _delay = 115; //time for repair animation _player = _this select 1; _damage = 0; if(getDammage _unit > _damage) then { hint "Repairing,This will take about 2 mins."; _unit setVehicleLock "LOCKED"; player switchMove "RepairingKneel"; sleep _delay; player switchMove "AmovPercMstpSrasWrflDnon"; hint "Complete"; _unit setVehicleLock "UNLOCKED"; _unit setDamage 0; } else { hint "Not dammaged"; }; When I put the code into players init, it says no damage when I try to fix a vehicle. I am guessing the script is running on the unit its in. Share this post Link to post Share on other sites
Muzzleflash 111 Posted July 10, 2010 _this select 0 in a addAction script refers to the object you attached the action to. If you put _repair = this addAction ["Repair", "repair.sqf"]; in a player's init, the script will attempt to "repair" the player. You have to add the action on vehicle. Something like this in the init of the player: nul = { _x addAction ["Repair", "repair.sqf"]; } forEach [alpha_1, bravo_1, charlie_1]; While player and _player in most likely all situations are the same you might want for clarity to replace the "player" inside the if-statement to "_player". Share this post Link to post Share on other sites
mia389 10 Posted July 11, 2010 @ Muzzleflash Im a bit confused. I need to put this in the init of players alpha_1, bravo_1 and charlie_1 nul = { _x addAction ["Repair", "repair.sqf"]; } forEach [alpha_1, bravo_1, charlie_1]; and change the script to this _unit = _this select 0; _delay = 115; //time for repair animation _player = _this select 1; _damage = 0; if(getDammage _unit > _damage) then { hint "Repairing,This will take about 2 mins."; _unit setVehicleLock "LOCKED"; _player switchMove "RepairingKneel"; sleep _delay; _player switchMove "AmovPercMstpSrasWrflDnon"; hint "Complete"; _unit setVehicleLock "UNLOCKED"; _unit setDamage 0; } else { hint "Not dammaged"; }; Won't the script try to repair the player? Share this post Link to post Share on other sites
Muzzleflash 111 Posted July 11, 2010 Oh my mistake, thought alpha_1 and so on was the vehicles. You should do this on the each player alpha_1 and so on: nul = { _x addAction ["Repair", "repair.sqf"]; } forEach [vehicle_1, vehicle_2, vehicle_3]; Where vehicle_1 for example is one of the repairable vehicles. Share this post Link to post Share on other sites
mia389 10 Posted July 11, 2010 You rock! that sounds like it will work. TY sir! Will give it a try Share this post Link to post Share on other sites
shuko 59 Posted July 11, 2010 I put this in vehicle init: _repair = this addAction ["Repair", "repair.sqf"]; Using the last parameter of addAction, you can specify who can see the action: _repair = this addAction ["Repair", "repair.sqf",[],1,false,true,"","_this in [alpha_1,bravo_1,charlie_1]"]; Share this post Link to post Share on other sites
mia389 10 Posted July 11, 2010 Nice shk, now I don't have to name every vehicle. Share this post Link to post Share on other sites