"Refreshing" a certain house
#1

Say if a player purchases a house, what's a way of "refreshing" the icons for just that house.

They're able to own unlimited houses, meaning, a house ID or such isn't stored into their variables. All I do is set their name as the owner.

If I was to refresh all the houses, the old Label and Pickup would be placed there, overlapping the "newer" Label and Pickup.

I use MySQL R33.
Reply
#2

Well you can update the house labels when player buys the house. Same for the icons etc..

Assuming you know the house ID, you can update it's label and map icon easily.
Reply
#3

That's what I want to know. How would I get the house ID?
Reply
#4

Well, how do you create the houses? Is there any function like CreateHouse.. or any array etc You didn't show any code at all. Am I just meant to guess what you have there.
Reply
#5

Creating the house is done by using "INSERT INTO" function:
pawn Код:
CMD:createhouse(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        new Float:X, Float:Y, Float:Z, Float:X2, Float:Y2, Float:Z2, price, interior;
        GetPlayerPos(playerid, X2, Y2, Z2);
        if(sscanf(params, "fffdd", X, Y, Z, interior, price)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" /createhouse [IntX] [IntY] [IntZ] [InteriorID] [Price]");
        format(query, sizeof(query), "INSERT INTO `houses` (IntX, IntY, IntZ, ExtX, ExtY, ExtZ, Price, Interior) VALUES ('%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d')", X, Y, Z, X2, Y2, Z2, price, interior);
        mysql_query(sqldb, query);
        SendClientMessage(playerid, COLOR_GREEN, "Houses has been created and inserted into the database.");
    }
    return true;
}
Since INSERT INTO already auto increments the ID.
Reply
#6

Quote:
Originally Posted by BleverCastard
Посмотреть сообщение
Creating the house is done by using "INSERT INTO" function:
pawn Код:
CMD:createhouse(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        new Float:X, Float:Y, Float:Z, Float:X2, Float:Y2, Float:Z2, price, interior;
        GetPlayerPos(playerid, X2, Y2, Z2);
        if(sscanf(params, "fffdd", X, Y, Z, interior, price)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" /createhouse [IntX] [IntY] [IntZ] [InteriorID] [Price]");
        format(query, sizeof(query), "INSERT INTO `houses` (IntX, IntY, IntZ, ExtX, ExtY, ExtZ, Price, Interior) VALUES ('%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d')", X, Y, Z, X2, Y2, Z2, price, interior);
        mysql_query(sqldb, query);
        SendClientMessage(playerid, COLOR_GREEN, "Houses has been created and inserted into the database.");
    }
    return true;
}
Since INSERT INTO already auto increments the ID.
Could you show me how you load those houses from the database please?
Reply
#7

I select * from houses which is then passed through to the "HouseCheck" function:
pawn Код:
forward HouseCheck();
public HouseCheck()
{
    new rows = mysql_num_rows();
    if(!rows) return print("Houses failed to load. - No rows returned.");
    for(new i = 0; i < rows; i++)
    {
        new temp[24];
        HouseInfo[i][ID] = cache_get_row_int(i, 0, sqldb);
        cache_get_row(i, 1, temp); HouseInfo[i][Owner] = temp;
        HouseInfo[i][IntX] = cache_get_row_float(i, 2, sqldb);
        HouseInfo[i][IntY] = cache_get_row_float(i, 3, sqldb);
        HouseInfo[i][IntZ] = cache_get_row_float(i, 4, sqldb);
        HouseInfo[i][ExtX] = cache_get_row_float(i, 5, sqldb);
        HouseInfo[i][ExtY] = cache_get_row_float(i, 6, sqldb);
        HouseInfo[i][ExtZ] = cache_get_row_float(i, 7, sqldb);
        HouseInfo[i][Interior] = cache_get_row_int(i, 8, sqldb);
        HouseInfo[i][Locked] = cache_get_row_int(i, 9, sqldb);
        HouseInfo[i][Money] = cache_get_row_int(i, 10, sqldb);
        HouseInfo[i][Price] = cache_get_row_int(i, 11, sqldb);
       
        if(!strcmp("STATE", HouseInfo[i][Owner]))
        {
            format(GlobalString, sizeof(GlobalString), ""COL_RED"[House]\n"COL_WHITE"Price: %i", HouseInfo[i][Price]);
            HouseInfo[i][hLabel] = Create3DTextLabel(GlobalString, 0x008080FF, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], 40.0, 0, 0);
            HouseInfo[i][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], -1);
        }
        else
        {
            format(GlobalString, sizeof(GlobalString), ""COL_RED"[House]\n"COL_WHITE"Owner: %s", HouseInfo[i][Owner]);
            HouseInfo[i][hLabel] = Create3DTextLabel(GlobalString, 0x008080FF, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], 40.0, 0, 0);
            HouseInfo[i][hPickup] = CreateDynamicPickup(1272, 1, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], -1);
        }
    }
    return true;
}
Reply
#8

Quote:
Originally Posted by BleverCastard
Посмотреть сообщение
I select * from houses which is then passed through to the "HouseCheck" function:
pawn Код:
forward HouseCheck();
public HouseCheck()
{
    new rows = mysql_num_rows();
    if(!rows) return print("Houses failed to load. - No rows returned.");
    for(new i = 0; i < rows; i++)
    {
        new temp[24];
        HouseInfo[i][ID] = cache_get_row_int(i, 0, sqldb);
        cache_get_row(i, 1, temp); HouseInfo[i][Owner] = temp;
        HouseInfo[i][IntX] = cache_get_row_float(i, 2, sqldb);
        HouseInfo[i][IntY] = cache_get_row_float(i, 3, sqldb);
        HouseInfo[i][IntZ] = cache_get_row_float(i, 4, sqldb);
        HouseInfo[i][ExtX] = cache_get_row_float(i, 5, sqldb);
        HouseInfo[i][ExtY] = cache_get_row_float(i, 6, sqldb);
        HouseInfo[i][ExtZ] = cache_get_row_float(i, 7, sqldb);
        HouseInfo[i][Interior] = cache_get_row_int(i, 8, sqldb);
        HouseInfo[i][Locked] = cache_get_row_int(i, 9, sqldb);
        HouseInfo[i][Money] = cache_get_row_int(i, 10, sqldb);
        HouseInfo[i][Price] = cache_get_row_int(i, 11, sqldb);
       
        if(!strcmp("STATE", HouseInfo[i][Owner]))
        {
            format(GlobalString, sizeof(GlobalString), ""COL_RED"[House]\n"COL_WHITE"Price: %i", HouseInfo[i][Price]);
            HouseInfo[i][hLabel] = Create3DTextLabel(GlobalString, 0x008080FF, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], 40.0, 0, 0);
            HouseInfo[i][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], -1);
        }
        else
        {
            format(GlobalString, sizeof(GlobalString), ""COL_RED"[House]\n"COL_WHITE"Owner: %s", HouseInfo[i][Owner]);
            HouseInfo[i][hLabel] = Create3DTextLabel(GlobalString, 0x008080FF, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], 40.0, 0, 0);
            HouseInfo[i][hPickup] = CreateDynamicPickup(1272, 1, HouseInfo[i][ExtX], HouseInfo[i][ExtY], HouseInfo[i][ExtZ], -1);
        }
    }
    return true;
}
And what exactly is your problem? I do see that you have a variable which stores the ID of the house from the database. You could use it to update the house label on the go.
Reply
#9

Could you give me an example? Loop through the houses then what?
Reply
#10

If you're look for an interior ID you'll be able to find some here https://sampwiki.blast.hk/wiki/InteriorIDs
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)