SA-MP Forums Archive
House saving - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House saving (/showthread.php?tid=303415)



House saving - thimo - 13.12.2011

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


Re: House saving - TheArcher - 13.12.2011

You forgot to store and free the results.


Re: House saving - thimo - 13.12.2011

Where to put that?


Re: House saving - TheArcher - 13.12.2011

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


Re: House saving - thimo - 13.12.2011

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