02.04.2012, 11:43
(
Last edited by AndreT; 02/04/2012 at 11:53 AM.
Reason: Ran a test in loop with 100000 iterations and sscanf is faster than my method.
)
You can do stuff like
strcat(destination, source[starting_index])
So:
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.
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;
}
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;
}