Issue with recursion and replacements
#2

Well first to get the string input you should use sscanf and zcmd:
pawn Код:
CMD:somecommand(playerid, params[])
{
new string[128];
if(sscanf(params, "s", string)) return SendClientMessage(playerid, -1, "You must enter a string!");

....
}
Then, to find the last space you need to use strfind, which returns the location of the found substring in the main string:
pawn Код:
new offset = 0, actualOffset = 0;
for(new i = 0; i < sizeof string; i++)
{
   actualOffset = offset;
   offset = strfind(string, " ", true, actualOffset);
   if(offset == -1) break; //This means no space was found.
} //If it goes out of the loop we found the last space location.
Now we can use strmid to extract what's after the space to string2: (https://sampwiki.blast.hk/wiki/Strmid)
pawn Код:
strmid(string2,string,offset,sizeof string) // we cut whatever that is from the last space to the end of the string and paste it to string2
Now you want to insert '...' in the first string so you do that by using strins:
pawn Код:
strins(string, "...", offset)
Then you can send both of these messages to whoever you want.. Hope this helps!
Reply


Messages In This Thread
Issue with recursion and replacements - by Aeonosphere - 16.05.2013, 16:53
Re: Issue with recursion and replacements - by YoYo123 - 16.05.2013, 20:08

Forum Jump:


Users browsing this thread: 2 Guest(s)