Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 96 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: string to int
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 12:19 pm
is there a command to get a string to be an int?
example:

howdy = "howdyho";
inthowdy = howdy;

ofc that wont work because howdy isnt an int, does anyone know how i can break it down to an intiger? like sense howdy is a 5 letter word inthowdy would = to 5.

anyone know?
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 12:22 pm
ah nvm i found a diffrent way around this but if anyone knows that would still be good to take note on.
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 12:57 pm
getSubStr() perhaps?

The function returns the substring of characters using the strings total size. You find any part of a string by find the right place to start + the strings total size - the point you want to end at.

Example:

If you wanted to get the first part of a MP weapon string, you would do this:

Code:
	current = self getCurrentWeapon();
	weapon = getSubStr( current, 0, current.size - 3 );


If your current weapon was an "mp5_mp", that code would return "mp5".

Not sure if that's what you want.
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 01:03 pm
liltc64 writes...
Quote:
is there a command to get a string to be an int?
example:

howdy = "howdyho";
inthowdy = howdy;

ofc that wont work because howdy isnt an int, does anyone know how i can break it down to an intiger? like sense howdy is a 5 letter word inthowdy would = to 5.

anyone know?


Having re-read your post, I think I know what you need. Here is a method I used to convert a string into a number:

Code:
init()
{
	level.serverlogotext = "yourstring";
	StrSize = getSubStr( level.serverlogotext, 0, level.serverlogotext.size );
	
	X = undefined;
	
	if( GetInteger( StrSize ) < 15 )
		X = 305;
	else if( GetInteger( StrSize ) < 30 )
		X = 275;
	else
		X = 250;
		
}

GetInteger( str )
{
	val = 0;
	
	for( i=0; i < str.size; i++ )
	{
		val++;
	}
	
	return val;
}


I used that code to find the X coordinate in a hud element depending on how many characters were in a string logo for a server.

edited on Aug. 1, 2010 09:04 am by DemonSeed
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 01:07 pm
looks nice, thanks ill try it out later i think ima go hit the sack and end my allnighter good night
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 01:46 pm
Code:

	myString = "awesome";
	lengthofString = myString.size;
	// lengthOfString is 7
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Aug. 1, 2010 06:37 pm
wow didnt even think of that i was so tired from stareing at my screen for hours thank you both.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»