Jump to content
Sign in to follow this  
slimnala

Trouble with config

Recommended Posts

hello all,

I am have trouble with a condition and need a little help.

It seems to only work for the server.....any suggestions..

this action is under the addon and in it's own .pbo

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

{

class RELOAD

{

displayName ="Reload Magazine";

position = "pos r";

radius =3;

onlyForplayer= false;

condition = "(count nearestObjects [this,[""UralReammo"",""Truck5tReammo""],10] != 0 ) && (not (someAmmo this))";

statement = "this addmagazine ""4Rnd_AA_Brdm2""";

};

};

any suggestions are appreciated

thnx

slimnala

Share this post


Link to post
Share on other sites

In OFP. If you try and add ammo to a vehicle that is not local to the Players client i.e Either the player or a unit in the players group, is not in the drivers position. Then the server will reset the ammo count, to the amount in the vehicle local to the server. Err if that makes sense?

In other words, for vehicles local to the server, it seems to broadcast the ammount of ammo every 2 or 3 seconds to all the clients. So if a client adds some ammo, after a couple of seconds the server will over write the ammo count.

This had me stumped for quite a while in OFP. I would add ammo then immediatley do a check to confirm the ammo was added. Only to find it removed again after a couple of seconds. Perhaps Arma does it the same way? You should be able to prove this by sitting in the vehicles drivers position when you activate your reload action. If I'm correct, you should be able to reload the vehicle.

But to be honest, I don't think this is the best method to use. The nearest commands can be very laggy when executed in action conditions.  If you think about it, whenever you have two units\vehicles within 3 meters (although a 3 meter radius seems quite small?) of each other, the condition will be called something like every 0.4 seconds (perhaps even quicker).

I would do it this way:

Build a global array in your missions init script, of all the ammo trucks in your mission. Lets call it SLI_AMMOTRUCKARRAY.

Then write a function SLI_AddAmmo.sqf to check the distance. Compile and pre-process that in your init.sqf to. So your init.sqf would look like this:

Init.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">SLI_AMMOTRUCKARRAY=[AmmoTruck01,AmmoTruck02,AmmoTruck03,AmmoTruck04];

SLI_AddAmmo=Complile PreProcessFile "SLI_AddAmmo.sqf";

SLI_AddAmmo.sqf:

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

_Result=False;

If (Local _Vehicle) Then

     {

     If !(SomeAmmo _Vehicle) Then

           {

           _Count=Count SLI_AMMOTRUCKARRAY;

           For [{_Counter=0},{_Counter<_Count},{_Counter=_Counter+1}]

                 {

                 _AmmoTruck=SLI_AMMOTRUCKARRAY Select _Counter;

                 If ((_Vehicle Distance _AmmoTruck)<=10) Then

                       {

                       _Result=True;

                       _Counter=_Count;

                       };

                 };

           };

     };

_Result

Your action condition would be:

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

{

displayName ="Reload Magazine";

position = "pos r";

radius =3;

onlyForplayer= false;

condition = "[This] Call SLI_AddAmmo";

statement = "this addmagazine ""4Rnd_AA_Brdm2""";

};

Now the above function should first check to see if the vehicle is local, if it's not it will exit.

If it is local then it will check to see if it has some ammo, if does it will exit.

If it's about to run out of ammo it will check for the proximity of an ammo truck.

One thing to remember about conditions is, it will check the entire line of code. So even if it fails your first && condition it will still check all the others. Things might have changed in Arma from OFP, I don't know off hand. But if you create nested if statements, then you know the check will stop as soon as it hits a false condition.

Like I said 3 meters is such a small radius, nearestobjects might not be to laggy. But my method will account for MP locality. Anyway, something think about smile_o.gif

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  

×