SA-MP Forums Archive
[MySQL] House creation problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MySQL] House creation problem (/showthread.php?tid=603426)



[MySQL] House creation problem - SsHady - 23.03.2016

Well, here's my code
pawn Код:
CMD:createhouse(playerid, params[])
{
    if(pAdmin[playerid] < 5)
        return Error(playerid, "You are not authorized to use this command!");

    new cost, hint;
    new Float:X, Float:Y, Float:Z;
    if(sscanf(params, "iD(0)", cost, hint)) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, E_CMD_USAGE_CREATEHOUSE);

    if(hint < 0 || hint > MAX_HOUSE_INTERIORS) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, E_INVALID_HINT);
    if(cost < MIN_HOUSE_VALUE || cost > MAX_HOUSE_VALUE) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, E_INVALID_HVALUE);
    else
    {
        // Set a random interior if not specified.
        if(hint == 0)
        {
            hint = random(10);
        }
        GetPlayerPos(playerid, Xp, Yp, Zp);
        GetPlayerFacingAngle(playerid, Angle);
       
        new interior = GetPlayerInterior(playerid);
        GetPlayerPos(playerid, X, Y, Z);
        GetPosInFrontOfPlayer(playerid, X, Y, -2.5);

        format(query, sizeof(query), "INSERT INTO houses(house_id,hname,howner,hpass,x,y,z,a,cpx,cpy,cpz,hint,hvalue) VALUES(0,'House For Sale!','INVALID_PLAYER_ID','INVALID_HOUSE_PASSWORD', %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %d, %d)", X, Y, Zp, (180.0 + Angle), Xp, Yp, Zp, interior, cost);
        mysql_tquery(cHandle, query,"OnHouseCreate", "ifffffffdd", playerid, Xp, Yp, Zp, (180.0 + Angle), X, Y, Zp, hint, cost);
    }
    return 1;
}
Here's where I load the houses
pawn Код:
function LoadHouseData()
{
    new count;
    cache_get_data(rows, fields);
    if(!rows)
    {
        // House doesn't exist
    }
    else
    {
        for(new h; h < rows; h++)
        {
            // Proceed loading house data.
            h_id = cache_get_row_int(h, 0);
            cache_get_row(h, 1, hInfo[h][HouseName]);
            cache_get_row(h, 2, hInfo[h][HouseOwner]);
            cache_get_row(h, 3, hInfo[h][HouseLocation]);
            cache_get_row(h, 4, hInfo[h][HousePassword]);
            hInfo[h][SpawnOutX] = cache_get_row_float(h, 5);
            hInfo[h][SpawnOutY] = cache_get_row_float(h, 6);
            hInfo[h][SpawnOutZ] = cache_get_row_float(h, 7);
            hInfo[h][SpawnOutAngle] = cache_get_row_float(h, 8);
            hInfo[h][CPOutX] = cache_get_row_float(h, 9);
            hInfo[h][CPOutY] = cache_get_row_float(h, 10);
            hInfo[h][CPOutZ] = cache_get_row_float(h, 11);
            hInfo[h][HouseValue] = cache_get_row_int(h, 12);
            hInfo[h][HouseStorage] = cache_get_row_int(h, 13);
            hInfo[h][HouseInterior] = cache_get_row_int(h, 14);
            hInfo[h][HousePrivacy] = cache_get_row_int(h, 15);
           
            // Create House Pickup
            HousePickupOut[h_id] = CreateDynamicPickup(PICKUP_MODEL_OUT, PICKUP_TYPE, hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ], 0, 0, -1, 20.0);
            CreateCorrectHouseExitCP(h_id);
            new labeltext[300];
            if(!strcmp(hInfo[h_id][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
            {
                format(labeltext, sizeof(labeltext), LABELTEXT1, hInfo[h_id][HouseName], hInfo[h_id][HouseValue], h_id);
                HouseMIcon[h_id] = CreateDynamicMapIcon(hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ], 31, -1, 0, 0, -1, MICON_VD);
            }
            else if(strcmp(hInfo[h_id][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
            {
                format(labeltext, sizeof(labeltext), LABELTEXT2, hInfo[h_id][HouseName], hInfo[h_id][HouseOwner], hInfo[h_id][HouseValue], Answer(hInfo[h_id][HousePrivacy], "Open", "Closed"), h_id);
                HouseMIcon[h_id] = CreateDynamicMapIcon(hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ], 32, -1, 0, 0, -1, MICON_VD);
            }
            HouseLabel[h_id] = CreateDynamic3DTextLabel(labeltext, COLOR_GREEN, hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ]+0.7, TEXTLABEL_DISTANCE, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, TEXTLABEL_TESTLOS, 0, 0, -1, TEXTLABEL_DISTANCE);

            Iter_Add(Houses, h);
            count++;
        }
        // DEBUG
        printf("UoS: %d houses loaded!", count);
    }
    return 1;
}
and this
pawn Код:
stock LoadHouses()
{
    LoadHouseInteriors(); // Load house interiors
    format(query, sizeof(query), "SELECT house_id,hname,howner,hlocation,hpass,x,y,z,a,cpx,cpy,cpz,hvalue,hstorage,hint,hprivacy FROM houses");
    mysql_tquery(cHandle, query, "LoadHouseData", "", 0);
}
I'm using BlueG's Latest MySQL plugin. The thing is that the code above does create the house at the particular moment. but the house is not saved in the Database nor it is present there after restarting the server!
I've recently updated my MySQL plugin, before updating it was working fine, but after updating its not.
The old houses that were created before this update of plugin are loading properly. I would really be waiting for your replies.

Thanks


Re: [MySQL] House creation problem - maddinat0r - 23.03.2016

Check your mysql_log.txt for any errors.


Re: [MySQL] House creation problem - SsHady - 24.03.2016

Here's some part of the mysql_log
Код:
[16:34:01] [DEBUG] CMySQLResult::GetRowData - row: '2', field: '12', data: "6000000"
[16:34:01] [DEBUG] cache_get_row_int - row: 2, field_idx: 13, connection: 1
[16:34:01] [DEBUG] CMySQLResult::GetRowData - row: '2', field: '13', data: "0"
[16:34:01] [DEBUG] cache_get_row_int - row: 2, field_idx: 14, connection: 1
[16:34:01] [DEBUG] CMySQLResult::GetRowData - row: '2', field: '14', data: "12"
[16:34:01] [DEBUG] cache_get_row_int - row: 2, field_idx: 15, connection: 1
[16:34:01] [DEBUG] CMySQLResult::GetRowData - row: '2', field: '15', data: "0"
[16:34:01] [DEBUG] cache_get_row_int - row: 3, field_idx: 0, connection: 1
[16:34:01] [DEBUG] CMySQLResult::GetRowData - row: '3', field: '0', data: "3"
[16:34:01] [DEBUG] cache_get_row_int - row: 3, field_idx: 1, connection: 0
[16:34:01] [DEBUG] CMySQLResult::GetRowData - row: '3', field: '1', data: "Generation Of Trooper"
[16:34:01] [ERROR] cache_get_row_int - invalid datatype
[16:34:01] [DEBUG] cache_get_row_int - row: 3, field_idx: 2, connection: 0
[16:34:02] [DEBUG] CMySQLResult::GetRowData - row: '3', field: '2', data: "Assault_Trooper"
[16:34:02] [ERROR] cache_get_row_int - invalid datatype
[16:34:02] [DEBUG] cache_get_row_int - row: 3, field_idx: 3, connection: 0
[16:34:02] [DEBUG] CMySQLResult::GetRowData - row: '3', field: '3', data: "Prickle Pine"
[16:34:02] [ERROR] cache_get_row_int - invalid datatype
[16:34:02] [DEBUG] cache_get_row_int - row: 3, field_idx: 4, connection: 0
[16:34:02] [DEBUG] CMySQLResult::GetRowData - row: '3', field: '4', data: "INVALID_HOUSE_PASSWORD"
[16:34:02] [ERROR] cache_get_row_int - invalid datatype



Re: [MySQL] House creation problem - maddinat0r - 24.03.2016

Hm. Try re-downloading the latest MySQL plugin (R39-4). Replace all files correctly and (the most important part!) recompile your gamemode with the newest include.


Re: [MySQL] House creation problem - LBrasi - 24.03.2016

pawn Код:
INSERT INTO houses(house_id,hname,howner,hpass,x,y,z,a,cpx,cpy,cpz,hint,hvalue) VALUES(0,'House For Sale!','INVALID_PLAYER_ID','INVALID_HOUSE_PASSWORD', %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %d, %d)", X, Y, Zp, (180.0 + Angle), Xp, Yp, Zp, interior, cost);
Why are you setting the house ID as 0, do you have AI enabled for house id on MySQL DB/PhpMyAdmin?


Re: [MySQL] House creation problem - SsHady - 27.03.2016

Yes I have A_I enabled on my mysql database. Any help guys?