Jump to content
Sign in to follow this  
shlomo

STRINGTABLE.String manipulations / Format ["%1.1"]

Recommended Posts

Hi.

Is it possible to do some string manipulation in OFP ?  rock.gif

Lets say I want to use just the player ID within his group (1-12) .

When I use format["1",player] -> West Alpha Bravo :5 (shy)

But I want to use only the "5".

I've looked everywhere but havn't found a solution. crazy_o.gif

However when I looked at the STRINGTABLE.CSV file I found

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> OH NO.... %1.1... IS DOWN!

In the game we gets "OH NO.... 5... IS DOWN!"

So it seems there is some ability to do there.  smile_o.gif

Thx.

Share this post


Link to post
Share on other sites

My solution is to compare the group name with the group name plus a colon and a number. This solution is a bit expensive but works good.

Here is an example of how I figure out the AI numbers for the player group and add some info about them to a list box in my crCTI:

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

_units = units player

_units = _units - [player]

_texts = []

_index = 0

_indexAI = 2

{ while " format[""%1:%2"", playerGroup, _indexAI] != format[""%1"", _x] && _indexAI < 13" do { _indexAI=_indexAI+1 }; _texts set [_index, format["%1%2%3%4", [_indexAI, _x] select (_indexAI==13), ["", ",In Vehicle"] select (_x != vehicle _x), [",No Legs", ""] select (canStand _x), ["", ",Bad Aim"] select (handsHit _x)] ]; _index=_index+1 } foreach _units

lbClear IDC_LB_UNITS

{ lbAdd [IDC_LB_UNITS, _x] } foreach _texts

This script only works for local units. If the unit is not local u should compare to a different string, see below.

group: WEST Alpha Black

local unit: WEST Alpha Black:2

not local unit: WEST Alpha Black:2 REMOTE

Share this post


Link to post
Share on other sites

Thx. cleanrock . smile_o.gif

However As I wrote, this was just an example.

I'm looking for a generic solution - something like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> substring("bla bla",1) ,or charAt(i) which helps a lot in programming .

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  

×