How do delete one string from another?
#1

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...
Reply
#2

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

You need:

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

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 ?
Reply
#4

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

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

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

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..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)