Code:
/* First, save the file ! - Sublime AMXX Editor v1.9 */
#include <amxmodx>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Spawner"
#define string. _String_
#pragma semicolon 1
new _multipleInput[][] = { "[class]myClass1[item]item1,item2,item3[/item]",
"[class]myClass2[item]2_item1,2_item2,3_item3[/item]",
"[class]myClass3[item]3_item1,3_item2,3_item3[/item]"
};
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_srvcmd("parse", "parse_Hook");
}
public parse_Hook(){
for(new i = 0; i < sizeof _multipleInput; i++){
new _myString[7][64];
string.Split( _myString,
string.GetBetween(_multipleInput[i], "[item]", "[/item]"),
','
);
server_print("Class name : %s", string.GetBetween(_multipleInput[i], "[class]", "[item]"));
new i;
while( strlen(_myString[i]) != 0 ){
server_print(" [+] Item name : %s", _myString[i]);
i++;
}
}
}
stock string.GetBetween( _content[], _begin[], _end[] ){
new _Parse[ 256 ];
if( containi(_content, _begin ) != -1 &&
containi(_content, _end ) != -1 )
{
new iStart, iEnd;
iStart = strfind(_content, _begin) + strlen(_begin);
iEnd = strfind(_content, _end, _, iStart);
//formatex( _Parse, iEnd - iStart, "%s", _content[iStart] );
copy( _Parse , iEnd - iStart , _content[ iStart ] );
return _Parse;
}
_Parse = "Can't find it!"; return _Parse; // return "" ... crash the compiler ( AGAIN ! )
}
// <a href="https://forums.alliedmods.net/showpost.php?p=63298&postcount=14" target="_blank" rel="noopener">https://forums.alliedmods.net/showpo...8&postcount=14</a>
stock string.Split( p_szOutput[][], p_szInput[], p_szDelimiter, size = sizeof p_szOutput[], size2 = sizeof p_szOutput )
{
new nIdx = 0, l = strlen(p_szInput);
new nLen = (1 + copyc( p_szOutput[nIdx], size, p_szInput, p_szDelimiter ));
while( (nLen < l) && (++nIdx < size2) )
nLen += (1 + copyc( p_szOutput[nIdx], size, p_szInput[nLen], p_szDelimiter ));
return nIdx;
}