Something wrong with my register script
#1

Hello. My registration script worked fine until I added some fishing variables, and now when I register it doesn't create my new character row in MySQL. Here is the script:

pawn Код:
enum pInfo
{
    pLevel,
    pGender,
    pCash,
    pBank,
    pJob,
    pBirthDate,
    pBirthMonth,
    pBirthYear,
    pAdminLevel,
    pAdminDuty,
    pSkin,
    pFishPermit,
    pFish[5],
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ,
    Float:pPosA,
    pRegistered
}

new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[350], pname[24], IP[15];
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 15);
    PlayerInfo[playerid][pLevel] = 1;
    PlayerInfo[playerid][pGender] = 0;
    PlayerInfo[playerid][pCash] = 300;
    PlayerInfo[playerid][pBank] = 500;
    PlayerInfo[playerid][pJob] = 0;
    PlayerInfo[playerid][pBirthDate] = 0;
    PlayerInfo[playerid][pBirthMonth] = 0;
    PlayerInfo[playerid][pBirthYear] = 0;
    PlayerInfo[playerid][pAdminLevel] = 0;
    PlayerInfo[playerid][pAdminDuty] = 0;
    PlayerInfo[playerid][pSkin] = 101;
    PlayerInfo[playerid][pFishPermit] = 0;
    PlayerInfo[playerid][pFish][0] = 0;
    PlayerInfo[playerid][pFish][1] = 0;
    PlayerInfo[playerid][pFish][2] = 0;
    PlayerInfo[playerid][pFish][3] = 0;
    PlayerInfo[playerid][pFish][4] = 0;
    PlayerInfo[playerid][pPosX] = 1282;
    PlayerInfo[playerid][pPosY] = 170;
    PlayerInfo[playerid][pPosZ] = 20;
    PlayerInfo[playerid][pPosA] = 338;
    PlayerInfo[playerid][pRegistered] = 0;
    format(query, sizeof(query), "INSERT INTO playerdata (Username, Password, Level, Gender, Cash, Bank, Job, BirthDate, BirthMonth, BirthYear, AdminLevel, AdminDuty, IP, Skin, FishPermit, FishA, FishB, FishC, FishD, FishE, PosX, PosY, PosZ, PosA, Registered) VALUES('%s', SHA1('%s'), %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %f, %f, %f, %f, %d)",
    pname,
    passwordstring,
    PlayerInfo[playerid][pLevel],
    PlayerInfo[playerid][pGender],
    PlayerInfo[playerid][pCash],
    PlayerInfo[playerid][pBank],
    PlayerInfo[playerid][pJob],
    PlayerInfo[playerid][pBirthDate],
    PlayerInfo[playerid][pBirthMonth],
    PlayerInfo[playerid][pBirthYear],
    PlayerInfo[playerid][pAdminLevel],
    PlayerInfo[playerid][pAdminDuty],
    IP,
    PlayerInfo[playerid][pSkin],
    PlayerInfo[playerid][pFishPermit],
    PlayerInfo[playerid][pFish][0],
    PlayerInfo[playerid][pFish][1],
    PlayerInfo[playerid][pFish][2],
    PlayerInfo[playerid][pFish][3],
    PlayerInfo[playerid][pFish][4],
    PlayerInfo[playerid][pPosX],
    PlayerInfo[playerid][pPosY],
    PlayerInfo[playerid][pPosZ],
    PlayerInfo[playerid][pPosA],
    PlayerInfo[playerid][pRegistered]);
    mysql_query(query);
    ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, ""Blue"Character Gender", ""White"Please select your characters gender from the options provided.", "Male", "Female");
    return 1;
}
Reply
#2

I suggest using this;
May not look the prettiest but it should work.
pawn Код:
enum pInfo
{
    pLevel,
    pGender,
    pCash,
    pBank,
    pJob,
    pBirthDate,
    pBirthMonth,
    pBirthYear,
    pAdminLevel,
    pAdminDuty,
    pSkin,
    pFishPermit,
    pFish,
    pFish2,
    pFish3,
    pFish4,
    pFish5,
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ,
    Float:pPosA,
    pRegistered
}

new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[350], pname[24], IP[15];
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 15);
    PlayerInfo[playerid][pLevel] = 1;
    PlayerInfo[playerid][pGender] = 0;
    PlayerInfo[playerid][pCash] = 300;
    PlayerInfo[playerid][pBank] = 500;
    PlayerInfo[playerid][pJob] = 0;
    PlayerInfo[playerid][pBirthDate] = 0;
    PlayerInfo[playerid][pBirthMonth] = 0;
    PlayerInfo[playerid][pBirthYear] = 0;
    PlayerInfo[playerid][pAdminLevel] = 0;
    PlayerInfo[playerid][pAdminDuty] = 0;
    PlayerInfo[playerid][pSkin] = 101;
    PlayerInfo[playerid][pFishPermit] = 0;
    PlayerInfo[playerid][pFish][0] = 0;
    PlayerInfo[playerid][pFish][1] = 0;
    PlayerInfo[playerid][pFish][2] = 0;
    PlayerInfo[playerid][pFish][3] = 0;
    PlayerInfo[playerid][pFish][4] = 0;
    PlayerInfo[playerid][pPosX] = 1282;
    PlayerInfo[playerid][pPosY] = 170;
    PlayerInfo[playerid][pPosZ] = 20;
    PlayerInfo[playerid][pPosA] = 338;
    PlayerInfo[playerid][pRegistered] = 0;
    format(query, sizeof(query), "INSERT INTO playerdata (Username, Password, Level, Gender, Cash, Bank, Job, BirthDate, BirthMonth, BirthYear, AdminLevel, AdminDuty, IP, Skin, FishPermit, FishA, FishB, FishC, FishD, FishE, PosX, PosY, PosZ, PosA, Registered) VALUES('%s', SHA1('%s'), %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %f, %f, %f, %f, %d)",
    pname,
    passwordstring,
    PlayerInfo[playerid][pLevel],
    PlayerInfo[playerid][pGender],
    PlayerInfo[playerid][pCash],
    PlayerInfo[playerid][pBank],
    PlayerInfo[playerid][pJob],
    PlayerInfo[playerid][pBirthDate],
    PlayerInfo[playerid][pBirthMonth],
    PlayerInfo[playerid][pBirthYear],
    PlayerInfo[playerid][pAdminLevel],
    PlayerInfo[playerid][pAdminDuty],
    IP,
    PlayerInfo[playerid][pSkin],
    PlayerInfo[playerid][pFishPermit],
    PlayerInfo[playerid][pFish],
    PlayerInfo[playerid][pFish2],
    PlayerInfo[playerid][pFish3],
    PlayerInfo[playerid][pFish4],
    PlayerInfo[playerid][pFish5],
    PlayerInfo[playerid][pPosX],
    PlayerInfo[playerid][pPosY],
    PlayerInfo[playerid][pPosZ],
    PlayerInfo[playerid][pPosA],
    PlayerInfo[playerid][pRegistered]);
    mysql_query(query);
    ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, ""Blue"Character Gender", ""White"Please select your characters gender from the options provided.", "Male", "Female");
    return 1;
}
Reply
#3

Hmm, but then how would this work:

pawn Код:
CMD:fish(playerid, params[])
{
    new string[128], done, fish;
    if(!IsPlayerLoggedIn(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not logged in.");
        return 1;
    }
    if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
        return 1;
    }
    if(PlayerInfo[playerid][pFish][0] < 1 && PlayerInfo[playerid][pFish][1] < 1 && PlayerInfo[playerid][pFish][2] < 1 && PlayerInfo[playerid][pFish][3] < 1 && PlayerInfo[playerid][pFish][4] < 1)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You cannot hold any more fish in your inventory.");
        return 1;
    }
    PlayerInfo[playerid][pFish][done] = fish;
    format(string, sizeof(string), "* %s attempts to fish off the jetty.", Name(playerid));
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    SetTimerEx("FishingTime", 20000, false, "i", playerid);
    return 1;
}
pawn Код:
forward FishingTime(playerid);
public FishingTime(playerid)
{
    new done, fish, string[256], query[300], pname[24];
    GetPlayerName(playerid, pname, 24);
    for(new i=0; i<5; i++) // Fish
    {
        if(!done)
        {
            if(!PlayerInfo[playerid][pFish][i]) done = i+1;
        }
    }
    done = done-1;
    fish = random(31)+10;
    PlayerInfo[playerid][pFish][done] = fish;
    format(query, sizeof(query), "UPDATE playerdata SET FishA=%d, FishB=%d, FishC=%d, FishD=%d, FishE=%d WHERE Username='%s'",
    PlayerInfo[playerid][pFish][0],
    PlayerInfo[playerid][pFish][1],
    PlayerInfo[playerid][pFish][2],
    PlayerInfo[playerid][pFish][3],
    PlayerInfo[playerid][pFish][4],
    pname);
    mysql_query(query);
    format(string, sizeof(string), "* %s has caught a %d lbs fish.", fish);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
Reply
#4

bump, please help.
Reply
#5

new query[350] is not enough. It should be at least 500. The query without any values is 344 letters long. It'll be over 350 with values set.
Reply
#6

Quote:
Originally Posted by 3ventic
Посмотреть сообщение
new query[350] is not enough. It should be at least 500. The query without any values is 344 letters long. It'll be over 350 with values set.
You have solved it, +rep, cheers man!
I use query[300] for the smaller lines so the query without values would probably be atleast 100 :P
By the way, would setting all new queries to 500 effect my code in any way even for the smaller values?
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)