SA-MP Forums Archive
What's wrong with this loop? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What's wrong with this loop? (/showthread.php?tid=353297)



What's wrong with this loop? - Makaveli93 - 22.06.2012

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;
                    }
                }
            }



Re: What's wrong with this loop? - Kindred - 22.06.2012

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.


Re: What's wrong with this loop? - Makaveli93 - 22.06.2012

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