What's wrong with this loop?
#1

This is a loop inside /call command. The problem is, when ever I call someone it keeps saying "Invalid phone number.", even though I typed in the right one. The phonenumber shows correctly in /stats and works with /sms.

Can someone please check this loop, maybe you can notice the problem:
pawn Code:
for(new i = 0; i < MAX_ONLINE_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    format(string, sizeof(string), "%d", PlayerInfo[i][pPhoneNumber]);
                    if(PlayerInfo[i][pPhoneNumber] == phonenumb && phonenumb > 0 || strcmp(tmp, string, true) == 0)
                    {
                        giveplayerid = i;
                        Mobile[playerid] = giveplayerid;
                        if(IsPlayerConnected(giveplayerid))
                        {
                               if(PhoneOff[giveplayerid])
                                {
                                    SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] That person's cellphone is turned off.");
                                    return 1;
                                }
                                if (Mobile[giveplayerid] == 2550)
                                {
                                    if(PlayerInfo[playerid][pSex] == 1)
                                    {
                                        PlayerActionMessage(playerid,20.0,"takes out his cellphone.");
                                    }
                                    else
                                    {
                                        PlayerActionMessage(playerid,20.0,"takes out her cellphone.");
                                    }
                                    format(string, sizeof(string), "[SERVER:] Your phone is ringing; Caller: %s ( %d )", GetPlayerNameEx(playerid),PlayerInfo[playerid][pPhoneNumber]);
                                    SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                                    PlayerActionMessage(giveplayerid,20.0,"'s phone begins to ring.");
                                    StartedCall[playerid] = 1;
                                    if(!IsPlayerInAnyVehicle(playerid))
                                    {
                                        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
                                    }
                                    StartedCall[giveplayerid] = 0;
                                    return 1;
                                }
                            }
                       
                        else
                        {
                            SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] That person is on the phone.");
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] Invalid phone number.");
                        return 1;
                    }
                }
            }
Reply
#2

You defined MAX_ONLINE_PLAYERS right? If not, I think it's suppose to be MAX_PLAYERS.

Otherwise, I have no idea whats wrong with this.
Reply
#3

Yes, I have defined it as MAX_PLAYERS. Same thing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)