Members Online»
0 Active | 67 Guests
Online:
|
LATEST FORUM THREADS»
by KAZAM3766
Posts: 1 / 343 CoD: Battle Royale
CoD+UO Map + Mod Releases by morgawr
Posts: 1 / 2446 Damaged .pk3's
CoD Mapping by lazygit
Posts: 1 / 2953 heli to attack ai
CoD4 SP Mapping by DrBiggzz
Posts: 11 / 930 New Cod UO Rifle Mod.
CoD Mapping by rr016
Posts: 2 / 5218 setting your own ai names
CoD4 SP Mapping |
Polls»
|
A little tutorial that shows a way you can use the StrTok function and help you to understand how it functions.
The function is:
Code:
StrTok( <string>, <delimiter> )
can be in the form of a variable containing a string, or just a plain string.
is what is used to split the string.
Here is an example of the function in use:
Code:
CheckVIP()
{
string = createdvar( "scr_vip_names", "Waffles::Xylozi", "", "", "string" );
names = StrTok( string, "::" );
for( i = 0; i < names.size; i++ )
{
if( ToLower( self.name ) == ToLower( names[i] ) )
{
self.vip = true;
}
else
{
self.vip = false;
}
}
}
StrTok splits a string and turns the split strings into an array.
Code:
string = createdvar( "scr_vip_names", "Waffles::Xylozi", "", "", "string" );
Defines the variable with any values in the dvar. Uses a function called createdvar to make the dvar and set some default values.
Code:
names = StrTok( string, "::" );
This defines the variable "name" with the split strngs. String is the variable we defined earlier, and "::" is the delimiter, which is what is used to check were to split the string. This means string[0] returns "Waffles", and string[1] will return "Xylozi".
Code:
for( i = 0; i < names.size; i++ )
This uses the function of for(), which will loop through all the arrays of the variable names that are filled.
Code:
if( ToLower( self.name ) == ToLower( names[i] ) )
Makes the strings lowercase, ensure if they're the same they will match. Also used to check if they actually match, and therefore commit the code within the if statement.
StrTok can be used whenever you need to split a string, making it very useful for such functions as the VIP one above.
Hope this helped you understand StrTok.
Latest Syndicated News»
Comments: 5
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which... Comments: 5
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ... Comments: 5
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead?
... Comments: 5
Codutility.com up and runn...
It seems to me the like the site is completely dead? Comments: 5
Codutility.com up and runn...
Yeeaahhhh.........
|
Latest Downloads»
OHMY Don Quixote
Call of Duty 2: Maps: Multiplayer (5.76Mb) OHMY Neuburg
Call of Duty 2: Maps: Multiplayer (6.84Mb) OHMY Tebessa
Call of Duty 2: Maps: Multiplayer (7.36Mb) OHMY POW Camp
Call of Duty 2: Maps: Multiplayer (2.15Mb) OHMY Valley
Call of Duty 2: Maps: Multiplayer (5.7Mb) |
Partners & Friends»
|
Site Links and Information
|
Partners
|
Friends
|
Copyright © MODSonline LLC
Tresware Content Management System © 2011
Website Designed by LKFX and Developed by Tresware