SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 22/06/2012, 08:27 PM   #1
Makaveli93
Huge Clucker
 
Makaveli93's Avatar
 
Join Date: May 2012
Posts: 234
Reputation: 17
Default What's wrong with this loop?

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;
                    }
                }
            }
__________________
Makaveli93 is offline   Reply With Quote
Old 22/06/2012, 08:55 PM   #2
Kindred
High-roller
 
Join Date: Aug 2011
Posts: 1,252
Reputation: 504
Default Re: What's wrong with this loop?

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.
Kindred is offline   Reply With Quote
Old 22/06/2012, 09:00 PM   #3
Makaveli93
Huge Clucker
 
Makaveli93's Avatar
 
Join Date: May 2012
Posts: 234
Reputation: 17
Default Re: What's wrong with this loop?

Yes, I have defined it as MAX_PLAYERS. Same thing.
__________________
Makaveli93 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's wrong with this loop? Knappen Scripting Help 2 07/11/2011 03:51 PM
showing wrong/wrong string TextDraws Voldemort Help Archive 5 22/02/2011 05:50 PM


All times are GMT. The time now is 08:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.