Problem with STRINS
#3

instead of using strfind and strdel and strins use str_replace
Information about str_replace - https://sampwiki.blast.hk/wiki/Strlib/str_replace
so new code would be-
pawn Код:
public OnPlayerText(playerid, text[])
{
    new findid=strfind(text,"id",true,0);
    if(findid!=-1)
    {  
        new msg[20],id,extra,pname[MAX_PLAYER_NAME];
        strmid(msg,text,findid,findid+5);
        if(sscanf(msg,"uu",extra,id))
        {
            return 1;
        }
        if(id==INVALID_PLAYER_ID)
        {
            return 1;
        }
        printf("findid %d",findid);
        GetPlayerName(id,pname,sizeof(pname));
        printf("sizeof %d",sizeof(pname));
        printf("strlen %d",strlen(pname));
        printf( "getname %s",pname);
        new r[20];
        format(r,sizeof(r),"id %i",id);//added this line
        str_replace(r, pname, text);//added this line
        printf("%s",text);
        SendClientMessageToAll(-1,text);
        return 0;
    }
    return 1;
}
str_replace function is part of strlib include which can be found here - https://sampforum.blast.hk/showthread.php?tid=85697
Reply


Messages In This Thread
Problem with STRINS - by Quickie - 01.11.2014, 05:59
Re: Problem with STRINS - by MasonSFW - 01.11.2014, 11:32
Re: Problem with STRINS - by BroZeus - 01.11.2014, 13:01
Re: Problem with STRINS - by MasonSFW - 01.11.2014, 13:10
Re: Problem with STRINS - by Quickie - 02.11.2014, 05:46

Forum Jump:


Users browsing this thread: 1 Guest(s)