Home   Help Search Login Register  

Author Topic: show values aboce 999999  (Read 667 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
show values aboce 999999
« on: 12 Apr 2004, 05:09:12 »
as most of you knows, OFP shows 7 digit numbers or above as a math shortcut (like: 2.5e+006).

Problem is, i want OFP to show numbers of 1 million or above as real number (i.e. 1'000'000)

If anyone knows how to force OFP to do this, please reply

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:show values aboce 999999
« Reply #1 on: 12 Apr 2004, 14:24:41 »
explain exactly what you're trying to do in more detail

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:show values aboce 999999
« Reply #2 on: 12 Apr 2004, 20:20:57 »
well, the map i'm making, is some sort of a RPG...so you can earn money, buy things and so on.
So i have a script for each playable loon, which contains several Info's, like amount of money he has, if he got a driving license and some more.
The problem now is, if the player as more than $999'999, the hint message does show the money in this way (i.e. $1'500'000): $1.5e+006. I think this is the mathematic correct way how such large numbers can be shown, but i want it shown in real numbers.

m21man

  • Guest
Re:show values aboce 999999
« Reply #3 on: 12 Apr 2004, 20:39:49 »
Syntax not guaranteed:
Code: [Select]
?(_money < 1000000): exit
_newmoney = _money / 1000000
hint format ["You have %1 Million Dollars",_newmoney]
exit
« Last Edit: 12 Apr 2004, 20:40:21 by m21man »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:show values aboce 999999
« Reply #4 on: 12 Apr 2004, 20:45:57 »
should have done this at the beginning...here's the script i'm talking about:

;showstatistics.sqs

_name = name civ0
?(civ0bike == 0): _bike = "No"
?(civ0bike == 1): _bike = "Yes"
?(civ0car == 0): _car = "No"
?(civ0car == 1): _car = "Yes"
?(civ0air == 0): _air = "No"
?(civ0air == 1): _air = "Yes"
?(civ0hand == 0): _hand = "No"
?(civ0hand == 1): _hand = "Yes"
?(civ0gun == 0): _gun = "No"
?(civ0gun == 1): _gun = "Yes"
?(civ0auto == 0): _auto = "No"
?(civ0auto == 1): _auto = "Yes"
?(civ0mafia == 0): _mafia = "No"
?(civ0mafia == 1): _mafia = "Yes"
?(civ0wanted == 0): _wanted = "No"
?(civ0wanted == 1): _wanted = "Yes"

?(civ0mafia == 1): _money = mafiamoney
?(civ0mafia == 0): _money = civ0money

_msg = Format["%1 Statistics:\n\nMoney: %2\n\nDriving Licenses\n\nBike: %3\nCar: %4\nAir: %5\n\nWeapon Licenses\n\nHandguns: %6\nRifles: %7\nHeavy Weapons: %8\n\nOthers\n\nMafia Member: %9\nWanted: %10", _name, _money, _bike, _car, _air, _hand, _gun, _auto, _mafia, _wanted]
hint _msg
exit


:edit:
m21man, this would work if i had only values 1'000'000 or 2'000'000...but what would i get with 1'112'350 ?
« Last Edit: 12 Apr 2004, 20:57:42 by myke13021 »

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:show values aboce 999999
« Reply #5 on: 13 Apr 2004, 00:51:41 »
off the top of my head, i guess you could create a function that gradually subtracted from each place of the number (recording how many times its subtracted) and then formatting the data into a string (idk if what im saying makes sense to you, so ill show u)

say u have:

money = 1,112,350

the function could start subtracting the ten millions place:

_money = money
_tenmillionsplace = 0
_millionsplace = 0
etc...

#tenmillionsplace
(_money - 10000000 >= 0) : _tenmillionsplace = _tenmillionsplace + 1; _money = _money - 10000000; goto "tenmillionsplace"

#millionsplace
(_money - 1000000 >= 0) : _millionsplace = _millionsplace + 1; _money = _money - 1000000; goto "millionsplace"

etc...

then when you got _money to be 0, you could format the number:

moneystring = format ["$%1%2,%3%4%5,%6%7%8", _tenmillionsplace, _millionsplace, _hundredthousandsplace, _tenthousandsplace, etc]

where the %1 would be equal to 0,
%2 = 1
%3 = 1
%4 = 1
%5 = 2
%6 = 3
%7 = 5
%8 = 0

then the variable moneystring would be equal to the string "$01,112,350"





this is just a basic idea that popped into my head, it may or may not work :P
« Last Edit: 13 Apr 2004, 00:52:51 by .pablo. »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:show values aboce 999999
« Reply #6 on: 13 Apr 2004, 02:03:24 »
well, god damn pablo...a really good way to get what i need....only with one little problem:

I have no clue about functions....so i've started reading snYpir's tutorials about and now i can proudly say:

I have no clue about functions or how writing them  ;D

As far i understand snYpirs tut's, writing function is something similar to writing app's in C....and writing scripts is something similar to BASIC.

Well, as the old Tard i am, i can remember the good old times with my C16 (downsized C64) and the little BASIC progs i wrote on it. So i can take some of my rusty knowledge when writing scripts, but i'm absolutely lost when it goes to something more complex.

So, if someone could write me such a function and lead me through how i do implement this into my scripts....hay this would be a real big help.

FantasyChrono

  • Guest
Re:show values aboce 999999
« Reply #7 on: 13 Apr 2004, 03:08:08 »
I would suggest doing continous divison by 10 (and taking remainders), which would give the digits in reverse order. However, you would be able to do it nicely w/ one loop.

Coded in C++ (I don't know OFP scripting that well, but it should be comparable)

int money = _money; // money value
const int ARR_MAX = 20; // Declare maximum stack size
int digits[ARR_MAX];
int big_digit=0;
for(big_digit=0; money; big_digit++){
    digits[big_digit] = money%10;
    money /= 10;
}
if(big_digit == 0)
    cout << "0"; // takes care of case where money = 0
for(int i=big_digit-1; i>=0; i--)
    cout << digits; // all other cases
cout << endl; // flush output, new line

Programmers would recognize the digits array is a stack with the implementation implicit in my code. The size of 20 is arbitrary (you can put any # greater than or equal to the number of digits you want to handle -- 20 is way bigger than any number you will be working with).

On a side note, does anyone know of a tutorial that teaches scripting in terms of a standard OOP, for example C++?
« Last Edit: 13 Apr 2004, 03:17:13 by FantasyChrono »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:show values aboce 999999
« Reply #8 on: 13 Apr 2004, 03:29:58 »
FantasyChrono...you made it...you confused me to eternety.

As i'm sure the code you wrote is absolutely brilliant, i have no clue what i should do with.
As i said above, i'm becoming better in scripting .sqs, but about the rest i'm a little lost.

So, if someone could take me to the hand and lead me through (plz explain it to me, as you would explain it to a 5 year old  ;D ) i might be able to reproduce it...but i'm affraid, i think i'll never understand it.

with all due respect to pablo and FantasyChrono....i'm absolutely sure they showed a perfect way to solve this prob...and i'm just too dumb to understand it.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:show values aboce 999999
« Reply #9 on: 14 Apr 2004, 23:19:02 »
so is there a way which i could use to force OFP to show values above 999999 in real numbers? ???

The answers i got till now are surely good, but not very useful for me (maybe i'm too noob for this).
any help which includes scripting .sqs files, description.ext would help.

If it is only doable by writing functions, i'm affraid this is too advanced for me.   :(

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:show values aboce 999999
« Reply #10 on: 14 Apr 2004, 23:54:54 »
I just knocked this together, although I haven't tested it yet.
It presumes that _money contains a valid number already.


_tenmill = 0
_mill =0

#10

? _money >= 10000000 : _tenmill = tenmill +1
_money = _money - 10000000
? _money < 10000000 : goto "1"
goto "10"

#1

? _money >= 1000000 : _mill = _mill +1
_money = _money - 1000000
? _money < 1000000 : goto "there"
goto "1"

#there

? _tenmill > 0 : hint format ["Money = %1%2,%3", _tenmill, _mill, _money]; goto exit

? _mill > 0 : hint format ["Money = %1,%2", _mill, _money]; goto exit

hint format ["Money = %1", _money]

exit


Anyway, play about with it, but check the syntax first.


Planck
« Last Edit: 15 Apr 2004, 01:29:42 by Planck »
I know a little about a lot, and a lot about a little.