SA-MP Forums Archive
Replacer - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Replacer (/showthread.php?tid=141546)



Replacer - Mechscape - 13.04.2010

How do i make, like:

I do say:

Hello, you are noob.

But system replacing noob to ****.

Will be showen:

Hello, you are ****.


Re: Replacer - Mikep. - 13.04.2010

strreplace()

pawn Код:
stock strreplace(trg[],newstr[],src[])
{
  new f=0;
  new s1[MAX_STRING];
  new tmp[MAX_STRING];
  format(s1,sizeof(s1),"%s",src);
  f = strfind(s1,trg);
  tmp[0]=0;
  while (f>=0)
  {
    strcat(tmp,ret_memcpy(s1, 0, f));
    strcat(tmp,newstr);
    format(s1,sizeof(s1),"%s",ret_memcpy(s1, f+strlen(trg), strlen(s1)-f));
    f = strfind(s1,trg);
  }
  strcat(tmp,s1);
  return tmp;
}



Re: Replacer - Mechscape - 13.04.2010

Quote:
Originally Posted by Mikep.
strreplace()
Can you explain more, how do it make?


Re: Replacer - Mikep. - 13.04.2010

pawn Код:
stock NoobCensor(playerid, text[])
{
  new tmp[256];
  set(tmp,text);
  tmp=strreplace("noob","****",tmp);
  return tmp;
}