Message is only sending to ID 0 -
milanosie - 20.01.2012
Hello all. I made my phone script. but The problem is, if anyone send an sms, only id 0 can send it(only if its send to his number tho)
For anyone else it says Message Delivered.. but the person who got it cant see it.
PHP код:
CMD:sms(playerid, params[])
{
if(PlayerInfo[playerid][Phone] == phone_yes)
{
if(phoneon[playerid] == true)
{
new text[128]; //<----- NIET VERGETEN OM STRING SIZE TO DOEN VOOR EEN TEXT OF %S INPUT!!!
new pnumber;
if(!sscanf(params, "is[128]", pnumber, text)) //String size for text.. NIET VERGETEN ANDERS CRASHED ALLES
{
foreach(Player, i)
{
if(PlayerInfo[i][Phone] == phone_yes)
{
if(PlayerInfo[i][PhoneNumber] == pnumber)
{
if(phoneon[i] == true)
{
if(i != playerid)
{
new string[265], string2[265];
new pnumber2;
pnumber2 = PlayerInfo[playerid][PhoneNumber];
format(string, sizeof(string), "[SMS]%i: %s.", pnumber2, text);
SendClientMessage(i, TEAM_RADIO_COLOR, string);
format(string2, sizeof(string2), "You just sended a text message to %i", pnumber);
SendClientMessage(playerid, TEAM_RADIO_COLOR, string2);
PlayerPlaySound(i,1085,0.0,0.0,0.0);
return 1;
}
}
else return SendClientMessage(playerid, COLOR_GREY, "This player has his/her phone turned off!");
}
return 1;
}
}
return 1;
}
else return SendClientMessage(playerid, COLOR_GREY, "USAGE: /sms [Phone Number] [SMS text]");
}
else return SendClientMessage(playerid, COLOR_GREY, "You have your phone turned off!");
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have a phone!");
}
Re: Message is only sending to ID 0 -
Unte99 - 20.01.2012
You have to use the "u" parameter, which lets to send the message to other players. So the parameters would look like:
pawn Код:
new playeridornamehere;
if(!sscanf(params, "uis[128]", playeridornamehere, pnumber, text))
EDIT: So the playerid would be the player who uses the command, and the playeridornamehere would be the player which you want to do something with.
Re: Message is only sending to ID 0 -
milanosie - 20.01.2012
But I dot want it on name, I want it on number..
so not /sms playername number text
just /sms number text
thats why i use if pnumber == PlayerInfo[i][PhoneNumber]
Re: Message is only sending to ID 0 -
Vince - 20.01.2012
I hate this kind of layout :/ It's so easy to lose your bearings in it. Try this one instead, I restructured it.
pawn Код:
CMD:sms(playerid, params[])
{
if(PlayerInfo[playerid][Phone] != phone_yes)
return SendClientMessage(playerid, COLOR_GREY, "You don't have a phone!");
if(phoneon[playerid] == false)
return SendClientMessage(playerid, COLOR_GREY, "You have your phone turned off!");
new
text[128], //<----- NIET VERGETEN OM STRING SIZE TO DOEN VOOR EEN TEXT OF %S INPUT!!!
pnumber;
if(sscanf(params, "is[128]", pnumber, text)) //String size for text.. NIET VERGETEN ANDERS CRASHED ALLES
return SendClientMessage(playerid, COLOR_GREY, "USAGE: /sms [Phone Number] [SMS text]");
if(PlayerInfo[playerid][PhoneNumber] == pnumber)
return SendClientMessage(playerid, COLOR_GREY, "You cannot send a message to yourself!");
foreach(Player, i)
{
if(PlayerInfo[i][Phone] != phone_yes)
continue;
if(PlayerInfo[i][PhoneNumber] != pnumber)
continue;
if(!phoneon[i])
return SendClientMessage(playerid, COLOR_GREY, "This player has his/her phone turned off!");
new string[144];
format(string, sizeof(string), "[SMS]%i: %s.", PlayerInfo[playerid][PhoneNumber], text);
SendClientMessage(i, TEAM_RADIO_COLOR, string);
format(string, sizeof(string), "You just sent a text message to %i", pnumber);
SendClientMessage(playerid, TEAM_RADIO_COLOR, string);
PlayerPlaySound(i,1085,0.0,0.0,0.0);
return 1;
}
SendClientMessage(playerid, COLOR_GREY, "No such number!");
return 1;
}
Re: Message is only sending to ID 0 -
milanosie - 20.01.2012
u also changed something?
Re: Message is only sending to ID 0 -
milanosie - 20.01.2012
Anyone know the solution?
Re: Message is only sending to ID 0 -
milanosie - 20.01.2012
bump (im sorry need awnser)
Re: Message is only sending to ID 0 -
[ABK]Antonio - 20.01.2012
pawn Код:
CMD:sms(playerid, params[])
{
if(PlayerInfo[playerid][Phone] == phone_yes)
{
if(phoneon[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You have your phone turned off!");
new text[128], pnumber;
if(sscanf(params, "is[128]", pnumber, text)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /sms [Phone Number] [SMS text]");
new pID, count=0; //Lets create a variable to store who has the phone number
foreach(Player, i)
{
if(PlayerInfo[i][Phone] == phone_yes)
{
if(PlayerInfo[i][PhoneNumber] == pnumber)
{
i = pID; //We check who has it, then we save them into pID
count++;
}
}
}
if(count == 0) return SendClientMessage(playerid, COLOR_GREY, "Phone number not found!");
if(pID != playerid) //Check if the one who has it is the same person who typed the command
{
if(phoneon[pID] == false) return SendClientMessage(playerid, COLOR_GREY, "This player has their phone turned off!"); //their = possesive him/her
new string[265], pnumber2;
pnumber2 = PlayerInfo[playerid][PhoneNumber];
format(string, sizeof(string), "[SMS]%i: %s.", pnumber2, text);
SendClientMessage(pID, TEAM_RADIO_COLOR, string);
format(string, sizeof(string), "You've sent a text message to %i", pnumber); //We can format the same string twice instead of creating a new one
SendClientMessage(playerid, TEAM_RADIO_COLOR, string2);
PlayerPlaySound(pID,1085,0.0,0.0,0.0);
return 1;
}
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have a phone!");
return 1;
}
Hmm, maybe this one will work
Re: Message is only sending to ID 0 -
Eric - 20.01.2012
Did you recently update to 0.3d, or are you using a 0.3b/0.3c script?
You may need to update your sscanf.
Re: Message is only sending to ID 0 -
Michael@Belgium - 20.01.2012
Only sending to ID 0. When i have this i just restart my server
And after it's fixed again, something with sscanf