SA-MP Forums Archive
Getting all characters one by one - 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: Getting all characters one by one (/showthread.php?tid=527982)



Getting all characters one by one - Don_Cage - 25.07.2014

Just out of curiosity..
If I would want to make a command, lets say /riddle [riddle text].
Would it be possible to make it show each character one by one?

For example: /riddle car
And it will say something like "First character is: C"
then maybe make some timer and after couple of seconds it say "Second character is: A" and again after some seconds it say "Third character is: R".
Is that possible and if yes, how would I do it?


Re: Getting all characters one by one - Abagail - 25.07.2014

Use timers/strings to your advantage. Separate the string, and set timers, etc.


Re: Getting all characters one by one - Don_Cage - 25.07.2014

How do I seperate the string?
Please show an example


Re: Getting all characters one by one - Champ - 25.07.2014

There is a stock of "split" in wiki.

pawn Code:
// Author unknown. It was probably someone smart like [[User:DracoBlue|DracoBlue]] or [[User:Y_Less|Y_Less]].
stock 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;
}
check this out for usage:
https://sampwiki.blast.hk/wiki/Code_Snippets