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

Members Online

»
0 Active | 67 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

Tutorials

»
CoD4 Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Understanding the Function: StrTok
Versions: You must be logged in to view history.

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

»
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

»