PDA

View Full Version : Help


Fire_optikz001
29th December 2009, 18:19
i got a lil problem in my cruise insim

if a user has negative money it has ( $ ) around the money but when a user has +money its fine my code for it is


openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32,strFormat( "^7Cash: {0:C}",GetCurrentPlayerVar( "Cash" ) ) );

Heiko1
29th December 2009, 18:22
does the method is in byte or in int ?

byte goes from 0-255
int goes from -9999...-99999...

EDIT: what an dumb answer
maybe convert it to int32

Gai-Luron
29th December 2009, 19:57
Don't use currency in format

Fire_optikz001
29th December 2009, 20:35
Don't use currency in format
then how i do it diffrently

Lang?

Krayy
29th December 2009, 21:25
Th eproblem is that Lapper is hard coded to set the Globalization CultureInfo to en-US, so you are unable to use the currency formats if you do not want brackets around them. The best way would to be put an IF clause in to convert the negative to a positive and then print the negative sign:

$tmpCash = GetCurrentPlayerVar( "Cash" );
IF ( $tmpCash < 0 )
THEN
$tmpCash = $tmpCash - $tmpCash - $tmpCash; # This converts the number to a positive
openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32,strFormat( "^7Cash: {0:C}",$tmpCash ) );
ELSE
openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32,strFormat( "^7Cash: {0:C}",$tmpCash ) );
ENDIF


I had to do 3 minuses because for some odd reason, multiplying by -1 doesnt work.

Gai-Luron
29th December 2009, 21:37
round the values and add $, i don't know where is the problem and why the reason you use currency on format string

Fire_optikz001
29th December 2009, 22:00
round the values and add $, i don't know where is the problem and why the reason you use currency on format string
its for cash D: currency = cash D:

Fire_optikz001
29th December 2009, 22:01
Th eproblem is that Lapper is hard coded to set the Globalization CultureInfo to en-US, so you are unable to use the currency formats if you do not want brackets around them. The best way would to be put an IF clause in to convert the negative to a positive and then print the negative sign:

$tmpCash = GetCurrentPlayerVar( "Cash" );
IF ( $tmpCash < 0 )
THEN
$tmpCash = $tmpCash - $tmpCash - $tmpCash; # This converts the number to a positive
openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32,strFormat( "^7Cash: {0:C}",$tmpCash ) );
ELSE
openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32,strFormat( "^7Cash: {0:C}",$tmpCash ) );
ENDIF
I had to do 3 minuses because for some odd reason, multiplying by -1 doesnt work.
ye i relised that :)

Krayy
29th December 2009, 22:38
Even betterer:

...
openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32, "^7Cash: " . FormatCash( GetCurrentPlayerVar( "Cash" ) ) );
...

Sub FormatCash ( $tmpCash )
IF ( ToNum($tmpCash) < 0 )
THEN
$tmpCash = -$tmpCash; # This converts the number to a positive
return ( "-" . strFormat( "{0:C}",$tmpCash ));
ELSE
return ( strFormat( "{0:C}",$tmpCash ) );
ENDIF
EndSub

Fire_optikz001
29th December 2009, 23:20
Even betterer:

...
openPrivButton( "Cruise_HUD_Cash",2,140,20,5,12,-1,32, "^7Cash: " . FormatCash( GetCurrentPlayerVar( "Cash" ) ) );
...

Sub FormatCash ( $tmpCash )
IF ( ToNum($tmpCash) < 0 )
THEN
$tmpCash = -$tmpCash; # This converts the number to a positive
return ( "-" . strFormat( "{0:C}",$tmpCash ));
ELSE
return ( strFormat( "{0:C}",$tmpCash ) );
ENDIF
EndSub

works like a charm :D ty

Krayy
29th December 2009, 23:43
works like a charm :D ty
That'll be $30 thanks...PM me for my PayPal account :thumb: