What wrong in here.
#1

Hi all.I have a question with a message save.Here is my script:

Код:
COMMAND:pm(playerid, params[]) // or CMD:mycommand(playerid, params[])
{
new SenderID,MessageID [ 30 ];
if (sscanf(params, "us[20]", SenderID,MessageID)){SendClientMessage(playerid, COLOR_ORANGE, "* Send message for player: /pm [part of name] [message]");return 1;}
if( SenderID == INVALID_PLAYER_ID ){SendClientMessage( playerid, 0xFFFFFFFF, "* This player do not exist" );return 1;}
if( strlen( MessageID ) > 20 ) return SendClientMessage( playerid, 0xFFFFFFFF, "* Message too long [MAX:20]" );
Код:
PlayerData[SenderID][PhoneMessage] = strlen( MessageID[20] );
Код:
new String20 [ 20 ];
format ( String20, 20, "%s",strlen(PlayerData[playerid][PhoneMessage]));
SendClientMessage(playerid,COLOR_GREEN,String20);
And how you see this:

Код:
PlayerData[SenderID][TelefonoZinute]
i want to save in this message:and i use

Код:
strlen( MessageID[20] );
and then i test:

Код:
new String20 [ 20 ];
format ( String20, 20, "%s",strlen(PlayerData[playerid][PhoneMessage]));
SendClientMessage(playerid,COLOR_GREEN,String20);
But in this code i get wrong message,i don't get message only empty message like that:

Код:
SendClientMessage(playerid,COLOR_GREEN,"                                            ");
Maybe i use this wrong :

Код:
strlen( MessageID[20] );
Or maybe i use others things bad...
Reply
#2

strlen returns the character number of a string..
you should correctly use it like: strlen(MessageID);
so if you want to use it in a string like you did you need a %d or %i value for it like this:
pawn Код:
format(string, sizeof(string), "%d", strlen(MessageID));
if you want to show the "MessageID" text you will need to use a string value (%s)
so:
pawn Код:
format(string, sizeof(string), "%s", MessageID);
Reply
#3

No.I need to save this in variable,because how i use in here?

Код:
if(dialogid == 9230)
	{
	if(response)
	{
	new StringSet [ 50 ];
	format(StringSet,50, "%s",What i have write here?);
	ShowPlayerDialog(playerid,25,DIALOG_STYLE_MSGBOX,"Read message",StringSet,"OK","Back");
	}
	return 1;
	}
Reply
#4

Quote:
Originally Posted by budelis
Посмотреть сообщение
No.I need to save this in variable,because how i use in here?

Код:
if(dialogid == 9230)
	{
	if(response)
	{
	new StringSet [ 50 ];
	format(StringSet,50, "%s",What i have write here?);
	ShowPlayerDialog(playerid,25,DIALOG_STYLE_MSGBOX,"Read message",StringSet,"OK","Back");
	}
	return 1;
	}
Save what into a variable? Your simply returning the formatted string. There's nothing wrong with Sacha's post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)