House saving
#1

Fixed so code deleted due i dont want people to copy it
Reply
#2

You forgot to store and free the results.
Reply
#3

Where to put that?
Reply
#4

pawn Код:
COMMAND:createhouse(playerid, params[])
{
    new string[128], Float:X, Float:Y, Float:Z, HouseID, HPrice, MaxLevel, string2[128];
    format(string, sizeof(string), "SELECT HouseID, Houseprice, Houseowner, X, Y, Z FROM Houses WHERE HouseID = '%i'", UserStats[playerid][Name]);
    mysql_query(string);
    mysql_store_result();
    if (sscanf(params, "ii", HPrice, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
    else
    {
        // Find the first free HouseID
        for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
            if (AHouseData[HouseID][PickupID] == 0) // Check if an empty house-index has been found (PickupID is 0)
                break; // Stop searching, the first free HouseID has been found now


        if(HouseID < MAX_HOUSES)
        {
            GetPlayerPos(playerid, X, Y, Z);
            AHouseData[HouseID][HouseX] = X;
            AHouseData[HouseID][HouseY] = Y;
            AHouseData[HouseID][HouseZ] = Z;
            AHouseData[HouseID][Owned] = false;
            AHouseData[HouseID][Houseprice] = HPrice;
            House_CreateEntrance(HouseID);
        }
        format(string2, sizeof(string2), "INSERT INTO Houses SET `X` = '%f', `Y` = '%f',  `Z` = '%f', `Owned` = '%s', `Houseprice` = '%i' WHERE `HouseID` = '%i'", AHouseData[HouseID][HouseX],AHouseData[HouseID][HouseY],AHouseData[HouseID][HouseZ], AHouseData[HouseID][Owned], AHouseData[HouseID][Houseprice], AHouseData[HouseID]);
        mysql_query(string2);
    }
    mysql_free_result();
    return 1;
}
P.S I see you create the house into the command :S
Reply
#5

So how to do it so it doesnt do create IN the command? :S
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)