SA-MP Forums Archive
How this code work ? - 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: How this code work ? (/showthread.php?tid=544344)



How this code work ? - MasonSFW - 01.11.2014

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);
        strdel(text,findid,findid+5);
        print("strdel"); //debug
        strins(text,pname,findid,sizeof(pname));
       
        print("strins"); //debug
       
        printf("%s",text);//debug
        SendClientMessageToAll(-1,text);
        return 0;
    }
    return 1;
}
This code i want to do, When players say some player ID to be playername
if Player ID 0 name is Mark
example Hello id0 = Hello Mark

So that code not work why ?


Re: How this code work ? - MasonSFW - 01.11.2014

I don't know some person give me this code


Re: How this code work ? - BroZeus - 01.11.2014

You copied it from another thread..
Look at the thread u copied from i replied there


Re: How this code work ? - MasonSFW - 01.11.2014

He can't know some things about Strins