SA-MP Forums Archive
Trouble, trouble, trouble... with strcmp I'm assuming - 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: Trouble, trouble, trouble... with strcmp I'm assuming (/showthread.php?tid=373608)



Trouble, trouble, trouble... with strcmp I'm assuming - 2KY - 31.08.2012

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.


Re: Trouble, trouble, trouble... with strcmp I'm assuming - rohancoolking - 31.08.2012

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, "#" );
        }



Re: Trouble, trouble, trouble... with strcmp I'm assuming - 2KY - 31.08.2012

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)