16.05.2013, 20:08
Well first to get the string input you should use sscanf and zcmd:
Then, to find the last space you need to use strfind, which returns the location of the found substring in the main string:
Now we can use strmid to extract what's after the space to string2: (https://sampwiki.blast.hk/wiki/Strmid)
Now you want to insert '...' in the first string so you do that by using strins:
Then you can send both of these messages to whoever you want.. Hope this helps!
pawn Код:
CMD:somecommand(playerid, params[])
{
new string[128];
if(sscanf(params, "s", string)) return SendClientMessage(playerid, -1, "You must enter a 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.
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
pawn Код:
strins(string, "...", offset)