PDA

View Full Version : String to integer



Jeplaa
24th February 2014, 10:38
Hey,
Is it possible to convert string to integer in CoD2 using stock functions ?

Here is example using Java, hope it is similar in CoD2.


String string = "1234";
int num = Integer.parseInt(string);

Thanks in advance,
Jeplaa

Mitch
24th February 2014, 11:06
Hey,
Is it possible to convert string to integer in CoD2 using stock functions ?

Here is example using Java, hope it is similar in CoD2.


String string = "1234";
int num = Integer.parseInt(string);

Thanks in advance,
Jeplaa

http://znation.nl/cod4script/int.htm



Int( <value> )
Module: Math

Summary:
Casts a floating point number or a string to an integer

Example:
x = Int( self.HUDHealthHeight );

Required Args:
1 : <value> A string or floating point number to cast to an integer

Tally
24th February 2014, 11:40
Hey,
Is it possible to convert string to integer in CoD2 using stock functions ?

Here is example using Java, hope it is similar in CoD2.


String string = "1234";
int num = Integer.parseInt(string);

Thanks in advance,
Jeplaa

yeah, there has been a stock function since the very first COD:


int( string );

FYI - the function in COD1 and UO took this form:


(int)( string);

Jeplaa
24th February 2014, 11:58
Ohh got it, tried this function but made fault in code :)