Trouble, trouble, trouble... with strcmp I'm assuming
#1

pawn Code:
else if( clickedid == DialPadNum )
        {
            new
                matches = 0;
               
            if( strlen( cellDialedNumber [ playerid ] ) == 9 )
            {
                for( new u; u < MAX_PLAYERS; u ++ )
                {
                    //if( plStats [ u ] [ CellPhoneNumber ] == cellDialedNumber [ playerid ] )
                    if( strcmp( cellDialedNumber [ playerid ], plStats [ u ] [ CellPhoneNumber ], false ) == 0 )
                    {
                        SendClientMessage( u, Colour_RankOrange, "LOL THIS MESSAGE IS OBNOXIOUS. O AND SOMEONE B CALLIN U" );
                        SendClientMessage( playerid, Colour_Yellow, "LOL IT WURKS" );
                        matches ++;
                    }
                }
            }
           
            if( matches == 0 ) {
                SendClientMessage( playerid, -1, "no wurk :(" );
            }
            SendClientMessage( playerid, -1, "#" );
        }
What I'm trying to do:
Loop through all the players, and if their number is equal to cellDialedNumber [ playerid ], then it will tell both users that it worked.

What it's doing:
Saying every number exists and spamming me with "LOL IT WURKS"

Any help would be appreciated greatly.
Reply
#2

Replace it with this:
pawn Code:
else if( clickedid == DialPadNum )
        {
            new
                matches = 0;
               
            if( strlen( cellDialedNumber [ playerid ] ) == 1 )
            {
                for( new u; u < MAX_PLAYERS; u ++ )
                {
                    //if( plStats [ u ] [ CellPhoneNumber ] == cellDialedNumber [ playerid ] )
                    if( strcmp( cellDialedNumber [ playerid ], plStats [ u ] [ CellPhoneNumber ], false ) == 1 )
                    {
                        SendClientMessage( u, Colour_RankOrange, "LOL THIS MESSAGE IS OBNOXIOUS. O AND SOMEONE B CALLIN U" );
                        SendClientMessage( playerid, Colour_Yellow, "LOL IT WURKS" );
                        matches ++;
                    }
                }
            }
           
            if( matches == 0 ) {
                SendClientMessage( playerid, -1, "no wurk :(" );
            }
            SendClientMessage( playerid, -1, "#" );
        }
Reply
#3

You've misunderstood my code. The string length has to be nine because that's the size of my phone number variable, every phone number is 9 digits long (000000001 to 999999999)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)