SA-MP Forums Archive
House? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: House? (/showthread.php?tid=198535)



House? - Luis- - 12.12.2010

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;
}



Re: House? - DVDK - 12.12.2010

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


Re: House? - Marcel - 12.12.2010

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


Re: House? - DVDK - 12.12.2010

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.