28.09.2015, 20:39
solved!
CMD:me(playerid, params[])
{
new msg[125], string[124];
if(!sscanf(params, "s[128]", msg))
{
if(!CharacterData[playerid][pLoggedIn])
{
return ErrorMessage(playerid, "You haven't spawned yet");
}
if(strlen(params) > 64) // If it's bigger then this number make it two lines!
{
new text1[65], text2[65];
strmid(text2, params, 64, 128);
strmid(text1, params, 0, 64);
format(string, 128, "* %s %s...",PlayerRPName(playerid), text1);
SendLocalMessage(playerid, 20.0, PURPLE, string);
format(string, 128, "...%s (( %s )).", text2, PlayerRPName(playerid));
SendLocalMessage(playerid, 20.0, PURPLE, string);
}
else // Make it a single line!
{
format(string, sizeof(string), "* %s %s", PlayerRPName(playerid), msg);
SendLocalMessage(playerid, 20.0, PURPLE, string);
}
}
else
{
SyntaxMessage(playerid, "USAGE: /me [action]");
}
return 1;
}
So, if you need a string splitted at 24 characters:
if(strlen(params) > 24) // If it's bigger then this number make it two lines!
{
// Do something!
}
else // Make it a single line!
{
// DO something!
}
new string[128];
format(string, sizeof(string), "~p~%s", Text);
for(new count, len = strlen(Text); count < len; count+=24)
strins(string, "~n~", count);
PlayerTextDrawSetString(playerid, DescriptionTD[3], string);
new string[128]; // Creates the string
format(string, sizeof(string), "~p~%s", Text); // Add text to the string
for(new count, len = strlen(Text); count < len; count+=24) // Makes a loop for each 24 times it adds a ~n~
strins(string, "~n~", count); // Function to add the ~с~
PlayerTextDrawSetString(playerid, DescriptionTD[3], string); // Set the string of the textdraw
PHP код:
|
count < len; count+=24