AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Any information to do with the array include. (https://forums.alliedmods.net/showthread.php?t=17309)

Dygear 08-29-2005 10:20

Any information to do with the array include.
 
I wanted to get a good idea on how to use it. This is mainly to do with a bunch of names, or rather parts of names, that I want to check against a list. I would use fread to get it into one variable but then I must be able to separate it out so I can check each individual tag against the players name. But there seems to be no good and clean way of getting this working. Oh, and there is no real help in the funciton list, as it does not tell you how to even place it in your code.

I WANT EXPLODE FROM PHP!

v3x 08-29-2005 10:34

Code:
stock ExplodeString(p_szOutput[][],p_iMax,p_szInput[],p_iSize,p_szDelimiter) {     new iIdx = 0,l = strlen(p_szInput)     new iLen = (1 + copyc(p_szOutput[iIdx],p_iSize,p_szInput,p_szDelimiter))     while((iLen < l) && (++iIdx < p_iMax))         iLen += (1 + copyc(p_szOutput[iIdx],p_iSize,p_szInput[iLen],p_szDelimiter))     return (iIdx + 1) }
xero's ( used in my Satchel Charges plugin )

Dygear 08-29-2005 23:23

Thanks :)

[EDIT]
How would use use it. Say I wanted to separate, a /n (new line), or a "/". How would I do it.

[EDIT]
Eh, took alook at the plugin, would seem that if I wanted to remove the / from the string and call each of these into BCL then I would do this . . . Right?


Code:

ExplodeString(BCL,MAX_CVAR_VALS,BadClanFile,31,'/')

XxAvalanchexX 08-29-2005 23:41

Seeminginly not as complicated version by Asskickr:

Code:
stock explode( output[][], input[], delimiter, textlen ) {         new nIdx = 0         new nLen = (1 + copyc( output[nIdx], textlen, input, delimiter ))         while( nLen < strlen(input) )         nLen += (1 + copyc( output[++nIdx], textlen, input[nLen], delimiter )) } new newstring[10][64]; new oldstring[64]; oldstring = "I|LOVE|SPLITTING|TEN|WORDS|INTO|LITTLE|TINY|SMALLER|PIECES"; explode(newstring, oldstring, '|', 63);

Make sure the third argument is a character, not a string (apostrophes instead of quotation marks).

BAILOPAN 08-30-2005 00:44

<_< what if nIdx overflows

XxAvalanchexX 08-30-2005 01:16

Then you'll get nasty runtime errors and be ashamed of yourself for not accounting for that.

BAILOPAN 08-30-2005 01:22

or you can fix it ;]

(also I've optimized it a bit, doing a strlen() in an iterator condition is slow)

Code:
stock explode( output[][], input[], delimiter, textlen, maxMatches ) {         new nIdx = 0         new nLen = (1 + copyc( output[nIdx], textlen, input, delimiter ))         new len = strlen(input)         while( nLen < len && nIdx < maxMatches )         nLen += (1 + copyc( output[++nIdx], textlen, input[nLen], delimiter )) } new newstring[10][64]; new oldstring[64]; oldstring = "I|LOVE|SPLITTING|TEN|WORDS|INTO|LITTLE|TINY|SMALLER|PIECES"; explode(newstring, oldstring, '|', 63, 10);

Dygear 09-01-2005 21:58

Thank you BAILOPAN.


All times are GMT -4. The time now is 14:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.