Find string after other string
#4

You can do stuff like
strcat(destination, source[starting_index])
So:
pawn Code:
CMD:lastname(playerid, params[])
{
    new szName[24], szLastName[24];
    GetPlayerName(playerid, szName, sizeof(szName));
    strcat(szLastName, szName[strfind(szName, "_", true) + 1]);
    SendClientMessage(playerid, RED, szLastName);
    return 1;
}
This means you don't need to get the sscanf plugin in case you don't yet have it.

Edit
Although, I just ran some tests, and using sscanf is quite a bit faster in such case.
pawn Code:
CMD:lastname(playerid, params[])
{
    new szName[24], szLastName[24];
    GetPlayerName(playerid, szName, sizeof(szName));
    sscanf(szName, "'_'s[20]", szLastName);
    SendClientMessage(playerid, RED, szLastName);
    return 1;
}
Reply


Messages In This Thread
Find string after other string - by !LukniS! - 02.04.2012, 11:20
Re: Find string after other string - by Vince - 02.04.2012, 11:23
Re: Find string after other string - by !LukniS! - 02.04.2012, 11:31
Re: Find string after other string - by AndreT - 02.04.2012, 11:43
Re: Find string after other string - by !LukniS! - 02.04.2012, 12:15

Forum Jump:


Users browsing this thread: 2 Guest(s)