House?
#1

Okay, I tried to make a dynamic house system but it failed it does save in to the Database.

The Code

pawn Код:
command(house, playerid, params[])
{
    GetPlayerPos(playerid, X, Y, Z);
    if(pStats[playerid][pAdminLevel] < 3)
    {
        return SendClientMessage(playerid, COLOR_GREY, ADMIN_CMD_ERROR);
    }
    else
    {
        CreatePickup(1273, 1, X, Y, Z, 0);
        SendClientMessage(playerid, COLOR_GREY, "[MYSQL DEBUG:] House Created");
    }
    format(Query, sizeof(Query), "INSERT INTO `Houses` (HPickupID, hExteriorX, hExteriorY, hExteriorZ) VALUES(%d, %f, %f, %f, %f)", HPickupID, hExteriorX, hExteriorY, hExteriorZ);
    mysql_query(Query);
    return 1;
}
The Code to Load the Houses
pawn Код:
stock InitHouses()
{
    new index;
    mysql_query("SELECT * FROM `House`");
    mysql_store_result();
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        if(mysql_num_rows() > 0)
        {
            while(mysql_fetch_row(Query))
            {
                sscanf(Query, "e<p<|>ddfffd>", House[index]);
                CreatePickup(1, 1, House[i][hExteriorX], House[i][hExteriorY], House[i][hExteriorZ], 0);
                index++;
            }
        }
        if(strcmp(House[i][hOwner], "Nobody", true) == 0)
        {
            House[i][LockStatus] = 0;
            House[i][HPickupID] = CreatePickup(1273, 1, House[i][hExteriorX], House[i][hExteriorY], House[i][hExteriorZ], 0);
        }
        else
        {
            House[i][HPickupID] = CreatePickup(1272, 1, House[i][hExteriorX], House[i][hExteriorY], House[i][hExteriorZ], 0);
        }
    }
    mysql_free_result();
    print("/n");
    printf("SERVER: Loaded %d MySQL Houses successfully.", index);
    return 1;
}
Reply
#2

Look at something like PEN, and then convert it to SQL.
Reply
#3

In your INSERT query you have 5 places to insert a variable, but you only define 4 of them.
Reply
#4

Quote:
Originally Posted by Marcel
Посмотреть сообщение
In your INSERT query you have 5 places to insert a variable, but you only define 4 of them.
Or he could have just watched the MySQL logs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)