Something buged with my code all help are aprecieated :)
#1

pawn Код:
RegisterPlayer(playerid, password[])
{
    if(AccountExists[playerid])
        return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already registered!");

    if(PlayerLogged[playerid])
    return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already logged in!");

    if(strlen(password) < 3 || strlen(password) >= 32)
    return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Your password is too short or too long!");

    CheckMySQL();

    new string[128];
    format(string, sizeof(string), "INSERT INTO Users (Name,Password) VALUES ('%s','%s')", UserStats[playerid][Name], password);
    mysql_query(string);

    AccountExists[playerid] = 1;
    SendClientMessage(playerid, COLOR_YELLOW, "[SYSTEM] Your account has been created, please login now!");
    SendClientMessage(playerid, COLOR_YELLOW, "[SYTEM] You will get $10,000 to start.");
    SendClientMessage(playerid, COLOR_YELLOW, "[SYTEM] You will start with level 1.");
    UserStats[playerid][pPcarkey1] = 999;
    UserStats[playerid][pPcarkey2] = 999;
    UserStats[playerid][pPcarkey3] = 999;
    GivePlayerMoney(playerid, 10000);
    SetPlayerScore(playerid, 1);
    LoginPlayer(playerid, password);
    SavePlayer(playerid);
    return 1;
}

LoginPlayer(playerid, password[])
{
    if(!AccountExists[playerid])
    return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're not registered!");

    if(PlayerLogged[playerid])
    return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already logged in!");

    if(strlen(password) < 3 || strlen(password) >= 32)
    return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Your password is too short or too long!");

    CheckMySQL();

    new string[128];
    format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s' AND Password = '%s'", UserStats[playerid][Name], password);
    mysql_query(string);
    mysql_store_result();

    if(!mysql_num_rows())
    return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Incorrect password!");

    new row[128]; // The length of 1 'row' total.
    new field[8][32]; // [4] = Amount of fields, [24] = Max length of the bigest field.

    mysql_fetch_row_format(row, "|");
    explode(row, field, "|");
    mysql_free_result();

    // The field starts here with 1, because the field 'Name' = 0, and we already have the name in a variable.
    format(UserStats[playerid][Password], 32, "%s", field[1]);
    UserStats[playerid][Admin] = strval(field[2]);
    UserStats[playerid][Money] = strval(field[3]);
    UserStats[playerid][Score] = strval(field[4]);
    UserStats[playerid][pPcarkey1] = strval(field[5]);
    UserStats[playerid][pPcarkey2] = strval(field[6]);
    UserStats[playerid][pPcarkey3] = strval(field[7]);
    UserStats[playerid][pPcarkey1] = UserStats[playerid][pPcarkey1];
    UserStats[playerid][pPcarkey2] = UserStats[playerid][pPcarkey2];
    UserStats[playerid][pPcarkey3] = UserStats[playerid][pPcarkey3];
    GivePlayerMoney(playerid, UserStats[playerid][Money]);
    SetPlayerScore(playerid, UserStats[playerid][Score]);


    format(string, sizeof(string), "[ACCOUNT] Welcome back %s, you are now logged in!", UserStats[playerid][Name]);
    SendClientMessage(playerid, COLOR_YELLOW, string);

    PlayerLogged[playerid] = 1;
    return 1;
}
Here is my code i will explain what is wrong..

The vehicle keys are kinda buged it is suppose to set the keys to 999 when a player register but when the players login its not seted to 999 because i get a message from my script that says you cant own more then 3 vehicles that means i have just 3 slots.. I tryed to set the keys to 999 on player login and it works but still buged because when i disconnect and connect the keys will be setted to 999 again.. Im very confused i tryed alot of things to fix and its not even working.

IT is suppose to set the vehicles to 999 when register and when login to load the last saved pcarkey ex i buy one car and it sets to the key 97 but then when i login it will be setted to 999 because of my code Lol

also i got a function to saveplayerss i will put here

pawn Код:
SavePlayer(playerid)
{
    if(!PlayerLogged[playerid])
    return 0;
    UserStats[playerid][Money] = GetPlayerMoney(playerid);
    CheckMySQL();
    new string[256]; //
    format(string, sizeof(string), "UPDATE Users SET Password='%s',Admin='%d',Money='%d',Score='%d',pPcarkey1'%d',pPcarkey2'%d',pPcarkey'%d' WHERE Name='%s'", UserStats[playerid][Password], UserStats[playerid][Admin], UserStats[playerid][Money],UserStats[playerid][Score],UserStats[playerid][pPcarkey1],UserStats[playerid][pPcarkey2],UserStats[playerid][pPcarkey3], UserStats[playerid][Name]);
    mysql_query(string);
    return 1;
}
I know you will open it and wtf what is this Lol, help please.

EDIT: I just need a way to dont mix the keys everytime xD
Reply


Messages In This Thread
Something buged with my code all help are aprecieated :) - by Hornet600 - 28.10.2010, 19:42

Forum Jump:


Users browsing this thread: 1 Guest(s)