SA-MP Forums Archive
How to replace characters in a string automatically? - 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: How to replace characters in a string automatically? (/showthread.php?tid=102813)



How to replace characters in a string automatically? - LTomi - 17.10.2009

I would like to create a new advertisement system for my server, writing the ads in a game text for everybody. It wouldn't be too hard, but there are many accentuated letters in my language, and if a player makes an ad with these letters, they doesn't appear correctly. I found a solution, if I want the game text to appear correctly, I have to replace the accentuated letters with symbols. It is easy, if I write the script, but when a player makes an ad, he/she writes the normal letters into the chatbox. So, are there any ways to replace the accentuated letters with their symbols automatically? Any help is welcome.


Re: How to replace characters in a string automatically? - dice7 - 17.10.2009

pawn Код:
public OnPlayerText(playerid, text)
{
  if (writting ad text)
  {
    new idx = 0;
    while(text[idx] != '\0')
    {
      switch(text[idx])
      {
        case '@': text[idx] = 'a';
        case 'Ђ': text[idx] = 'e';
      }
      idx++;
    }
  }
}
Something like that ?


Re: How to replace characters in a string automatically? - MenaceX^ - 17.10.2009

Use strdel + strins.