SA-MP Forums Archive
[SOLVED] Strcmp problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] Strcmp problem (/showthread.php?tid=88374)



[SOLVED] Strcmp problem - Blantas - 26.07.2009

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.



Re: Strcmp problem - abhinavdabral - 26.07.2009

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



Re: Strcmp problem - Blantas - 26.07.2009

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


Re: Strcmp problem - Blantas - 26.07.2009

*BUMP


Re: Strcmp problem - refshal - 26.07.2009

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



Re: Strcmp problem - Blantas - 26.07.2009

Not working at all..


Re: Strcmp problem - abhinavdabral - 26.07.2009

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

}



Re: Strcmp problem - Blantas - 26.07.2009

It works!

Thank u so much!


Re: [SOLVED] Strcmp problem - abhinavdabral - 26.07.2009

Good .....