Issue with houses (Code inside/Picture.)
#1

Houses on the database add's an extra "N" to nobody.... Although the other's appear correctly as it should be for sale if the Owner is "Nobody", it is only the first house in the database this happens to, It might be something to do with the loopIt actually does this for EVERY house EXCEPT the last in the list, How would I do House checking? I'm guessing it's that, I.e for the second house it's NNNobody it's like it's counting.


House loading

pawn Code:
stock LoadHouses()
{
    new QueryString[128];
    mysql_query( "SELECT id, HouseName, HouseOwner, HouseEntX, HouseEntY, HouseEntZ, HouseIntX, HouseIntY, HouseIntZ, HouseInt, HouseWS1, HouseWA1, HouseWS2, HouseWA2, HouseWS3, HouseWA3, HouseMoney, HouseCS, HousePrice, HouseLock FROM houses");
    mysql_store_result();
    new x;
    while(mysql_retrieve_row())
        {
            mysql_get_field("id", QueryString);
            x = strval(QueryString);

            mysql_get_field("HouseName", HouseName[x]);

            mysql_get_field("HouseOwner", HouseOwner[x]);

            mysql_get_field( "HouseEntX", QueryString);
            HouseEntX[x] = floatstr( QueryString);

            mysql_get_field( "HouseEntY", QueryString);
            HouseEntY[x] = floatstr( QueryString);

            mysql_get_field( "HouseEntZ", QueryString);
            HouseEntZ[x] = floatstr( QueryString);

            mysql_get_field( "HouseIntX", QueryString);
            HouseIntX[x] = floatstr( QueryString);

            mysql_get_field( "HouseIntY", QueryString);
            HouseIntY[x] = floatstr( QueryString);

            mysql_get_field( "HouseIntZ", QueryString);
            HouseIntZ[x] = floatstr( QueryString);

            mysql_get_field( "HouseInt", QueryString);
            HouseInt[x] = strval( QueryString);

            mysql_get_field( "HouseWS1", QueryString);
            HouseWS1[x] = strval( QueryString);

            mysql_get_field( "HouseWA1", QueryString);
            HouseWA1[x] = strval( QueryString);

            mysql_get_field( "HouseWS2", QueryString);
            HouseWS2[x] = strval( QueryString);

            mysql_get_field( "HouseWA2", QueryString);
            HouseWA2[x] = strval( QueryString);

            mysql_get_field( "HouseWS3", QueryString);
            HouseWS3[x] = strval( QueryString);

            mysql_get_field( "HouseWA3", QueryString);
            HouseWA3[x] = strval( QueryString);

            mysql_get_field( "HouseMoney", QueryString);
            HouseMoney[x] = strval( QueryString);

            mysql_get_field( "HouseCS", QueryString);
            HouseCS[x] = strval( QueryString)                   ;

            mysql_get_field( "HousePrice", QueryString);
            HousePrice[x] = strval( QueryString);

            mysql_get_field( "HouseLock", QueryString);
            HouseLock[x] = strval( QueryString);

            HousePickup[x] = CreateDynamicPickup(1273, 23, HouseEntX[x], HouseEntY[x], HouseEntZ[x], 0, -1, -1, 100.0);
            CreateDynamic3DTextLabel(HouseName[x], COLOUR_LIGHTBLUE, HouseEntX[x],HouseEntY[x], HouseEntZ[x], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, 0, -1, -1, 50.0);
    }
    mysql_free_result();
    return 1;
}
House Pickups.
pawn Code:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    new string[256];

    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HousePickup[i])
        {
            if(!strcmp(HouseOwner[i], "Nobody", true && HousePrice[i] >= 1))
            {
                format(string, sizeof(string), "~r~For Sale : %s~n~~w~Price: $%d~n~~b~Type '/buyhouse' to purchase.", HouseName[i], HousePrice[i]);
            }
            else
            {
                format(string, sizeof(string), "Address: %s ~n~ Owner: %s", HouseName[i], HouseOwner[i]);
            }

            GameTextForPlayer(playerid, string, 3000, 5);
            break;
        }
    }
    return 1;
}
This is the only two places coding for the house is mentioned apart from:

CMD:createhouse

pawn Code:
CMD:createhouse(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(AdminLevel[playerid] < 4) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");

    new houseid = -1;
    new housename[32], price;

    if(sscanf(params, "ds[32]", price, housename)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /createhouse [price] [House Name]");

    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(strlen(HouseName[i]) <= 1)
        {
            houseid = i;
            break;
        }
    }
    if(houseid == -1) return SendClientMessage(playerid, COLOUR_GREY, "House Limit Exceeded.");

    new Float:x, Float:y, Float:z;
   
    GetPlayerPos(playerid, x, y, z);

    new query[550];
    format(query, sizeof(query), "INSERT INTO `houses` (HouseName, HouseOwner, HouseEntX, HouseEntY, HouseEntZ, HouseIntX, HouseIntY, HouseIntZ, HouseInt, HouseWS1, HouseWA1, HouseWS2, HouseWA2, HouseWS3, HouseWA3, HouseMoney, HouseCS, HousePrice, HouseLock) VALUES ('%s', 'Nobody', %f, %f, %f, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, %d, 0)",housename, x, y, z, price);
    mysql_query(query);

    format(HouseName[houseid], 100, housename);
    HouseEntX[houseid] = x;
    HouseEntY[houseid] = y;
    HouseEntZ[houseid] = z;
    HouseIntX[houseid] = 0;
    HouseIntY[houseid] = 0;
    HouseIntZ[houseid] = 0;
    HouseInt[houseid] = -1;
    HouseWS1[houseid] = 0;
    HouseWA1[houseid] = 0;
    HouseWS2[houseid] = 0;
    HouseWA2[houseid] = 0;
    HouseWS3[houseid] = 0;
    HouseWA3[houseid] = 0;
    HouseMoney[houseid] = 0;
    HouseCS[houseid] = 0;
    HousePrice[houseid] = price;
    HouseLock[houseid] = 0;

    new string[128];
    format(string, sizeof(string), "You have created house id: %d", houseid);
    SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)