Jump to content
Sign in to follow this  
Oleg-Russia

Need help with filling truck with ammo

Recommended Posts

Hi everyone

I do have a problem.

1)I`ve a truck

http://img146.imageshack.us/i/50989925.jpg/

2)I`ve loaded it with ammo that i need:

http://img146.imageshack.us/i/86704253.jpg/

3)by adding this into the truck init:

http://img15.imageshack.us/i/20823603.jpg/

4)using this script "truck_ammo_1.sqf":

#include "x_setup.sqf"

_vec = _this select 0;
waitUntil {X_Init};
clearMagazineCargo _vec;
clearWeaponCargo _vec;

_vec addweaponcargo ["AK_107_GL_pso",2];
_vec addmagazinecargo ["30Rnd_545x39_AK",24];
_vec addweaponcargo ["VSS_vintorez",2];
_vec addmagazinecargo ["20Rnd_9x39_SP5_VSS",24];
_vec addweaponcargo ["KSVK",2];
_vec addmagazinecargo ["5Rnd_127x108_KSVK",6];	
_vec addweaponcargo ["Igla",2];
_vec addmagazinecargo ["Igla",25];
_vec addweaponcargo ["JAVELIN",2];
_vec addmagazinecargo ["JAVELIN",25];
_vec addweaponcargo ["MetisLauncher",2];
_vec addmagazinecargo ["AT13",25];
_vec addweaponcargo ["RPG7V",2];
_vec addmagazinecargo ["PG7VR",3];
_vec addmagazinecargo ["HandGrenade_East",10];
_vec addmagazinecargo ["Pipebomb",25];
_vec addmagazinecargo ["SmokeShellRed",3];
_vec addmagazinecargo ["SmokeShell",3];
_vec addmagazinecargo ["10Rnd_762x54_SVD",10];
_vec addmagazinecargo ["1Rnd_HE_GP25",8];
_vec addmagazinecargo ["FlareRed_GP25",3];
_vec addweaponcargo ["Laserdesignator",1];
_vec addmagazinecargo ["Laserbatteries",6];

4)Here i blow my truck up :

http://img20.imageshack.us/i/10705123.jpg/

5)After the truck has been respawned i get this ammo load

http://img146.imageshack.us/i/22186333.jpg/

Is there any way to get this truck respawned with an ammo i need? And if yes,what do i need to add into a script?

And the second quastion i`m modding Domination 1.04 ,but is there any way to switch off time reset,because each time i rejoin the server time of the mission drops to it`s begin as setted server config.Like i join tghe server mission time is 05:00 ,few hours later 11:00 i disconnect and join again the same server ,mission tikme drops back to 05:00 and not to 11:00.How do i change it?

Thanks

Edited by Oleg-Russia

Share this post


Link to post
Share on other sites

I assume this is for mp missions if you're respawning, and I only do single player, but a repeating trigger with the condition alive truck and then exec the script in the activation field?

Share this post


Link to post
Share on other sites

You could use an eventhandler. May need to modify but this is an example one you would put at the end of your script. Now this is for a player, but you could use vehicle variable.

if ( isNil{player getVariable "mk_killedEHadded"} ) then 
{
player addEventHandler ["killed", 
{ 
	[] spawn {
		waitUntil { alive player }; // waitUntil player has respawned
		execVM "ammo.sqf"; 
	};	
}];
player setVariable ["mk_killedEHadded", true];
};

Share this post


Link to post
Share on other sites

I have tried all kind of combinations here is one of them but it doesn`t work for me :(

#include "x_setup.sqf"

_vec = _this select 0;
waitUntil {X_Init};
clearMagazineCargo _vec;
clearWeaponCargo _vec;

_vec addweaponcargo ["AK_107_GL_pso",2];
_vec addmagazinecargo ["30Rnd_545x39_AK",24];
_vec addweaponcargo ["VSS_vintorez",2];
_vec addmagazinecargo ["20Rnd_9x39_SP5_VSS",24];
_vec addweaponcargo ["KSVK",2];
_vec addmagazinecargo ["5Rnd_127x108_KSVK",6];	
_vec addweaponcargo ["Igla",2];
_vec addmagazinecargo ["Igla",25];
_vec addweaponcargo ["JAVELIN",2];
_vec addmagazinecargo ["JAVELIN",25];
_vec addweaponcargo ["MetisLauncher",2];
_vec addmagazinecargo ["AT13",25];
_vec addweaponcargo ["RPG7V",2];
_vec addmagazinecargo ["PG7VR",3];
_vec addmagazinecargo ["HandGrenade_East",10];
_vec addmagazinecargo ["Pipebomb",25];
_vec addmagazinecargo ["SmokeShellRed",3];
_vec addmagazinecargo ["SmokeShell",3];
_vec addmagazinecargo ["10Rnd_762x54_SVD",10];
_vec addmagazinecargo ["1Rnd_HE_GP25",8];
_vec addmagazinecargo ["FlareRed_GP25",3];
_vec addweaponcargo ["Laserdesignator",1];
_vec addmagazinecargo ["Laserbatteries",6];

if ( isNil{_vec getVariable "mk_killedEHadded"} ) then 
{
_vec addEventHandler ["killed", 
{ 
	[] spawn {
		waitUntil { alive _vec }; // waitUntil _vec has respawned
		execVM "truck_ammo_1.sqf"; 
	};	
}];
_vec setVariable ["mk_killedEHadded", true]; 

Getting really tired of it, have spend days and nothing helps.

Share this post


Link to post
Share on other sites

How are you respawning the vehicle? Since you'd probably have to put the refill script stuff in that process to have it take.

Share this post


Link to post
Share on other sites

I do not know how it spawns and what settings it use,probably all it`s in some script of mission "domination 1.04 east revive" there is absolutely no command in init window box of the truck ,i`ve tried to find this spawn script ,but still have no result same as i can`t find an option to switch off time reset,so if you rejoin the server mission time is reseting back to the basic 05:00 or something like that.

Share this post


Link to post
Share on other sites

I just tested this and it works.

Below is the vehicle respawn script that I use:

/*  
=========================================================
 Simple Vehicle Respawn Script v1.6
 by Tophe of Östgöta Ops [OOPS]

 Put this in the vehicles init line:
 veh = [this] execVM "vehicle.sqf"


 Options:
 There are some optional settings. The format for these are:
 veh = [this, Delay, Deserted timer, Respawns, Effect, Static] execVM "vehicle.sqf"


 Default respawn delay is 30 seconds, to set a custom
 respawn delay time, put that in the init as well. 
 Like this:
 veh = [this, 15] execVM "vehicle.sqf"

 Default respawn time when vehicle is deserted, but not
 destroyed is 120 seconds. To set a custom timer for this 
 first put the respawn delay, then the deserted vehicle timer-
 Like this:  
 veh = [this, 15, 10] execVM "vehicle.sqf"

 By default the number of respawns is infinite. To set a limit
 First set the other values then the number of respawns you want (0 = infinite).
 Like this:
 veh = [this, 15, 10, 5] execVM "vehicle.sqf"


 Set this value to TRUE to add a special explosion effect to the wreck when respawning.
 Default value is FALSE, which will simply have the wreck disappear.
 Like this:
 veh = [this, 15, 10, 5, TRUE] execVM "vehicle.sqf"

 By default the vehicle will respawn to the point where it first
 was when the mission started (static). This can be changed to 
 dynamic. Then the vehicle will respawn to the position where it was destroyed. 
 First set all the other values then set TRUE for dynamic or FALSE for static.
 Like this:
 veh = [this, 15, 10, 5, TRUE, TRUE] execVM "vehicle.sqf"

 If you you want to set the INIT field of the respawned vehicle, first set all other 
 values, then set init commands. Those must be inside quotations.
 Like this:
 veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

 Default values of all settings are:
 veh = [this, 30, 120, 0, FALSE, FALSE] execVM "vehicle.sqf"




Contact & Bugreport: harlechin@hotmail.com

=========================================================
*/

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do 
{	
sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 
{
	_timeout = time + _deserted;
	sleep 0.1;
 	waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
	if ({alive _x} count crew _unit > 0) then {_dead = false}; 
	if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true}; 
	if !(alive _unit) then {_dead = true; _nodelay = false}; 
};


// Respawn vehicle
     if (_dead) then 
{	
	if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
	if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
	if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
	sleep 0.1;

	deleteVehicle _unit;
	sleep 2;
	_unit = _type createVehicle _position;
	_unit setPosASL _position;
	_unit setDir _dir;

	if (_haveinit) then 
				{_unit setVehicleInit format ["%1;", _unitinit];
				processInitCommands;};
	if (_hasname) then 
				{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
				processInitCommands;};
	_dead = false;

	// Check respawn amount
	if !(_noend) then {_rounds = _rounds + 1};
	if ((_rounds == _respawns) and !(_noend)) then {_run = false;};

_unit execvm "truckammo.sqf";
};
};

In the very last line you will see _unit execvm "truckammo.sqf" this would be your ammo script and will make it respawn with the truck.

Below is the ammo script that you will need to use I named it truckammo.sqf:

while {alive _this} do
{
clearweaponcargo _this;
clearmagazinecargo _this;

_this addweaponcargo ["AK_107_GL_pso",2];
_this addmagazinecargo ["30Rnd_545x39_AK",24];
_this addweaponcargo ["VSS_vintorez",2];
_this addmagazinecargo ["20Rnd_9x39_SP5_VSS",24];
_this addweaponcargo ["KSVK",2];
_this addmagazinecargo ["5Rnd_127x108_KSVK",6];	
_this addweaponcargo ["Igla",2];
_this addmagazinecargo ["Igla",25];
_this addweaponcargo ["JAVELIN",2];
_this addmagazinecargo ["JAVELIN",25];
_this addweaponcargo ["MetisLauncher",2];
_this addmagazinecargo ["AT13",25];
_this addweaponcargo ["RPG7V",2];
_this addmagazinecargo ["PG7VR",3];
_this addmagazinecargo ["HandGrenade_East",10];
_this addmagazinecargo ["Pipebomb",25];
_this addmagazinecargo ["SmokeShellRed",3];
_this addmagazinecargo ["SmokeShell",3];
_this addmagazinecargo ["10Rnd_762x54_SVD",10];
_this addmagazinecargo ["1Rnd_HE_GP25",8];
_this addmagazinecargo ["FlareRed_GP25",3];
_this addweaponcargo ["Laserdesignator",1];
_this addmagazinecargo ["Laserbatteries",6];



sleep 1800;
};

put this into the init line of your vehicle

veh = [this, 120, 180, 0, TRUE, FALSE] execVM "scripts\vehicle.sqf"; null0 = this execvm "scripts\truckammo.sqf"

Also there are respawn options that you can use as well just read the top script.

Let me know if you have any problems with the above info :D

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Dude, I found this amazing script...

Download this http://www.armaholic.com/page.php?id=5843

follow instructions and stick this code in the init field of an ammo crate or vehicle...

null0 = this execVM "ammo.sqf"

And voilá every weapon and item, very sweet! :D:yay:

Share this post


Link to post
Share on other sites

@Terra

That is the one I posted in the previous page.

@Oleg

Sorry man cant help you there Im still learning myself.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×