SA-MP Forums Archive
How do delete one string from another? - 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 do delete one string from another? (/showthread.php?tid=88130)



How do delete one string from another? - SiJ - 24.07.2009

Hey..
Here's my code:
pawn Код:
stock KickFromGang(PlayerID,GangName[])
{
    if(!dini_Exists(GangName)) return -1;
    new str[512],name[24];
    GetPlayerName(PlayerID,name,24);
    str = dini_Get(GangName,"Members");
    if(strfind(str,name,true) != 1) // If Player is in File:GangName, line:"Members"
    {
        // Need code to remove "name" from "str"
        return 1;
    }
    return 0;
}
So I could remove name from str...


Re: Help with strfind and strdel(?).. - Weirdosport - 24.07.2009

if(!strfind(str,name,true)) - Is wrong is this context.

You need:

if(strfind(str,name,true) != -1)


Re: Help with strfind and strdel(?).. - SiJ - 24.07.2009

Quote:
Originally Posted by Weirdosport
if(!strfind(str,name,true)) - Is wrong is this context.

You need:

if(strfind(str,name,true) != -1)
Ok.. I'll fix this.. but what about removing name from str ?


Re: [HELP] Help with strfind and strdel(?).. - SiJ - 24.07.2009

Sorry, but I need a quick answer.. :S
Thanks..


Re: How do delete one string from another? - paytas - 24.07.2009

pawn Код:
new position = strfind(str,name,true);

if(position != 1)
{
  strdel(str, position, position + strlen(name));
}



Re: How do delete one string from another? - SiJ - 24.07.2009

Quote:
Originally Posted by paytas
pawn Код:
new position = strfind(str,name,true);

if(position != 1)
{
  strdel(str, position, position + strlen(name));
}
lol I just found same code in another topic and wanted to use it.. But anyway thanks for answer..