Slice out of Rang

Started by Cool, Apr 21, 2017, 11:56 PM

Previous topic - Next topic

Cool

when i replace these two functions with these then its start giving me error you can also see screen shot
function FindClanTag(strPlayer)
{

local
D_DELIM = regexp(@"([\[(=^<]+\w+[\])=^>]+)").capture(strPlayer),
S_DELIM = regexp(@"(\w.+[.*=]+)").capture(strPlayer);

if (D_DELIM != null)
{
return strPlayer.slice(D_DELIM[0].begin, D_DELIM[0].end);
}
else if (S_DELIM != null)
{
return strPlayer.slice(S_DELIM[0].begin, S_DELIM[0].end);
}
}


function GetTag(strPlayer)
{

local
D_DELIM = regexp(@"([\[(=^<]+\w+[\])=^>]+)").capture(strPlayer),
S_DELIM = regexp(@"(\w.+[.*=]+)").capture(strPlayer);

if (D_DELIM != null)
{
return strPlayer.slice(D_DELIM[0].begin + 1, D_DELIM[0].end - 1);
}
else if (S_DELIM != null)
{
return strPlayer.slice(S_DELIM[0].begin, S_DELIM[0].end - 1);
}
}

With this One

function FindClanTag(strPlayer)
{
local
     D_DELIM = regexp(@"([\[(=^<{]+\w+[\])=^>}]+)"),// Checking for double delimiter like [TX],{TX},(TX),=TX=,^TX^,<TX>
     D_DELIM_SYM_2 = regexp(@"([\[(=^<{]+\w+[\.*-=]+\w+[\])=^>}]+)"),    // Checking the presence of symbolic clan tag with 2 alphanumeric values like [T-X]Azazel [ Double Delimiter ]
     D_DELIM_SYM_3 = regexp(@"([\[(=^<{]+\w+[\.*-=]+\w+[\.*-=]+\w+[\])=^>}]+)"), // Checking the presence of symbolic clan tag with 3 alphanumeric values like [F.O.X]Sofia [ Double Delimiter ]
         S_DELIM = regexp(@"(\w.+[.*=]+)"),               // Checking for single delimiter like VT. VT= VT* 

     D_DELIM_res = D_DELIM.capture(strPlayer),// Capturing for the double delimiter expression in player.Name  [ will return some array blocks of clan as [TX] < WITH THE CLAN TAG SYMBOL INCLUDED>]
     D_DELIM_SYM_2_res = D_DELIM_SYM_2.capture(strPlayer),  // Capturing for T-X / T.X / T*X Type
     D_DELIM_SYM_3_res = D_DELIM_SYM_3.capture(strPlayer),  // Capturing for F-O-X / F.O.X / F*O*X Type
     S_DELIM_res = S_DELIM.capture(strPlayer);           // Capturing for the single delimiter expression in player.Name  [ will return some array blocks as VT. < WITH THE CLAN TAG SYMBOL INCLUDED>]

if ( D_DELIM_res != null )      // Are captured expressions true ? Do they physically exist in memory?
{
return strPlayer.slice( D_DELIM_res[ 0 ].begin + 1, D_DELIM_res[ 0 ].end - 1 );   // Slicing [TX] into TX by moving 1 step forward from beginning & same step backward from the end 
}
else if ( D_DELIM_SYM_2_res != null )     
{
local tag_sym_2 = strPlayer.slice( D_DELIM_SYM_2_res[ 0 ].begin + 1, D_DELIM_SYM_2_res[ 0 ].end - 1 );   // Slicing [T-X] into T-X by moving 1 step forward from beginning & same step backward from the end 
    local amalgamate_2 = split(tag_sym_2, ".*-=");                      // Splitting T-X into 2 array blocks like a[0] = T, a[1] = X [ DEFINED BY SEPARATORS ]
    return (amalgamate_2[0]+amalgamate_2[1]);                         // Returning the Sum i.e. TX
}
else if ( D_DELIM_SYM_3_res != null )      // Are captured expressions true ? Do they physically exist in memory?
{
local tag_sym_3 = strPlayer.slice( D_DELIM_SYM_3_res[ 0 ].begin + 1, D_DELIM_SYM_3_res[ 0 ].end - 1 );   // Slicing [F.0.X] into F.O.X by moving 1 step forward from beginning & same step backward from the end 
    local amalgamate_3 = split(tag_sym_3, ".*-=");                      // Splitting F.O.X into 3 array blocks like a[0] = F, a[1] = 0, a[2] = X [ DEFINED BY SEPARATORS ]
    return (amalgamate_3[0]+amalgamate_3[1]+amalgamate_3[2]);           // Returning the Sum i.e. FOX

}
else if ( S_DELIM_res != null )
{
return strPlayer.slice( S_DELIM_res[ 0 ].begin, S_DELIM_res[ 0 ].end - 1 ); // Slicing VT. into VT by moving 1 step backward from the end
}
        else return null;                            // No such expressions found? Probably player isn't in a clan. Let's return null !!!
}
function GetTag( string )
{
        local
        Tag = FindClanTag( string ).toupper(),   
        Clans = { VU_T = "VU", VU_R = "VU", TLK = "ULK", TLKR = "ULK", UFR = "UF", UFT = "UF", MKT = "MK", MKS = "MK", DKR = "DK", DKT = "DK", DKS = "DK", OSKR = "OSK", OSK_A ="OSK", OSKR= "OSK", OSKA= "OSK", OSK_R= "OSK", WR_S ="WRS", WRS_T ="WRS", ATT = "AT", ATR = "AT", CFR = "CF", CFT = "CF", VAT = "VA", VAR = "VA", MDT = "MD", MDR = "MD"};
       
         if ( Tag in Clans )    // Checking if the tag obtained through findclan( string ) is in Clan Table or not
        {
             return Clans[ Tag ];      // If yes, its time to calling their corresponding slots from the table
        }
        else return FindClanTag( string );    // if not, then tag will be as it is [ If no slot will be alloted for a clan then script may recognize sublevels as other clans ]
}

Error at this Function
function TruncateClan(strPlayer)
{

local
D_DELIM = regexp(@"([\[(=^<]+\w+[\])=^>]+)").capture(strPlayer),
S_DELIM = regexp(@"(\w.+[.*=]+)").capture(strPlayer);

if (D_DELIM != null)
{

// --- 2 letters in tag
if (GetTag(strPlayer).len() == 2)
{
return strPlayer.slice(D_DELIM[0].begin + 4, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len()); // Error at this line
}



// --- 3 letters in tag
else if (GetTag(strPlayer).len() == 3)
{
return strPlayer.slice(D_DELIM[0].begin + 5, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


// --- 4 letters in tag
else if (GetTag(strPlayer).len() == 4)
{
return strPlayer.slice(D_DELIM[0].begin + 6, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


// --- 5 letters in tag no found for valid
else if (GetTag(strPlayer).len() == 5)
{
return strPlayer.slice(D_DELIM[0].begin + 7, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


// --- 6 letters in tag no found for valid
else if (GetTag(strPlayer).len() == 6)
{
return strPlayer.slice(D_DELIM[0].begin + 8, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


}
else if (S_DELIM != null)
{
// --- 2 letters in tag
if (GetTag(strPlayer).len() == 2)

{
return strPlayer.slice(S_DELIM[0].begin + 3, S_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}



// --- 3 letters in tag
else if (GetTag(strPlayer).len() == 3)
{
return strPlayer.slice(S_DELIM[0].begin + 4, S_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}



// --- 4 letters in tag
else if (GetTag(strPlayer).len() == 4)
{
return strPlayer.slice(S_DELIM[0].begin + 5, S_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


// --- 5 letters in tag no found for valid
else if (GetTag(strPlayer).len() == 5)
{
return strPlayer.slice(S_DELIM[0].begin + 6, S_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


// --- 6 letters in tag no found for valid
else if (GetTag(strPlayer).len() == 6)
{
return strPlayer.slice(S_DELIM[0].begin + 7, S_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
}


}
}
http://imgur.com/a/sQpHF
Error line
   return strPlayer.slice(D_DELIM[0].begin + 4, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len()); // Error at this line

EK.IceFlake

Try changing:
   return strPlayer.slice(D_DELIM[0].begin + 4, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len());
to
   return strPlayer.slice(D_DELIM[0].begin + 4);

KAKAN

if (GetTag(strPlayer).len() == 2)
 {
 return strPlayer.slice(D_DELIM[0].begin + 4, D_DELIM[0].end + strPlayer.len() - FindClanTag(strPlayer).len()); // Error at this line
 }
What if D_DELIM[0].begin is > 1 ?
1+4 = 5.
Total length of the string = 2.
5 > 2, isn't it?
How do you think its going to work?
oh no

Cool

Thanks KAKAN And Thanks Ice Flake for the solution problem solved