help please
#1

So i needed help with my /sellhouse command but it doesnt work properly. This is my code:
pawn Код:
CMD:sellhouse(playerid, params[])
{
    for(new i; i < MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.50, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ]))
        {
            new pName[MAX_PLAYER_NAME], string[128], string2[128], string3[128], string4[128];
            GetPlayerName(playerid, pName, sizeof(pName));
            format(string, sizeof(string), "SELECT Houseowner FROM Houses WHERE HouseID = '%d'", i);
            mysql_query(string);
            mysql_store_result();
            new howner[MAX_PLAYER_NAME];
            mysql_fetch_field_row("Houseowner", howner);
            if(strcmp(howner, pName, false))
            {
                format(string2, sizeof(string2), "UPDATE Houses SET Houseowner = '' WHERE HouseID = '%d'", i);
                mysql_query(string2);
                SendClientMessage(playerid, 0xFF0000, "Your house has been sold");
                format(string3, sizeof(string3), "UPDATE Users SET Houses = '%d' WHERE Name = '%s'", APlayerData[playerid][Houses]--, APlayerData[playerid][Name]);
                mysql_query(string3);
                DestroyDynamicPickup(AHouseData[i][PickupID]);
                AHouseData[i][PickupID] = CreatePickup(1273, 1, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ], -1);
                format(string4, sizeof(string4), "This house is for sale!\nPrice: %i\n Type /buyhouse to buy", AHouseData[i][price]);
                UpdateDynamic3DTextLabelText(AHouseData[i][HouseName], COLOR_GREY, string4);
                strdel(AHouseData[i][Owner], 0, 24); //Owner = "" Anyway why the pickup wont get deleted? :| old pickupwill stay
            }
            else
                SendClientMessage(playerid, COLOR_GREY, "This house is not owned by you!");
            mysql_free_result();
        }
    }
    return 1;
}
But this is the error log:
Код:
[21:56:59] >> mysql_query( Connection handle: 1 )
[21:56:59] CMySQLHandler::Query(SELECT Houseowner FROM Houses WHERE HouseID = '111') - Successfully executed.
[21:56:59] >> mysql_store_result( Connection handle: 1 )
[21:56:59] CMySQLHandler::StoreResult() - Result was stored.
[21:56:59] >> mysql_fetch_field_row( Connection handle: 1 )
[21:56:59] CMySQLHandler::FetchField() - You cannot call this function now. (Reason: Fields/Rows are empty.)
[21:56:59] >> mysql_free_result( Connection handle: 1 )
It says the getfield is empty and above it it says it has the right houseid why it does that? since in my database there is clearly my name :S Please help! Thanks
Reply
#2

Код:
CMD:sellhouse(playerid, params[])
{
    for(new i; i < MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.50, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ]))
        {
            new pName[MAX_PLAYER_NAME], string[128], string2[128], string3[128], string4[128];
            GetPlayerName(playerid, pName, sizeof(pName));
            format(string, sizeof(string), "SELECT Houseowner FROM Houses WHERE HouseID = '%d'", i);
            mysql_query(string);
            mysql_store_result();
            new howner[MAX_PLAYER_NAME];
            
    
           mysql_fetch_field_row(howner,"Houseowner");
            if(strcmp(howner, pName, false))
            {
                format(string2, sizeof(string2), "UPDATE Houses SET Houseowner = '' WHERE HouseID = '%d'", i);
                mysql_query(string2);
                SendClientMessage(playerid, 0xFF0000, "Your house has been sold");
                format(string3, sizeof(string3), "UPDATE Users SET Houses = '%d' WHERE Name = '%s'", APlayerData[playerid][Houses]--, APlayerData[playerid][Name]);
                mysql_query(string3);
                DestroyDynamicPickup(AHouseData[i][PickupID]);
                AHouseData[i][PickupID] = CreatePickup(1273, 1, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ], -1);
                format(string4, sizeof(string4), "This house is for sale!\nPrice: %i\n Type /buyhouse to buy", AHouseData[i][price]);
                UpdateDynamic3DTextLabelText(AHouseData[i][HouseName], COLOR_GREY, string4);
                strdel(AHouseData[i][Owner], 0, 24); //Owner = "" Anyway why the pickup wont get deleted? :| old pickupwill stay
            }
            else
                SendClientMessage(playerid, COLOR_GREY, "This house is not owned by you!");
            mysql_free_result();
        }
    }
    return 1;
}
your syntax is wrong...

now try
Reply
#3

It still gives the same weird error of that the row is empty :S
Edit: Fixed it as far now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)