strreplace isn't working for me
#6

Quote:
Originally Posted by judothijs
Посмотреть сообщение
Try something like this:

pawn Код:
if(strfind(inputtext == "Admin"))
{
      strreplace(inputtext, "Dick");
      return 1;
}
Funny idea btw :P
thanks, I did something similar:

pawn Код:
if(strfind(inputtext,"admin",true)!=-1)
{
    new adpoz = strfind(inputtext,"admin",true);
    strdel(inputtext,adpoz,adpoz+5);
    strins(inputtext,"dick",adpoz,strlen(inputtext));
}
@VincentDunn
I used dracoblue's utiles
pawn Код:
stock ret_memcpy(source[],index=0,numbytes)
{
    new tmp[200];
    new i=0;
    tmp[0]=0;
    if (index>=strlen(source)) return tmp;
    if (numbytes+index>=strlen(source)) numbytes=strlen(source)-index;
    if (numbytes<=0) return tmp;
    for (i=index;i<numbytes+index;i++) {
        tmp[i-index]=source[i];
        if (source[i]==0) return tmp;
    }
    tmp[numbytes]=0;
    return tmp;
}
stock strreplace(trg[],newstr[],src[])
{
    new f=0;
    new s1[128];
    new tmp[128];
    format(s1,sizeof(s1),"%s",src);
    f = strfind(s1,trg,true);
    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;
}
but it would still be useful to know why strreplace didn't work
Reply


Messages In This Thread
strreplace isn't working for me - by vvhy - 21.06.2012, 17:24
Re: strreplace isn't working for me - by Kindred - 21.06.2012, 17:46
Re: strreplace isn't working for me - by vvhy - 21.06.2012, 17:58
Re: strreplace isn't working for me - by judothijs - 21.06.2012, 18:06
Re: strreplace isn't working for me - by ReneG - 21.06.2012, 18:07
Re: strreplace isn't working for me - by vvhy - 21.06.2012, 18:50
Re: strreplace isn't working for me - by Vince - 21.06.2012, 19:13
Respuesta: strreplace isn't working for me - by vvhy - 21.06.2012, 19:50

Forum Jump:


Users browsing this thread: 1 Guest(s)