Message is only sending to ID 0
#1

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(playeridparams[])
{
    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]"pnumbertext)) //String size for text.. NIET VERGETEN ANDERS CRASHED ALLES
            
{
                foreach(
Playeri)
                {
                    if(
PlayerInfo[i][Phone] == phone_yes)
                    {
                        if(
PlayerInfo[i][PhoneNumber] == pnumber)
                        {
                            if(
phoneon[i] == true)
                            {
                                if(
!= playerid)
                               {
                                    new 
string[265], string2[265];
                                    new 
pnumber2;
                                    
pnumber2 PlayerInfo[playerid][PhoneNumber];
                                    
format(stringsizeof(string), "[SMS]%i: %s."pnumber2text);
                                    
SendClientMessage(iTEAM_RADIO_COLORstring);
                                    
format(string2sizeof(string2), "You just sended a text message to %i"pnumber);
                                    
SendClientMessage(playeridTEAM_RADIO_COLORstring2);
                                    
PlayerPlaySound(i,1085,0.0,0.0,0.0);
                                    return 
1;
                                }
                            }
                            else return 
SendClientMessage(playeridCOLOR_GREY"This player has his/her phone turned off!");
                        }
                        return 
1;
                    }
                }
                return 
1;
            }
            else return 
SendClientMessage(playeridCOLOR_GREY"USAGE: /sms [Phone Number] [SMS text]");
        }
        else return 
SendClientMessage(playeridCOLOR_GREY"You have your phone turned off!");
    }
    else return 
SendClientMessage(playeridCOLOR_GREY"You don't have a phone!");

Reply
#2

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.
Reply
#3

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]
Reply
#4

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;
}
Reply
#5

u also changed something?
Reply
#6

Anyone know the solution?
Reply
#7

bump (im sorry need awnser)
Reply
#8

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
Reply
#9

Did you recently update to 0.3d, or are you using a 0.3b/0.3c script?
You may need to update your sscanf.
Reply
#10

Only sending to ID 0. When i have this i just restart my server And after it's fixed again, something with sscanf
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)