AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cvar_to_array (https://forums.alliedmods.net/showthread.php?t=29515)

Chex 06-07-2006 02:46

cvar_to_array
 
Is this even a function? It does not work for me. Any ideas on making it work?

Xanimos 06-07-2006 03:00

Be more specific.

like take a cvar with a value of "12 34 56 78" and making it into an array like
array[0] = "12"
array[1] = "34"
array[2] = "56"
array[3] = "78"

If so then you can use this function for that.

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 }

You call it like so.
Code:
new array[6][5] , szCvar[16] get_cvar_string("mycvar" , szCvar , 15) // For reference it works like this array[p_iMax][p_iSize+1] ExplodeString(array , 6 , szCvar , 4 , ' ')


All times are GMT -4. The time now is 16:23.

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