if(strcmp ....
#1

Hi, why -> if(strcmp(password, inputtext)) .... is not working ? Player give false password and is connecting?

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 2)
    {
        if(
response == 1)
        {
            
mysql_format(SqlGMsampsizeof(samp), "SELECT `password` FROM `players` WHERE `nick` LIKE BINARY `%s`"GetPlayerNick(playerid));
            
mysql_query(SqlGMsamptrue);
            
cache_get_field_content(0"password"password);
            if(
strcmp(passwordinputtext))
            {
                
format(sampsizeof(samp), ""RED"Wrong password!");
                
ShowPlayerDialog(playerid2DIALOG_STYLE_PASSWORD""ORANGE"Loging"samp""GREEN"next"""RED"back");
                return 
1;
            }
            else
            {
            
format(string,sizeof(string),""RED"[LOGING]: "WHITE" your password is correct!, account "GREEN" is connecting.");
            
SendClientMessage(playerid, -1string);
            
TogglePlayerSpectating(playerid0);
            
SpawnPlayer(playerid);
            }
        }
    }
... 
Reply
#2

You have to negate the call, strcmp yields false if the strings match, look at the wiki: https://sampwiki.blast.hk/wiki/Using_strcmp%28%29
Reply
#3

NO NO NO UN-HASHED PWORDS OMG
Reply
#4

hash the passwords!!!
Reply
#5

use udb_hash
Reply
#6

How to make it?
I just started learning pawn.
Reply
#7

Quote:
Originally Posted by n00blek
Посмотреть сообщение
use udb_hash
Or use the default hashing function provided by SA-MP itself which would be far more secure than udb_hash.

Quote:
Originally Posted by Oficer
Посмотреть сообщение
How to make it?
I just started learning pawn.
Take time to read the wiki as it contains a lot of information which is vital to learning how the callbacks etc. work and how best to use them. Also take a look at the tutorial board on this forum as there are some very well written tutorials there.

I would probably start with something a little smaller than a user system, especially if it's going to be a mysql system. Mysql is a language in its own right which means what you are doing right now is trying to learn two languages at once.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)