HashString (self made) refuses to work ingame (Unknown command)
#1

Hello.
I have made a 'HashString' function which works in printf ( in main() ). It works there (it outputs an integer).
When I go ingame and register, it refuses to work. It returns a 'SERVER: Unknown command'. Here are some parts of the script (NOTE: The HashString function is not completely shown, to prevent safety failures for later )

HashString function with the functions it needs:
pawn Код:
stock HashString(input[])
{
    new tmpStr[129],
           tmpOutputA,
           tmpOutputB
    ;

    WP_Hash(tmpStr, 129, input); //Thanks to Alex Cole (******) for adding whirlpool to SAMP
    for(new i = 0; i < strlen(tmpStr); i++)
    {
        //CUT
        //CUT    
    }
    tmpOutputA  =   tmpOutputA  %   2237;
    tmpOutputB  =   tmpOutputB  %   2237;
    //CUT
    //CUT

    return ((tmpOutputA << 6) + (tmpOutputB << 6));
}

stock alphabetIndex(const input) //Made by Kwarde, BIG Edit by Ryder` :'). Thanks Ryder` :P
    return ('a' <= input <= 'z') ? (input - 96) : ('A' <= input <= 'Z') ? (input - 64) : 0;

stock isNumeric(input[])
{
    for(new i = 0; i < strlen(input); i++)
    {
        if(input[i] >= 0 && input[i] <= 9 || input[i] == '+' || input[i] == '-') continue;
        else return false;
    }
    return true;
}
So that HashString works in main(), example:
pawn Код:
main()
{
    printf("test = %d", HashString("test"));
    printf("Test = %d", HashString("Test"));
    printf("tEst = %d", HashString("tEst"));
    printf("TEST = %d", HashString("TEST"));
    return 1;
}
It outputs:
Код:
test = 80576
Test = 82560
tEst = 81408
TEST = 81920
And now the /register command + the functions it needs: (It looks a bit like shit with the sscanf, I tried sscanf to try to fix it, without success):
pawn Код:
CMD:register(playerid, params[])
{
    new password[75];
    if(PlayerInfo[playerid][pLogged] || PlayerInfo[playerid][pMustLogin]) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You cannot register. You are either logged in or this account is registered already.");
    if(sscanf(params, "s[75]", password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /register [password]");
    if(strlen(password) < 3 || strlen(password) > 75) return SendClientMessage(playerid, COLOR_ERROR, "To prevent safety leaks, your password must be atleast 3 and maximal 75 characters.");
    ResetPlayer(playerid);
    PlayerInfo[playerid][pPassword] = HashString(password);
    UpdateUserFile(playerid);
    SendClientMessage(playerid, COLOR_GREEN, "Congratulations. You have been successfully registered with the password: null");
    PlayerInfo[playerid][pLogged] = true;
    SpawnPlayer(playerid);
    return 1;
}

CB:UpdateUserFile(playerid)
{
    //CUT: It just creates a file if it doesn't exist and save the variables
    return 1;
}

stock ResetPlayer(playerid)
{
    PlayerInfo[playerid][pLogged]       =   false;
    PlayerInfo[playerid][pMustLogin]    =   false;
   
    PlayerInfo[playerid][pPassword]     =   0;
    PlayerInfo[playerid][pTeam]         =   0;
    PlayerInfo[playerid][pRank]         =   0;
    PlayerInfo[playerid][pNewUserStep]  =   0;
    return 1;
}
Is there anyone that knows what to do? Because I'm getting tired of this, and it's annoying :P
Thanks in advance.

Sirencely,
Kevin
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)