[Solved]Need help with WP_Hash
#1

Hey everyone, I seem to be having a problem, and was wondering if you could possibly help me out.

My problem is this, I am using SeifAdmin, it uses MD5_Hash, but I would like to change this from MD5 to WP, but heres my problem.

When I change the MD5_Hash to WP_Hash like this:

pawn Код:
OnPlayerRegister(playerid, WP_Hash(tmppass, sizeof(tmppass), params));
it gives me a tag mismatch on the second arguement.

pawn Код:
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\admTstSvr.pwn(469) : error 035: argument type mismatch (argument 2)
and also here:

pawn Код:
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\admTstSvr.pwn(495) : error 035: argument type mismatch (argument 2)
pawn Код:
dcmd_login(playerid, params[])
{
        new
            tmppass[128],
            plname[24],
            string[128];
           
        if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in.");
        if(!sscanf(params, "i", tmppass))
        {
           SendClientMessage(playerid, ORANGE, "Error! Use /login password!");
        }
        else
        {
        GetPlayerName(playerid, plname, sizeof(plname));
        format(string, sizeof(string), "/Accounts/%s.playerAccount", plname);
        if(!fexist(string)) return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]");
        strmid(tmppass, params, 0, strlen(params), 255);
        OnPlayerLogin(playerid, WP_Hash(tmppass, sizeof(tmppass), params)); //line 495
        return true;
        }
        return true;
}
pawn Код:
dcmd_register(playerid, params[])
{
    {
      new
            sendername[24],
            string[64];
      if(IsPlayerConnected(playerid))
      {
        if(AccountInfo[playerid][Logged] == 1)
            {
                SendClientMessage(playerid, RED, "You are already logged in.");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 64, "/Accounts/%s.playeraccount", sendername);
            new File: hFile = fopen(string, io_read);
            if (hFile)
            {
                SendClientMessage(playerid, RED, "That name is already taken. Please reconnect using a different username.");
                fclose(hFile);
                return 1;
            }
        new tmppass[128];
            if(!sscanf(params, "i", tmppass))
            {
               SendClientMessage(playerid, ORANGE, "Error! Use /register password");
            }
            else
            {
            strmid(tmppass, params, 0, strlen(params), 255);
            OnPlayerRegister(playerid, WP_Hash(tmppass, sizeof(tmppass), params)); //line 469
        }
            return true;
        }
        return true;
    }
}
(OnPlayerRegister)
pawn Код:
forward OnPlayerRegister(playerid, password[]);
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
      new name[24], str[128], ip[15];
      GetPlayerName(playerid, name, sizeof name);
      GetPlayerIp(playerid, ip, sizeof ip);
      format(str, sizeof str, "/Accounts/%s.playerAccount", name);
      new File:account = fopen(str, io_write);
      if (account)
        {
            strmid(AccountInfo[playerid][Password], password, 0, strlen(password), 255);
            AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
            new file[128];
            {
                format(file, sizeof file, "Password: %s\n\r", AccountInfo[playerid][Password]);
                {   fwrite(account, file); }
                format(file, sizeof file, "AdminLevel: %d\n\r", 0);
                {   fwrite(account, file); AccountInfo[playerid][AdminLevel] = 0; }
                format(file, sizeof file, "Cash: %d\n\r", AccountInfo[playerid][Cash]);
                {   fwrite(account, file); }
                format(file, sizeof file, "IPAddress: %s\n\r",ip);
                {   fwrite(account, file); }
            }
            fclose(account);
            SendClientMessage(playerid, GREEN, "|- Account successfully registered. You can now login ( /login [password] ) -|");
        }
    }
    return 1;
}
(OnPlayerLogin)
pawn Код:
forward OnPlayerLogin(playerid, password[]);
public OnPlayerLogin(playerid, password[])
{
  new name[24], str[128];
  GetPlayerName(playerid, name, sizeof name);
    format(str, sizeof str, "/Accounts/%s.playeraccount", name);
    new File:account = fopen(str, io_read);
    if (account)
    {
      new pass[256];
      new passres[128], value[128];
      fread(account, pass, sizeof pass);
      passres = GetFileString(pass);
      if (!strcmp("Password", passres))
        {
            value = GetFileValue(pass);
            strmid(AccountInfo[playerid][Password], value, 0, strlen(value)-1, 128);
        }
        if (!strcmp(AccountInfo[playerid][Password], password, true))
        {
          while (fread(account, pass, 256))
            {
                passres = GetFileString(pass);
                if (strfind(passres, "AdminLevel") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][AdminLevel] = strval(value);
                }
                if (strfind(passres, "Cash") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Cash] = strval(value);
                }
            }
            fclose(account);
      AccountInfo[playerid][Logged] = 1;
        }
        else
        {
            SendClientMessage(playerid, RED, "Incorrect Password.");
        fclose(account);
        return 1;
        }
        GivePlayerMoney(playerid, AccountInfo[playerid][Cash]);
        format(str, sizeof str, "|- You have successfully logged in as %s -|", name);
        SendClientMessage(playerid, GREEN, str);
        printf("%s has logged in", name);
        if (AccountInfo[playerid][AdminLevel] > 0)
        {
        format(str, sizeof str, "|» You are now logged in as a level %d admin «|", AccountInfo[playerid][AdminLevel]);
            SendClientMessage(playerid, LIGHTGREEN, str);
        }
    }
    return 1;
}
also, password is called from an enum
pawn Код:
enum Info
{
    AdminLevel,
    Password[128],
    Cash,
    Logged,
    Mute,
    IP[20],
};
I have a feeling that it has something to do with this, so if you guys can assist me in this, it would be appreciated.

P.s. Don't tell me to post this in the topic, unless you want me to bump a topic that is about 5 pages behind.
Reply
#2

*bump after 12h*

Anyone think they can help?
Reply
#3

Quote:
Originally Posted by Hiitchy - Oui, tu comprends?
*bump after 12h*

Anyone think they can help?
Well, if you have to bump, than i guess noone knows how to answer it
Reply
#4

try out, this is not tested
pawn Код:
dcmd_login(playerid, params[])
{
        new
            tmppass[128],
            plname[24],
            string[128];
           
        if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in.");
        if(!sscanf(params, "i", tmppass))
        {
           SendClientMessage(playerid, ORANGE, "Error! Use /login password!");
        }
        else
        {
        GetPlayerName(playerid, plname, sizeof(plname));
        format(string, sizeof(string), "/Accounts/%s.playerAccount", plname);
        if(!fexist(string)) return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]");
        strmid(tmppass, params, 0, strlen(params), 255);
        WP_Hash(tmppass, sizeof(tmppass), params);
        OnPlayerLogin(playerid, tmppass); //line 495
        return true;
        }
        return true;
}

dcmd_register(playerid, params[])
{
    {
      new
            sendername[24],
            string[64];
      if(IsPlayerConnected(playerid))
      {
        if(AccountInfo[playerid][Logged] == 1)
            {
                SendClientMessage(playerid, RED, "You are already logged in.");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 64, "/Accounts/%s.playeraccount", sendername);
            new File: hFile = fopen(string, io_read);
            if (hFile)
            {
                SendClientMessage(playerid, RED, "That name is already taken. Please reconnect using a different username.");
                fclose(hFile);
                return 1;
            }
        new tmppass[128];
            if(!sscanf(params, "i", tmppass))
            {
               SendClientMessage(playerid, ORANGE, "Error! Use /register password");
            }
            else
            {
            strmid(tmppass, params, 0, strlen(params), 255);
            WP_Hash(tmppass, sizeof(tmppass), params);
            OnPlayerRegister(playerid, tmppass); //line 469
        }
            return true;
        }
        return true;
    }
}
Reply
#5

Hmm, I tried what was mentioned above, but then the samp-server.exe tells me this:

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

SA-MP Dedicated Server
----------------------
v0.3a R4, ©2005-2009 SA-MP Team

[12:00:07] 
[12:00:07] Server Plugins
[12:00:07] --------------
[12:00:07] Loaded 0 plugins.

[12:00:07] 
[12:00:07] Ban list
[12:00:07] --------
[12:00:07] Loaded: samp.ban
[12:00:07] 
[12:00:07] 
[12:00:07] Filter Scripts
[12:00:07] ---------------
[12:00:07]  Loading filter script 'towtruckScript.amx'...
[12:00:07] Tow truck Script loaded
[12:00:07]  Loading filter script 'creatingCar_FS.amx'...
[12:00:07] Car creation Filterscript! Created by Hiitchy - Tu comprends pas?
[12:00:07] Re-distribution of this filterscript is allowed!
[12:00:07] No copyrights or credits.
[12:00:07]  Loaded 2 filter scripts.

[12:00:07] Script[gamemodes/admTstSvr.amx]: Run time error 19: "File or function is not found"
[12:00:07] Number of vehicle models: 0
Reply
#6

You need this PlugIn
http://forum.sa-mp.com/index.php?topic=89418.0
Reply
#7

md5 hash is an integer while wp is a string
Reply
#8

Quote:
Originally Posted by pen_†ĥęGun
I alerady have the plugin native in my gamemode, but, do I need the whole plugin, or just the native? Im confused..

EDIT: never mind, i got it to work. Thanks for your help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)