created houses loads only after server load mysql +rep
#1

hello i got a problem when i creaete a house i need to restart the server to edit it or buy etc..
plz help
this is my SaveHouse Function
pawn Код:
stock SaveHouse(Float:ExtX, Float:ExtY, Float:ExtZ, Float:IntX, Float:IntY, Float:IntZ, IntID, RWorld)
{
    new
        id,
        string[512],
        Query[2000],
        hID,
        hName[128],
        hOwner[24],
        Float:ExtX,
        Float:ExtY,
        Float:ExtZ,
        Float:IntX,
        Float:IntY,
        Float:IntZ,
        Price,
        IntID,
        Locked,
        World;
       
    mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `Houses` (`HouseName`, `HouseOwner`, `ExteriorX`, `ExteriorY`, `ExteriorZ`, `InteriorX`, `InteriorY`, `InteriorZ`, `InteriorID`, `HousePrice`, `HouseLocked`, `HouseWorld`) VALUES('NotSet', 'Nobody', '%f', '%f', '%f', '%f', '%f', '%f', '%i', '25000', '0', '%i')", ExtX, ExtY, ExtZ, IntX, IntY, IntZ, IntID, RWorld);
    mysql_query(mysql, Query);
    mysql_free_result();
    hInfo[id][HouseID] = hID;
    hInfo[id][HouseExteriorX] = ExtX;
    hInfo[id][HouseExteriorY] = ExtY;
    hInfo[id][HouseExteriorZ] = ExtZ;
    hInfo[id][HouseInteriorX] = IntX;
    hInfo[id][HouseInteriorY] = IntY;
    hInfo[id][HouseInteriorZ] = IntZ;
    hInfo[id][HouseInteriorID] = IntID;
    hInfo[id][HousePrice] = Price;
    hInfo[id][HouseLocked] = Locked;
    hInfo[id][HouseWorld] = World;
    HousePickup[id] = CreatePickup(1273, 1, ExtX, ExtY, ExtZ, 0);
    format(hInfo[id][HouseName], 128, "%s", hName);
    format(hInfo[id][HouseOwner], 24, "%s", hOwner);
    format(string, sizeof(string), "{3366FF}%s\nID: {FFFFFF}%d", hName, hInfo[id][HouseID]);
    HouseLabel[id] = Create3DTextLabel(string, COLOR_BLUE, ExtX, ExtY, ExtZ, 5.0, 0, 1);
    return 1;
}
sorry for my bad english
Reply
#2

Where's Buy or Edit house function ?!?
And why your variables are inside ?
Reply
#3

---------
Reply
#4

After creating do you see the "House Added" Message ?
Reply
#5

Quote:
Originally Posted by amirm3hdi
Посмотреть сообщение
After creating do you see the "House Added" Message ?
yes but can't buy it only after server restart
Reply
#6

Let me see the BUY house function..
Reply
#7

------
Reply
#8

ok replace it with this code, and see till how many CP this function works:
Код:
CMD:buyhouse(playerid, params[])
{
    print("CP: 1");
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[i][HouseExteriorX], hInfo[i][HouseExteriorY], hInfo[i][HouseExteriorZ]))
        {
            print("CP: 2");
            if(strmatch(hInfo[i][HouseOwner], "Nobody"))
            {
                print("CP: 3");
                if(pInfo[playerid][HouseKey] == 0)
                {
                    print("CP: 4");
                    if(pInfo[playerid][Money] >= hInfo[i][HousePrice])
                    {
                        print("CP: 6");
                        new string[256], Query[128];
                        format(string, sizeof(string), "Congratulations! You have purchased %s for $%d.", hInfo[i][HouseName], hInfo[i][HousePrice]);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        format(hInfo[i][HouseOwner], 24, "%s", pName(playerid));
                        pInfo[playerid][Money] -= hInfo[i][HousePrice];
                        GivePlayerMoney(playerid, -hInfo[i][HousePrice]);
                        pInfo[playerid][HouseKey] = i;
                        SavePlayer(playerid);
                        mysql_format(mysql, Query, sizeof(Query), "UPDATE `Houses` SET `HouseOwner` = '%s' WHERE `hID` = %i", hInfo[i][HouseOwner], i);
                        mysql_query(mysql, Query);
                        mysql_free_result();
                        print("CP: 7");
                    }
                    else return SendClientMessage(playerid, COLOR_WHITE, "You don't have enough money to purchase this house.");
                }
                else return SendClientMessage(playerid, COLOR_WHITE, "You already own a house.");
            }
            else return SendClientMessage(playerid, COLOR_WHITE, "This house isn't for sale.");
        }
    }
    return 1;
}
Reply
#9

---------------
Reply
#10

---------------------------------
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)