SA-MP Forums Archive
Deleting char. - 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: Deleting char. (/showthread.php?tid=254109)



Deleting char[SOLVED] - kamilbam - 09.05.2011

Hello!

I'm having little problem with the string.

What i want to do is to check if there is let's say '' char find out the pos of it and delete it.

Код:
stock DeleteChar(text[])
{
	for(new i = 0;  text[i] != 0; i++)
	if(text[i] == ':D')text[i] = ' ';
}
Now this code works only for 1 char and i have no idea how to make it work for 2 chars.


Re: Deleting char. - Seven_of_Nine - 09.05.2011

pawn Код:
stock DeleteChar(text[]) {
    new char2, text2[30];
    for(new i = 0; i < sizeof(text); i++) {
        if(strcmp(text,":",true) == 0) {
            text[i] = "*";
        }
        text2 = text[i+1];
        if(strcmp(text2,"D",true) == 0) {
            text[i+1] = "*";
            return 1;
        }
    }
    return 0;
}
Not tested, but this should remove "" smiley.


Re: Deleting char. - kamilbam - 09.05.2011

TOTAL EDIT:

I found out how to make it.

Before you format message you write something like this:

Код:
strf = strfind(text, ":D", true);

if(strf != -1)
{
	strdel(text, strf, strf +2);
}