md5 hash
#1

(I know WP is better, but I like the way you script md5 and it will be this untill I can finally get my gamemode working)

I recently downloaded one of my old gamemodes which uses md5 and MySQL, and finally solved the MySQL problem but I have problems with MD5

Код:
(1529) : error 017: undefined symbol "md5"
(1601) : error 017: undefined symbol "md5"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

2 Errors.
Error (1529):
pawn Код:
if(dialogid == DIALOG_REG_PASS)
    {
        if(response)
        {
            if(strlen(inputtext) <= 0) return ShowPlayerDialog(playerid,DIALOG_REG_PASS,DIALOG_STYLE_INPUT," ","Entered password is empty/too long.\nEnter valid password.","Enter","Cancel");
            new str[256];
            format(str,128,"SELECT * FROM emails WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str),mysql_store_result();
            if(mysql_num_rows() != 0)
            {
                mysql_free_result();
                ShowPlayerDialog(playerid,DIALOG_REG_LOG,DIALOG_STYLE_INPUT," ","This E-mail is already registered. Use 'Login' instead, or enter another E-mail.","Enter","Cancel");
                return 1;
            }
            mysql_free_result();
            md5(str,inputtext,64); // Line 1529
            format(str,256,"INSERT INTO emails (email,password) VALUES('%s','%s')",PlayerInfo[playerid][pEmail],str);
            mysql_query(str);
            Logged[playerid] = true;
            for(new i = 0; i < 5; i++) TextDrawShowForPlayer(playerid,Tutorial[i]);
            SelectTextDraw(playerid,0x73B1EDFF);
            TutStep[playerid] = 1;
        }
        else
        {
            for(new i = 0; i < 5; i++) TextDrawShowForPlayer(playerid,RegLog[i]);
            SelectTextDraw(playerid,0x73B1EDFF);
            format(PlayerInfo[playerid][pEmail],128,"");
            RegOrLog[playerid] = true;
        }
        return 1;
    }
Error (1601):
pawn Код:
if(dialogid == DIALOG_LOG_PASS)
    {
        if(response)
        {
            if(strlen(inputtext) <= 0) return ShowPlayerDialog(playerid,DIALOG_LOG_PASS,DIALOG_STYLE_INPUT," ","You enter empty password/too long.\nTry again.","Enter","Cancel");
            new str[256],passch[128];
            format(str,256,"SELECT used FROM emails WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            if(strval(str) != 0) return ShowPlayerDialog(playerid,DIALOG_LOG_LOG,DIALOG_STYLE_INPUT," ","Current E-mail is being used in game.\nTry another E-mail.\nIf this is mistake, contact with administator.","Enter","Cancel");
            format(str,128,"SELECT password FROM emails WHERE email='%s' LIMIT 1",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            md5(passch,inputtext,64); // Line 1601
            if(strcmp(str,passch,true) != 0) return ShowPlayerDialog(playerid,DIALOG_LOG_PASS,DIALOG_STYLE_INPUT," ","Wrong password for E-mail.\nTry again.","Enter","Cancel");
            format(str,256,"UPDATE emails SET used=1 WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            Logged[playerid] = true;
            format(str,256,"SELECT driversnum FROM emails WHERE email='%s' LIMIT 1",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            PlayerInfo[playerid][pDriversNum] = strval(str);
            if(PlayerInfo[playerid][pDriversNum] == 0)
            {
                TextDrawShowForPlayer(playerid,Tutorial[0]);
                TextDrawShowForPlayer(playerid,Tutorial[4]);
                for(new i = 5; i < 8; i++) TextDrawShowForPlayer(playerid,Tutorial[i]);
                TutStep[playerid] = 2;
                SelectTextDraw(playerid,0x73B1EDFF);
            }
IF anyone wants to convert this to Whirlpool, feel free to do so. You would be awesome if you did so, but is there any way to solve this?
EDIT: Whirlpool won't run on my server, which is unknown why. So fixing those errors is enough, don't know how though!
Reply
#2

Why don't you hash it on the server? MySQL has a few hash functions that you can use, including sha2. As for the "sending in plain text" argument; loopback connections aren't subject to man-in-the-middle attacks.
Reply
#3

Solved that. Now problem #2

Код:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x-R2, ©2005-2013 SA-MP Team

[17:31:56] 
[17:31:56] Server Plugins
[17:31:56] --------------
[17:31:56]  Loading plugin: AntiCheat
[17:31:57]   Failed.
[17:31:57]  Loading plugin: audio
[17:31:57] 

*** Audio Plugin v0.5 R2 by Incognito loaded ***

[17:31:57]   Loaded.
[17:31:57]  Loading plugin: gvar
[17:31:57] 

*** GVar Plugin v1.3 by Incognito loaded ***

[17:31:57]   Loaded.
[17:31:57]  Loading plugin: mysql
[17:31:57]  SA:MP MySQL Plugin v2.1.1 Loaded.
[17:31:57]   Loaded.
[17:31:57]  Loading plugin: nativechecker
[17:31:57] [MySQL] Thread running. Threadsafe: Yes.
[17:31:57]   Loaded.
[17:31:57]  Loading plugin: sscanf
[17:31:57] 

[17:31:57]  ===============================

[17:31:57]       sscanf plugin loaded.     

[17:31:57]          Version:  2.8.1        

[17:31:57]    © 2012 Alex "******" Cole  

[17:31:57]  ===============================

[17:31:57]   Loaded.
[17:31:57]  Loading plugin: streamer
[17:31:57] 

*** Streamer Plugin v2.6.1 by Incognito loaded ***

[17:31:57]   Loaded.
[17:31:57]  Loaded 6 plugins.

[17:31:57] 
[17:31:57] Filterscripts
[17:31:57] ---------------
[17:31:57]   Loaded 0 filterscripts.

[17:31:57]    Error: Function not registered: 'Streamer_CallbackHook'
[17:31:57]    Error: Function not registered: 'SSCANF_Init'
[17:31:57]    Error: Function not registered: 'SSCANF_Join'
[17:31:57]    Error: Function not registered: 'SSCANF_Leave'
[17:31:57]    Error: Function not registered: 'CheckSet'
[17:31:57]    Error: Function not registered: 'SetMaxPing'
[17:31:57]    Error: Function not registered: 'SetWeaponAllowed'
[17:31:57]    Error: Function not registered: 'AntiCheatSetUpdateDelay'
[17:31:57]    Error: Function not registered: 'CreateDynamicSphere'
[17:31:57]    Error: Function not registered: 'CreateDynamicMapIcon'
[17:31:57]    Error: Function not registered: 'Streamer_SetIntData'
[17:31:57]    Error: Function not registered: 'CreateDynamicObject'
[17:31:57]    Error: Function not registered: 'SetDynamicObjectMaterialText'
[17:31:57]    Error: Function not registered: 'CreateDynamicObjectEx'
[17:31:57]    Error: Function not registered: 'SetDynamicObjectMaterial'
[17:31:57]    Error: Function not registered: 'Streamer_SetArrayData'
[17:31:57]    Error: Function not registered: 'CreateDynamicCircleEx'
[17:31:57]    Error: Function not registered: 'CreateDynamicPolygonEx'
[17:31:57]    Error: Function not registered: 'CreateDynamicCubeEx'
[17:31:57]    Error: Function not registered: 'CreateDynamicRectangleEx'
[17:31:57]    Error: Function not registered: 'Streamer_GetUpperBound'
[17:31:57]    Error: Function not registered: 'IsValidDynamicObject'
[17:31:57]    Error: Function not registered: 'Streamer_GetFloatData'
[17:31:57]    Error: Function not registered: 'Streamer_SetFloatData'
[17:31:57]    Error: Function not registered: 'CreateDynamicCube'
[17:31:57]    Error: Function not registered: 'CreateDynamicPolygon'
[17:31:57]    Error: Function not registered: 'CreateDynamicCircle'
[17:31:57]    Error: Function not registered: 'DestroyDynamicMapIcon'
[17:31:57]    Error: Function not registered: 'DestroyDynamicObject'
[17:31:57]    Error: Function not registered: 'DestroyDynamicArea'
[17:31:57]    Error: Function not registered: 'sscanf'
[17:31:57]    Error: Function not registered: 'IsPlayerInDynamicArea'
[17:31:57]    Error: Function not registered: 'Streamer_UpdateEx'
[17:31:57]    Error: Function not registered: 'AttachDynamicObjectToVehicle'
[17:31:57]    Error: Function not registered: 'IsValidDynamic3DTextLabel'
[17:31:57]    Error: Function not registered: 'DestroyDynamic3DTextLabel'
[17:31:57]    Error: Function not registered: 'CreateDynamic3DTextLabel'
[17:31:57]    Error: Function not registered: 'Streamer_RemoveArrayData'
[17:31:57]    Error: Function not registered: 'Streamer_Update'
[17:31:57]    Error: Function not registered: 'MoveDynamicObject'
[17:31:57] Script[gamemodes/nfsw.amx]: Run time error 19: "File or function is not found"
[17:31:57] Number of vehicle models: 0
All plugins are loaded. Streamer,Sscanf etc, only AntiCheat failed to load.
Reply
#4

I suggest you learn to use white space and put spaces after commas, and perhaps comment too.. Looking at this gave me a headache:

pawn Код:
if(dialogid == DIALOG_LOG_PASS)
    {
        if(response)
        {
            if(strlen(inputtext) <= 0) return ShowPlayerDialog(playerid,DIALOG_LOG_PASS,DIALOG_STYLE_INPUT," ","You enter empty password/too long.\nTry again.","Enter","Cancel");
            new str[256],passch[128];
            format(str,256,"SELECT used FROM emails WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            if(strval(str) != 0) return ShowPlayerDialog(playerid,DIALOG_LOG_LOG,DIALOG_STYLE_INPUT," ","Current E-mail is being used in game.\nTry another E-mail.\nIf this is mistake, contact with administator.","Enter","Cancel");
            format(str,128,"SELECT password FROM emails WHERE email='%s' LIMIT 1",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            md5(passch,inputtext,64); // Line 1601
            if(strcmp(str,passch,true) != 0) return ShowPlayerDialog(playerid,DIALOG_LOG_PASS,DIALOG_STYLE_INPUT," ","Wrong password for E-mail.\nTry again.","Enter","Cancel");
            format(str,256,"UPDATE emails SET used=1 WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            Logged[playerid] = true;
            format(str,256,"SELECT driversnum FROM emails WHERE email='%s' LIMIT 1",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            PlayerInfo[playerid][pDriversNum] = strval(str);
            if(PlayerInfo[playerid][pDriversNum] == 0)
            {
                TextDrawShowForPlayer(playerid,Tutorial[0]);
                TextDrawShowForPlayer(playerid,Tutorial[4]);
                for(new i = 5; i < 8; i++) TextDrawShowForPlayer(playerid,Tutorial[i]);
                TutStep[playerid] = 2;
                SelectTextDraw(playerid,0x73B1EDFF);
            }
Also, it's very bad practise to half-ass something and say 'ill do it later', because you'll probably forget or never get around to it. You should use WP from the start.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
I suggest you learn to use white space and put spaces after commas, and perhaps comment too.. Looking at this gave me a headache:

pawn Код:
if(dialogid == DIALOG_LOG_PASS)
    {
        if(response)
        {
            if(strlen(inputtext) <= 0) return ShowPlayerDialog(playerid,DIALOG_LOG_PASS,DIALOG_STYLE_INPUT," ","You enter empty password/too long.\nTry again.","Enter","Cancel");
            new str[256],passch[128];
            format(str,256,"SELECT used FROM emails WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            if(strval(str) != 0) return ShowPlayerDialog(playerid,DIALOG_LOG_LOG,DIALOG_STYLE_INPUT," ","Current E-mail is being used in game.\nTry another E-mail.\nIf this is mistake, contact with administator.","Enter","Cancel");
            format(str,128,"SELECT password FROM emails WHERE email='%s' LIMIT 1",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            md5(passch,inputtext,64); // Line 1601
            if(strcmp(str,passch,true) != 0) return ShowPlayerDialog(playerid,DIALOG_LOG_PASS,DIALOG_STYLE_INPUT," ","Wrong password for E-mail.\nTry again.","Enter","Cancel");
            format(str,256,"UPDATE emails SET used=1 WHERE email='%s'",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            Logged[playerid] = true;
            format(str,256,"SELECT driversnum FROM emails WHERE email='%s' LIMIT 1",PlayerInfo[playerid][pEmail]);
            mysql_query(str);
            mysql_store_result();
            mysql_fetch_row(str);
            mysql_free_result();
            PlayerInfo[playerid][pDriversNum] = strval(str);
            if(PlayerInfo[playerid][pDriversNum] == 0)
            {
                TextDrawShowForPlayer(playerid,Tutorial[0]);
                TextDrawShowForPlayer(playerid,Tutorial[4]);
                for(new i = 5; i < 8; i++) TextDrawShowForPlayer(playerid,Tutorial[i]);
                TutStep[playerid] = 2;
                SelectTextDraw(playerid,0x73B1EDFF);
            }
Also, it's very bad practise to half-ass something and say 'ill do it later', because you'll probably forget or never get around to it. You should use WP from the start.
Comments annoy me tho. The hash problem is fixed, replaced and done. Now I have a problem with the plugins loading, which can be seen at my post above yours.
Reply
#6

They won't annoy you when you come back to your code in 3 years and think "what the fuck does that do?".
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
They won't annoy you when you come back to your code in 3 years and think "what the fuck does that do?".
that's right actually, and I'm commenting as much as I can now as well as set up a new structure:
include's
define's
new's
MySQL Data
forward's
Enumerator's
Publics
Custom Publics
Player Info
Vehicle Info

But I need a fix for those plugins, as it's a strange thing, I have the latest versions and everything included yet it doesn't kow SSCANF etc..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)