Jump to content
Sign in to follow this  
FAR-Warrior

Script help

Recommended Posts

How to list all weapons and magazines for all players in mp missions confused.gif

With command "magazines player" and "weapons player", it's ok, but when there're 4 M16 mag for exemple, i have "M16mag","M16mag","M16mag","M16mag" and i'd like to have "4 - M16mag".

And i'd like to have the player name before each player's list...

It's for MP missions...

Txs...

Share this post


Link to post
Share on other sites

It is pretty straightforward I think you could use something like:

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

_mag = magazines bob

_weapons = weapons bob

_nummag = count _mag

hint format ["Bob has %1 with %2 magazines", _weapons, _nummag]

<span id='postcolor'>

This hasn't been tested so it may not work.

RED

Share this post


Link to post
Share on other sites

It works (kind of) but you will need to play around with it.

RED

Share this post


Link to post
Share on other sites

?Player hasweapon "M16":Weapon="M16"

?Player hasweapon "AK74":Weapon="AK74"

?Player hasweapon "M60":Weapon="M60"

?Player hasweapon "PK":Weapon="PK"

~1

hint format ["%1",Weapon]

Make it activated by radio alpha or something so U can see that its working, I dunno if U can check for magazines.

Share this post


Link to post
Share on other sites

Yeah that is the best way for getting the weapons, but when you count the magazines it gets harder, maybe the game counts all magazines the unit has (ie weapon ammo and grenades)

Infact I am pretty sure that happens.

RED

Share this post


Link to post
Share on other sites

Yes, all Magazines like Grenades, Handgunmagazines a.s.o. are listed with magazines!

You have the scan the magazine-array for unique Magazinnames and then count them, like that

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

_mags = []

_magCount = []

_magazines = magazines player

#loop

_mag = magazines select 0

_mags = _mags + [_mag]

_comp = format ["_x == ""%1""", _mag]

_count = _comp count _magazines

_magCount = _magCount + [_count]

_magazines = _magazines - [_mag]

?count _magazines > 0: goto "loop"

<span id='postcolor'>

So, now you have in this arrays listed:

_mags : All magazines just one time

_magCount : corresponding magazine count

Now you can put out this arrays with

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

_text = "Magazines:\n\n";

_i = (count _mags) - 1

#loop2

_text = _text + format ["%1 X %2\n", _magCount select _i, _mags select _i]

_i = _i - 1

?_i >= 0: goto "loop2"

hint _text

<span id='postcolor'>

Weapons is easier, as there won't be any duplicated items like in magazines!

Share this post


Link to post
Share on other sites

This script work fine, thx

How to use this script for all units of a group in mp ??

I try to do :

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_magazines1 = magazines bob

_magazines2 = magazines bob1

_magazines3 = magazines bob2

_magazines = _magazines1 + _magazines2 + _magazines3<span id='postcolor'>

It works fine but if i have only two players, i have <Null> instead of number of mags sad.gif

And if a player is dead, mags are always in list, and i'd like to have only mags of alives players...

Share this post


Link to post
Share on other sites

Don't know if it will work, but try to init your variables in init.sqs or at the beginning of the script, if they are local, to empty lists :

_magazine1=[]

_magazine2=[]

_magazine3=[]

I don't know if the <Null> returned by the magazines function will override the empty list, but u can give it a try, it couls resolve your <Null> problem...

For the dead players part... hmmmmm ... Tough one...

Share this post


Link to post
Share on other sites

An assumption :

- You need this list "on the fly" during the mission, eg when leader asks his men for remaining weapons and munitions.

Why not calling the script when you need it, and publicVariable the result (which seems to be a string) each time, so that the list is updated when player is dead?

BTW, another way to get rid of the <Null> problem could be :

_magazine1=[]

_magazine2=[]

_magazine3=[]

?(bob1 != objNull):_magazine1=magazines bob1

?(bob2 != objNull):_magazine2=magazines bob2

?(bob3 != objNull):_magazine3=magazines bob3

_magazines=_magazine1 + _magazine2 + _magazine3

Whis'

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">It works fine but if i have only two players, i have <Null> instead of number of mags <span id='postcolor'>

It works

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">And if a player is dead, mags are always in list, and i'd like to have only mags of alives players...

<span id='postcolor'>

Dont work sad.gif When a player's dead, his mags always count sad.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  

×