SA-MP Forums Archive
Random word - 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: Random word (/showthread.php?tid=643563)



Random word - Zamek - 22.10.2017

Hey. I'm looking for a function that will return a random word from the typed text.

Regards.


Re: Random word - kAn3 - 22.10.2017

Sorry, this section is for scripting help, not for script requestings.


Re: Random word - CodeStyle175 - 22.10.2017

PHP код:
RndWordFromSentence(txt[]){
    new 
arr[20][30],cnt,cnt2;
    for(new 
i,i2=strlen(txt); i2i++){
        switch(
txt[i]){
            case 
' ',',':cnt++,cnt2=0;
            default: 
arr[cnt][cnt2++]=txt[i];
        }
    }
    return 
arr[random(cnt+1)];

print(RndWordFromSentence("Hello my name is jeff"));