How to split a /me up into 2 lines? -
Gramercy Riffs - 15.07.2011
This is my /me and /do script:
pawn Код:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !strcmp( cmdtext, "/me", true, 3 ) )
{
if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
return SendClientMessage( playerid, -1, "USAGE: /me (action)" );
new
tempString[ 128 ],
pName[ 24 ]
;
GetPlayerName( playerid, pName, sizeof pName );
format( tempString, sizeof tempString, "*%s%s", RemoveUnderScore(playerid), cmdtext[ 3 ] );
SendClosestMessage( playerid, COLOR_PINK, tempString );
return 1;
}
if ( !strcmp( cmdtext, "/do", true, 3 ) )
{
if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
return SendClientMessage( playerid, -1, "USAGE: /do (action)" );
new
tempString[ 128 ],
pName[ 24 ]
;
GetPlayerName( playerid, pName, sizeof pName );
new stringpos;
if (((stringpos = strfind(" ", pName))) != -1)
{
pName[stringpos] = ' ';
}
format( tempString, sizeof tempString, "* (( %s )) %s" , RemoveUnderScore(playerid), cmdtext[ 3 ] );
SendClosestMessage( playerid, COLOR_PINK, tempString );
return 1;
}
return 0;
}
How do I split the /me's and /do's up so that when they are too long, they go onto the 2nd line?
Re: How to split a /me up into 2 lines? -
[MG]Dimi - 15.07.2011
Try with if(strlen(cmdtext) < [how much you think it long])
{
//here create 2 temp strings and new variable that will get cmdtext to some lenght and stor it into first string and the rest of message store into second and then use 2xSendClientMessage
Re: How to split a /me up into 2 lines? -
MoroDan - 15.07.2011
Post the SendClosestMessage function.
Re: How to split a /me up into 2 lines? -
[MG]Dimi - 15.07.2011
I don't see how will that help
Re: How to split a /me up into 2 lines? -
MoroDan - 15.07.2011
I will modify that function. Is that so hard ?
Re: How to split a /me up into 2 lines? -
Steven82 - 15.07.2011
Quote:
Originally Posted by [MG]Dimi
I don't see how will that help
|
He is just trying to steal your function.
Re: How to split a /me up into 2 lines? -
=WoR=Varth - 16.07.2011
pawn Код:
strmid(chat3,chat2,75,160);
strdel(chat2,81,160);
CostumFormat(chat4,"%s-",chat2);
CostumFormat(chat5,"-%s",chat3);
SendClientMessage(i,color4,chat4);
SendClientMessage(i,color4,chat5);
A piece from my include.
Re: How to split a /me up into 2 lines? -
DRIFT_HUNTER - 16.07.2011
Its not hard to split it to 2 messages but that will not allow you to send longer message since samp's maximum input string is 128
Re: How to split a /me up into 2 lines? -
MoroDan - 16.07.2011
So smartass'es ( like Dimi & Steven82 ) that's why I told him to gimme that function ; I made those commands with SendClientMessage, not SendClosestMessage.
http://imageshack.us/f/840/samp033w.png/
http://imageshack.us/f/825/samp034bo.png/
PHP код:
if (!strcmp(cmdtext, "/me", true, 3))
{
if (cmdtext[3] != ' ' || !cmdtext[4])
return SendClientMessage(playerid, -1, "USAGE: /me (action)");
new string[128], tempStr[128], Str[128];
format(string, sizeof(string), "%s", cmdtext[3]);
if(strlen(string) > (128 - MAX_PLAYER_NAME))
{
strmid(tempStr, string, 0, (128 - MAX_PLAYER_NAME));
format(Str, sizeof(Str), "*%s%s", ReturnName(playerid), tempStr);
SendClientMessage(playerid, 0xFFAABBCC, Str);
strdel(string, 0, (128 - MAX_PLAYER_NAME));
format(tempStr, sizeof(tempStr), "*%s %s", ReturnName(playerid), string);
SendClientMessage(playerid, 0xFFAABBCC, tempStr);
}
else
{
format(string, sizeof string, "*%s%s", ReturnName(playerid), cmdtext[3]);
SendClientMessage(playerid, 0xFFAABBCC, string);
}
// SendClosestMessage(playerid, COLOR_PINK, tempString);
return 1;
}
if (!strcmp(cmdtext, "/do", true, 3))
{
if (cmdtext[3] != ' ' || !cmdtext[4])
return SendClientMessage(playerid, -1, "USAGE: /do (action)");
new string[128], tempStr[128], Str[128];
format(string, sizeof(string), "%s", cmdtext[3]);
if(strlen(string) > (128 - MAX_PLAYER_NAME))
{
strmid(tempStr, string, 0, (128 - MAX_PLAYER_NAME));
format(Str, sizeof(Str), "* (( %s ))%s", ReturnName(playerid), tempStr);
SendClientMessage(playerid, 0xFFAABBCC, Str);
strdel(string, 0, (128 - MAX_PLAYER_NAME));
format(tempStr, sizeof(tempStr), "* (( %s )) %s", ReturnName(playerid), string);
SendClientMessage(playerid, 0xFFAABBCC, tempStr);
}
else
{
format(string, sizeof string, "* (( %s ))%s", ReturnName(playerid), cmdtext[3]);
SendClientMessage(playerid, 0xFFAABBCC, string);
}
//SendClosestMessage(playerid, COLOR_PINK, tempString);
return 1;
}
And Gramercy Riffs, i suggest you to use strtok for commands, because the way how you try to find the parameters, is a bad idea. Because if you type /me or /measdf or /meetmeatthehotel or anything else which starts with me, you'll get the USAGE advertise message. Same as /do.
Re: How to split a /me up into 2 lines? -
Gramercy Riffs - 16.07.2011
Thank you very much.
Is strtok easier than the method I'm using?