[SOLVED] Strcmp problem
#1

Hello,
I'm trying to compare 2 strings in /login command.
1 -st string: params (when someone type /login [password])
2 -nd string: Pass (Real password from mysql database)

Код:
if(strcmp(Pass,params, true))
{
   SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
}
else
{
   //When password is correct
}
When i type wrong password, server shows me: [Server]: Wrong password!
When i type correct password, server shows me the same message.

I thought that something is wrong with my sql query but i tried to print these strings and i saw that they are equal.
Reply
#2

try this
pawn Код:
if(!strcmp(Pass,params, true,strlen(Pass)) && strlen(Pass)==strlen(params))
{
   ///// Correct Code goes here
}
else
{
   SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
}
Reply
#3

Quote:
Originally Posted by ۞●•λвнiиаv•●۞
try this
pawn Код:
if(!strcmp(Pass,params, true,strlen(Pass)) && strlen(Pass)==strlen(params))
{
   ///// Correct Code goes here
}
else
{
   SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
}
It's not working... Now when type correct pswd, server loads my stats, but when I type incorrect password, server also loads my stats. :P
Reply
#4

*BUMP
Reply
#5

Try this (just a suggestion, not tested yet):

pawn Код:
if(strcmp(Pass, params, true))
{
  // Put your code in here which does the things you want it to do when the player types in the correct password
  return 1;
}
if(strcmp(Pass, params, false))
{
  SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
  return 1;
}



And if that doesn't work, then try this:

pawn Код:
if(!strcmp(Pass, params, true))
{
  // Put your code in here which does the things you want it to do when the player types in the correct password
  return 1;
}
if(!strcmp(Pass, params, false))
{
  SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
  return 1;
}
Reply
#6

Not working at all..
Reply
#7

pawn Код:
if(strcmp(Pass,params, true))
{
      SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
}
else
{
   if(strlen(Pass)==strlen(params)){
        ///////////// Correct Code
   }
else{
   SendClientMessage(playerid, GRAY, "[Server]: Wrong password!");
}

}
Reply
#8

It works!

Thank u so much!
Reply
#9

Good .....
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)