Everything except house address not loading from database
#1

Hello. When I /createhouse <houseid> the houses create including the address and saves into the database, but when I load the houses OnGameModeInit it shows the HouseIDs and prices but not the addresses?

pawn Код:
CMD:createhouse(playerid, params[])
{
    new Float:pos[3], string[128], id;
    if(!IsPlayerLoggedIn(playerid))
    {
        SendClientMessage(playerid, -1, "You are restricted from using commands until you log in.");
        return 1;
    }
    if(PlayerInfo[playerid][pAdminLevel] < 1)
    {
        SendClientMessage(playerid, -1, "You do not have the authority to use this command.");
        return 1;
    }
    if(!AdminDuty[playerid])
    {
        SendClientMessage(playerid, -1, "You are not on duty as an Administrator (/aduty).");
        return 1;
    }
    if(sscanf(params, "i", id))
    {
        SendClientMessage(playerid, -1, "Usage: /createhouse <house id>");
        return 1;
    }
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    format(string, sizeof(string), "You have created House ID %d.", id);
    SendClientMessage(playerid, -1, string);
    CreateHouse(id, pos[0], pos[1], pos[2]);
    return 1;
}
pawn Код:
stock LoadHouses()
{
    new query[400];
    for(new id; id < MAX_HOUSES; id++)
    {
        format(query, sizeof(query), "SELECT * FROM `Houses` WHERE `HouseID` = %d", id);
        mysql_function_query(g_Handle, query, true, "HousesLoad", "d", id);
    }
    return 1;
}
pawn Код:
public HousesLoad()
{
    new temp[150], string[200], rows, fields;
    cache_get_data(rows, fields, g_Handle);

    if(rows)
    {
        for(new id; id < MAX_HOUSES; id++)
        {
            cache_get_row(0, 0, temp, g_Handle), HouseInfo[id][hHouseID] = strval(temp);
            cache_get_row(0, 1, temp, g_Handle), HouseInfo[id][hAddress] = strval(temp);
            cache_get_row(0, 2, temp, g_Handle), HouseInfo[id][hPrice] = strval(temp);
            cache_get_row(0, 3, temp, g_Handle), HouseInfo[id][hEnterPos][0] = floatstr(temp);
            cache_get_row(0, 4, temp, g_Handle), HouseInfo[id][hEnterPos][1] = floatstr(temp);
            cache_get_row(0, 5, temp, g_Handle), HouseInfo[id][hEnterPos][2] = floatstr(temp);
            cache_get_row(0, 6, temp, g_Handle), HouseInfo[id][hExitPos][0] = floatstr(temp);
            cache_get_row(0, 7, temp, g_Handle), HouseInfo[id][hExitPos][1] = floatstr(temp);
            cache_get_row(0, 8, temp, g_Handle), HouseInfo[id][hExitPos][2] = floatstr(temp);
           
            HouseInfo[id][hPickup] = CreateDynamicPickup(1273, 23,  HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], -1, -1, -1, 100.0);
            format(string,sizeof(string),"HouseID: %d\nAddress: %s\nPrice: %d", HouseInfo[id][hHouseID], HouseInfo[id][hAddress], HouseInfo[id][hPrice]);
            HouseInfo[id][hText] = CreateDynamic3DTextLabel(string, -1, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
            break;
        }
    }
    return 1;
}
I'll rep if someone finds the solution. Thanks
Reply
#2

UPDATE: I've noticed that the House ID's are loading because of the HouseID variable, but the actual loop for the MAX_HOUSES ID isn't.

pawn Код:
cache_get_row(0, 0, temp, g_Handle), HouseInfo[id][hHouseID] = strval(temp);
The "id" part isn't working but "hHouseID" is..
Reply
#3

Anyone? Really stuck on this
Reply
#4

Bump..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)