Scripting help
#1

So i am new scripter and because i want to learn scripting i will ask you a few things to explain me!

1) what is tmp? what is the number in front of this?: tmp[256]

2) what is strtok? what this actually do?

3) what this means? if(!strlen(tmp)) and this weap = strval(tmp); whats this lines do?
Reply
#2

1. This is an array variable. It can contain a string (i.e. text) or a series of numbers. Tmp is an abbreviation for Temporary and is a commonly used name for data that needs to be remembered for a short while.

2. strtok is a function that can split a string into multiple parts, based on a certain delimiter (most commonly space) and is mostly used for making commands with additional parameters. However, strtok is old and outdated and there are far superior ways available to make commands nowadays.

3. if(!strlen(tmp)) checks if the length of tmp is 'not something', or in other words 0. Actually, strlen returns the numbers of characters in a string. e.g. strlen("something") will return 9. The negation operator (!) inverses this effect.

weap = strval(tmp); assigns the numerical value that is stored in tmp (e.g. tmp[256] = "46" to a new variable called weap. strval (string value)converts the string (e.g. "46", note the double quotes) to an integer (e.g. 46).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)