SA-MP Forums Archive
Can someone explain me the "split" funcition? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Can someone explain me the "split" funcition? (/showthread.php?tid=347870)



Can someone explain me the "split" funcition? - Makaveli93 - 03.06.2012

pawn Код:
public split(const strsrc[], strdest[][], delimiter)
{
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc)){
        if(strsrc[i]==delimiter || i==strlen(strsrc)){
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
}
Can someone explain to me, how to properly use it? Cause I'm having a hard time understanding what it returns to you and what string is what... :/


Re: Can someone explain me the "split" funcition? - Sandiel - 03.06.2012

You can use it to split a player's name using the "_" in his name...
So if he is "FirstName_SecondName", you can split them using "_" and therefor getting:
-Only the FirstName
-Only the SecondName
-Name with this format: FirstName SecondName (notice the "_" is gone)


Glad to help.