SQL Help
#4

I've also got this:

pawn Код:
stock AddHouseToFile(HouseName, HouseOwner, HousePrice, Float:ExteriorX, Float:ExteriorY, Float:ExteriorZ, Float:InteriorX, Float:InteriorY, Float:InteriorZ)
{
    new
        Query[1024];

    format(Query, sizeof(Query), "INSERT INTO `houses` (HouseName, HouseOwner, HousePrice, ExteriorX, ExteriorY, ExteriorZ, InteriorX, InteriorY, InteriorZ) VALUES(%s[24], %s[24, %d, %f, %f, %f, %f, %f, %f)",
    HouseName, HouseOwner, HousePrice, ExteriorX, ExteriorY, ExteriorZ, InteriorX, InteriorY, InteriorZ);

    mysql_query(Query);
    mysql_free_result();
    return 1;
}
&

pawn Код:
stock AddHousesFromFiles()
{
    new
        Str[67],
        HouseName[24],
        HouseOwner[24],
        HousePrice,
        Float:ExteriorX,
        Float:ExteriorY,
        Float:ExteriorZ,
        Float:InteriorX,
        Float:InteriorY,
        Float:InteriorZ,
        hTotal;
       
    mysql_query("SELECT * FROM `houses`");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "s[24]s[24]dffffff", HouseName, HouseOwner, HousePrice, ExteriorX, ExteriorY, ExteriorZ, InteriorX, InteriorY, InteriorZ);
            CreatePickup(1273, 1, ExteriorX, ExteriorY, ExteriorZ, 0);
            Create3DTextLabel(HouseName, COLOR_GREY, ExteriorX, ExteriorY, ExteriorZ, 5.0, 0);
            hTotal++;
        }
    }
    mysql_free_result();
    printf("** %i\t<->\tHouses Loaded From\t<->\tMySQL\t\t   **", hTotal);
    return 1;
}
With this command:

pawn Код:
command(createhouse, playerid, params[])
{
    new Usage[128];
    if(sscanf(params, "s", Usage))
    {
        if(Player[playerid][pAdminLevel] >= 10)
        {
            SendClientMessage(playerid, GREY, "Server:  /createhouse [usage]");
            SendClientMessage(playerid, GREY, "Usage: Interior, Exterior or Complete.");
        }
    }
    else
    {
        if(Player[playerid][pAdminLevel] >= 10)
        {
            if(strcmp(Usage, "exterior", true) == 0)
            {
                new Float:X, Float:Y, Float:Z, NewHouseID;
                GetPlayerPos(playerid, X, Y, Z);
                SendFMessage(playerid, COLOR_GREY, "You have created a house at %f, %f, %f", X, Y, Z);
                Houses[NewHouseID][pHouseExteriorX] = X;
                Houses[NewHouseID][pHouseExteriorY] = Y;
                Houses[NewHouseID][pHouseExteriorZ] = Z;
            }
            if(strcmp(Usage, "interior", true) == 0)
            {
                new Float:X, Float:Y, Float:Z, NewHouseID;
                GetPlayerPos(playerid, X, Y, Z);
                SendFMessage(playerid, COLOR_GREY, "You have created a house interior at %f, %f, %f", X, Y, Z);
                Houses[NewHouseID][pHouseInteriorX] = X;
                Houses[NewHouseID][pHouseInteriorY] = Y;
                Houses[NewHouseID][pHouseInteriorZ] = Z;
            }
            if(strcmp(Usage, "complete", true) == 0)
            {
                new NewHouseID, HouseName, HouseOwner, HousePrice, Float:ExteriorX, Float:ExteriorY, Float:ExteriorZ, Float:InteriorX, Float:InteriorY, Float:InteriorZ;
                InteriorX = Houses[NewHouseID][pHouseInteriorX];
                InteriorY = Houses[NewHouseID][pHouseInteriorY];
                InteriorZ = Houses[NewHouseID][pHouseInteriorZ];
                ExteriorX = Houses[NewHouseID][pHouseExteriorX];
                ExteriorY = Houses[NewHouseID][pHouseExteriorY];
                ExteriorZ = Houses[NewHouseID][pHouseExteriorZ];
                SetPlayerPos(playerid, Houses[NewHouseID][pHouseExteriorX], Houses[NewHouseID][pHouseExteriorY], Houses[NewHouseID][pHouseExteriorZ]);
                HousePrice = 50000;
                Houses[NewHouseID][pHouseName] = HouseName;
                SendClientMessage(playerid, GREY, "House has been added.");
                AddHouseToFile(HouseName, HouseOwner, HousePrice, Float:ExteriorX, Float:ExteriorY, Float:ExteriorZ, Float:InteriorX, Float:InteriorY, Float:InteriorZ);
                CreatePickup(1273, 1, ExteriorX, ExteriorY, ExteriorZ, 0);
                Create3DTextLabel(Houses[NewHouseID][pHouseName], COLOR_GREY, Houses[NewHouseID][pHouseExteriorX], Houses[NewHouseID][pHouseExteriorY], Houses[NewHouseID][pHouseExteriorZ], 5.0, 0, 1);
            }
        }
    }
    return 1;
}
The houses don't save?

What's wrong with that?
Reply


Messages In This Thread
SQL Help - by iGetty - 11.01.2012, 15:09
Re: SQL Help - by iGetty - 13.01.2012, 18:23
Respuesta: SQL Help - by OPremium - 13.01.2012, 18:37
Re: SQL Help - by iGetty - 13.01.2012, 19:14

Forum Jump:


Users browsing this thread: 1 Guest(s)