Jump to content
Sign in to follow this  
wld427

multiple guns error....

Recommended Posts

can anyone spot the error......

Quote[/b] ]

Error in expression <elect 1);

_b = nearestObject [_u, _this select 4];

if (((_ammo mod 2) == 0) and >

Error position: <select 4];

if (((_ammo mod 2) == 0) and >

Error Zero divisor

File PRACS_AB212\mg.sqf, line 4

Error in expression <elect 1);

_b = nearestObject [_u, _this select 4];

if (((_ammo mod 2) == 0) and >

Error position: <select 4];

if (((_ammo mod 2) == 0) and >

Error Zero divisor

File PRACS_AB212\mg.sqf, line 4

script...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

if (((_ammo mod 2) == 0) and (_b isKindOf "B_762x51_Ball")) then

{

_offset1 = [1,1.9,-1.2];

_wpos1 = _u modelToWorld _offset1;

_b setpos _wpos1

};

init line....

"[(_this select 0)] execVM ""\PRACS_AB212\mg.sqf""";

Edited by W0lle

Share this post


Link to post
Share on other sites

You shouldn't call that script from the init line. It should be called from the fired eventhandler. So it might look like this for example (init line in editor):

Quote[/b] ] this addEventHandler ["fired", {_this execVM  "\PRACS_AB212\mg.sqf"}]
Or add it in the vehicle config. I recommend to precompile the mg.sqf function into a global var as it's called very often (for every bullet fired), if you want it to work like swiss watch smile_o.gif Edited by W0lle

Share this post


Link to post
Share on other sites

Recommend always learn from others who have already got it working and open their addons.

Su33

- Config

Quote[/b] ]fired="[_this] execvm ""\rktsu33\scr\firemissilesMR.sqf""";
Quote[/b] ]_array = _this select 0;

_weapon = _array select 1;

_ammoname = _array select 4;

_plane = _array select 0;

// If it's just the gun, then dont run the script

if(_weapon != "GSh301") then

{

//------------------ Missile type 1 -------------------

if(_ammoname == "RKT_R27_AA") then

{

_alamcount = _plane ammo "RKTR27Launcher";

if (_alamcount == 1) then

{

_plane animate ["R27_1_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [-4.85,-2.579,0.571]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_alamcount == 0) then

{

_plane animate ["R27_2_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [4.85,-2.579,0.571]);

_missobj SetvectorUp (VectorUp _plane);

};

};

//------------------ Missile type 2 -------------------

if(_ammoname == "RKT_R73_AA") then

{

_archcount = _plane ammo "RKTR73Launcher";

if (_archcount == 1) then

{

_plane animate ["R73_1_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [-7.2,-3.88,0.832]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_archcount == 0) then

{

_plane animate ["R73_2_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [7.2,-3.88,0.832]);

_missobj SetvectorUp (VectorUp _plane);

};

};

//------------------ Missile type 3 -------------------

if(_ammoname == "RKT_Ch29_AT") then

{

_alamcount = _plane ammo "RKTCh29Launcher";

if (_alamcount == 1) then

{

_plane animate ["ch29_1_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [-3.298,-2.559,0.454]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_alamcount == 0) then

{

_plane animate ["ch29_2_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [3.298,-2.559,0.454]);

_missobj SetvectorUp (VectorUp _plane);

};

};

//------------------ Bomb type 1 -------------------

if(_ammoname == "Bo_kb500_LGB") then

{

_bombcount = _plane ammo "RKT_kb500Launcher";

if (_bombcount == 1) then

{

_plane animate ["kb5_1_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [0.0,-3.15,0.071]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_bombcount == 0) then

{

_plane animate ["kb5_2_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [0.0,0.25,0.071]);

_missobj SetvectorUp (VectorUp _plane);

};

};

//------------------ Bomb type 2 -------------------

if(_ammoname == "Bo_fb250_FFB") then

{

_bombcount = _plane ammo "RKT_fb250Launcher";

if (_bombcount == 3) then

{

_plane animate ["fb25_1_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [-6.419,-4.15,0.653]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_bombcount == 2) then

{

_plane animate ["fb25_2_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [-5.978,-4.15,0.653]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_bombcount == 1) then

{

_plane animate ["fb25_3_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [6.419,-4.15,0.653]);

_missobj SetvectorUp (VectorUp _plane);

};

if (_bombcount == 0) then

{

_plane animate ["fb25_4_Hide", 1];

_missobj = nearestobject[_plane, _ammoname];

_missobj SetPos (_plane ModelToWorld [5.978,-4.15,0.653]);

_missobj SetvectorUp (VectorUp _plane);

};

};

};

EDIT - Ignore me, I see you trying to relocate MG ammo

Edited by W0lle

Share this post


Link to post
Share on other sites
Gnat @ Mar. 21 2009,08:23)]
Quote[/b] ]fired="[_this] execvm ""\rktsu33\scr\firemissilesMR.sqf""";

Hi Gnat,

it's nothing big, but those brackets around _this are completely unnecessary:

Quote[/b] ]

fired="_this execvm ""\rktsu33\scr\firemissilesMR.sqf""";

Then you can write

Quote[/b] ]

_weapon = _this select 1;

_ammoname = _this select 4;

_plane = _this select 0;

...

in your script.

Eliminating unnecessary extra variables makes debugging and navigating code easier. smile_o.gif

Edited by W0lle

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  

×