received,send messages.
#1

Hi peoples.I need some help with my message system.Problem is all overwrite on one,but i need in a row:

Код:
new StringSet [ 50 ];
format(StringSet,50, "+370%d - %s",PlayerData[playerid][PhoneNumber],PlayerData[playerid][SenderName]);
ShowPlayerDialog(playerid,9230,DIALOG_STYLE_LIST,"Received messages",StringSet,"See","Back");
SendClientMessage(playerid,COLOR_GREEN,StringSet);
Here write in GUI player phone number and name who send message to me.And it look like that:

Код:
+3705415464 - PlayerName1
And another player send my message:and it overwrite on first+3705415464 - PlayerName1)

Код:
+3709320081 - PlayerName2
But i need in a row on GUI:

Код:
1. +3705415464 - PlayerName1
2. +3709320081 - PlayerName2
Reply
#2

You have to make more variables, like:

pawn Код:
PhoneNumber1,
PhoneNumber2,
PhoneNumber3,
PhoneNumber4,
PhoneNumber5,
SenderName1,
SenderName2,
SenderName3,
SenderName4,
SenderName5,
Then

pawn Код:
new StringSet [256];
format(StringSet,sizeof(StringSet), "1. +370%d - %s",PlayerData[playerid][PhoneNumber1],PlayerData[playerid][SenderName1]);
format(StringSet,sizeof(StringSet), "%s\n2. +370%d - %s",StringSet,PlayerData[playerid][PhoneNumber2],PlayerData[playerid][SenderName2]);
format(StringSet,sizeof(StringSet), "%s\n3. +370%d - %s",StringSet,PlayerData[playerid][PhoneNumber3],PlayerData[playerid][SenderName3]);
format(StringSet,sizeof(StringSet), "%s\n4. +370%d - %s",StringSet,PlayerData[playerid][PhoneNumber4],PlayerData[playerid][SenderName4]);
format(StringSet,sizeof(StringSet), "%s\n5. +370%d - %s",StringSet,PlayerData[playerid][PhoneNumber5],PlayerData[playerid][SenderName5]);
ShowPlayerDialog(playerid,9230,DIALOG_STYLE_LIST,"Received messages",StringSet,"See","Back");
Reply
#3

Then if i want max 80,then i have to create variables of phones numbers 80 and sendername 80 80+80=160 too many.Maybe somebody know how to do it with loop,and one variable.
Reply
#4

any help?
Reply
#5

You could have one long string which you'd use with delimiters, like:
+37252123123|+37256123124|+37256123125
Then you could split the string.

Or you could also use PVars to store the numbers as strings.

@MadeMan
Something like this:
pawn Код:
format(string, sizeof(string), "%s", something);
format(string, sizeof(string), "%s%s", string, something_else);
is very bad and slow when done numerous times. Use strcat instead!
pawn Код:
strcat(string, something);
strcat(string, something_else);
Reply
#6

Quote:
Originally Posted by AndreT
Посмотреть сообщение
@MadeMan
Something like this:
pawn Код:
format(string, sizeof(string), "%s", something);
format(string, sizeof(string), "%s%s", string, something_else);
is very bad and slow when done numerous times. Use strcat instead!
pawn Код:
strcat(string, something);
strcat(string, something_else);
You think using format AND strcat is better than just format?

But this can be done with PVars and loop too

pawn Код:
new StringSet[1024];
new varname[32] = "PhoneNumber1";
new sendername[32];
new i=1;
while(GetPVarInt(playerid, varname))
{
    format(varname,sizeof(varname), "SenderName%d", i);
    GetPVarString(playerid, varname, sendername, sizeof(sendername));
    format(varname,sizeof(varname), "PhoneNumber%d",i);
    format(StringSet,sizeof(StringSet), "%s%d. +370%d - %s\n",StringSet,i,GetPVarInt(playerid, varname),sendername);
    i++;
    format(varname,sizeof(varname), "PhoneNumber%d",i);
}
if(i == 1) StringSet = "No Messages";
ShowPlayerDialog(playerid,9230,DIALOG_STYLE_LIST,"Received messages",StringSet,"See","Back");
Reply
#7

Код:
COMMAND:pm(playerid, params[]) // or CMD:mycommand(playerid, params[])
{
Then how to do this?
Reply
#8

Quote:
Originally Posted by budelis
Посмотреть сообщение
Код:
COMMAND:pm(playerid, params[]) // or CMD:mycommand(playerid, params[])
{
Then how to do this?
Do what?
Reply
#9

Код:
new varname[32] = "PhoneNumber1";
new sendername[32];
new i=1;
while(GetPVarInt(playerid, varname))
{
    format(varname,sizeof(varname), "SenderName%d", i);
    GetPVarString(playerid, varname, sendername, sizeof(sendername));
    format(varname,sizeof(varname), "PhoneNumber%d",i);
    format(StringSet,sizeof(StringSet), "%s%d. +370%d - %s\n",StringSet,i,GetPVarInt(playerid, varname),sendername);
    i++;
    format(varname,sizeof(varname), "PhoneNumber%d",i);
}
if(i == 1) StringSet = "No Messages";
ShowPlayerDialog(playerid,9230,DIALOG_STYLE_LIST,"Received messages",StringSet,"See","Back");
How to do pm command with this your code?
Reply
#10

Show the code you have now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)