[Help]format
#1

Hey there,

I've been trying to script a /sms CMD, everything is going well except one thing:
I tried to /sms myself and heres the results.
Код:
SMS from SenderName:[test], Number:90. // Sender number
SMS to RecieverName:[tSMS from Player:[test], Number:90.], Number:90. // reciever number
I couldn't figure out what's the problem but the msg you send appears to you as a reciever and a sender at the same time
Heres my CODE:

pawn Код:
CMD:sms(playerid,o[])
{
static
num,
msg,
str[120],
pname[MAX_PLAYER_NAME],
tname[MAX_PLAYER_NAME],
str1[120];
if(PlayerInfo[playerid][pPhone] == 0) return SCM(playerid,COLOR_BLUE,"You do not have a cellphone!");
else
{
if(sscanf(o,"is[80]",num,msg)) return SCM(playerid,COLOR_BLUE,"USAGE:/sms [Phone number] [text]");
else
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pPhone] == num)
{
GetPlayerName(playerid,pname,sizeof(pname));
GetPlayerName(playerid,tname,sizeof(tname));
format(str,sizeof(str),"SMS from %s:[%s], Number:%i.",pname,msg,PlayerInfo[playerid][pPhone]);
SCM(i,COLOR_YELLOW2,str);
format(str1,sizeof(str1),"SMS to %s:[%s], Number:%i.",tname,msg,PlayerInfo[i][pPhone]);
SCM(playerid,COLOR_YELLOW2,str1);
}
}
}
}
}
return 1;
}
Reply
#2

Just add:
pawn Код:
break;
After:
pawn Код:
SCM(playerid,COLOR_YELLOW2,str1);
It stops the loop because the number is unique for each player.
Reply
#3

Quote:
Originally Posted by Steve M.
Посмотреть сообщение
Just add:
pawn Код:
break;
After:
pawn Код:
SCM(playerid,COLOR_YELLOW2,str1);
It stops the loop because the number is unique for each player.

After this
pawn Код:
SCM(playerid,COLOR_YELLOW2,str1);
or this?
pawn Код:
SCM(playerid,COLOR_YELLOW2,str);

Because it didn't work... still the same results.
Reply
#4

Of course the result is the same because you send SMS to yourself. Try sending it to some other player.
Reply
#5

Quote:
Originally Posted by Steve M.
Посмотреть сообщение
Of course the result is the same because you send SMS to yourself. Try sending it to some other player.
If you took a look at the results above it shows that the SCM the sender should recieve contains the other string as the message of the formated string

pawn Код:
format(str,sizeof(str),"SMS from %s:[%s], Number:%i.",pname,msg,PlayerInfo[playerid][pPhone]);
SCM(i,COLOR_YELLOW2,str);
format(str1,sizeof(str1),"SMS to %s:[%s], Number:%i.",tname,msg/* this contains the first str*/,PlayerInfo[i][pPhone]);
SCM(playerid,COLOR_YELLOW2,str1);
Heres the results once again

Код:
SMS to RecieverName:[tSMS from Player:[test], Number:90.], Number:90.
It's like a string inside of a string
Reply
#6

Okay. Yeah. Now I understand what the problem is.

BTW, your msg variable should be a string, not an integer.

So, instead of:
pawn Код:
msg
It should be:
pawn Код:
msg[80]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)