How could i?
#1

Ok, i got it to write the values, but when i do /henter [houseid] [level] [price] It inserts in to the database but when i go to add a second houses it writes the values from the first house, The ids are diffrent but it's got the same values

pawn Код:
forward SaveHouses();
public SaveHouses()
{
    new sql[512];
    new idx;

    //new coordsstring[512];
    //format(coordsstring, sizeof(coordsstring), "%s|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\n",
    //format(sql, sizeof(sql), "INSERT INTO property (Howner,Enterx,Enterz,Enterz,Exitx,Exity,Exitz,Hint,Hworld,Hprice,Rentprice,Hrentable,Hlocked,Hdrugs,Hmats,Hgun1,Hammo1,Hgun2,Hammo2,Hgun3,Hammo3,Hmoney,Howned,Hlevel) VALUES ('%s','$f','$f','$f','$f','$f','$f','%d,'%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')",
    format(sql, sizeof(sql), "INSERT INTO houses(Howner,Enterx,Entery,Enterz,Exitx,Exity,Exitz,Hint,Hworld,Hprice,Rentprice,Hrentable,Hlocked,Hdrugs,Hmats,Hgun1,Hammo1,Hgun2,Hammo2,Hgun3,Hammo3,Hmoney,Howned,Hlevel) VALUES ('%s','%f','%f','%f','%f','%f','%f',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
    //format(sql, sizeof(HouseInfo), "UPDATE houses SET Howner='%s', Enterx='%f', Entery='%f', Enterz='%f', Exitx='%f', Exity='%f',Exitz='%f',Hint=%d,Hworld=%d,Hprice=%d,Rentprice=%d,Hrentable=%d,Hlocked='%d',Hdrugs='%d',Hmats=%d,Hgun1=%d,Hammo1=%d,Hgun2=%d,Hammo2=%d,Hgun3=%d,Hammo3=%d,Hmoney=%d,Howned=%d,Hlevel=%d WHERE id=%d",
    HouseInfo[idx][hOwner],
    HouseInfo[idx][hEnterX],
    HouseInfo[idx][hEnterY],
    HouseInfo[idx][hEnterZ],
    HouseInfo[idx][hExitX],
    HouseInfo[idx][hExitY],
    HouseInfo[idx][hExitZ],
    HouseInfo[idx][EnterInterior],
    HouseInfo[idx][EnterWorld],
    HouseInfo[idx][hPrice],
    HouseInfo[idx][hRentPrice],
    HouseInfo[idx][hRentable],
    HouseInfo[idx][hLocked],
    HouseInfo[idx][hDrugs],
    HouseInfo[idx][hMaterials],
    HouseInfo[idx][hGun1],
    HouseInfo[idx][hGunAmmo1],
    HouseInfo[idx][hGun2],
    HouseInfo[idx][hGunAmmo2],
    HouseInfo[idx][hGun3],
    HouseInfo[idx][hGunAmmo3],
    HouseInfo[idx][hMoney],
    HouseInfo[idx][hOwned],
    HouseInfo[idx][hLevel]);
    idx++;
    mysql_query(sql);
    //  return 1;
    }
What is written in the database when i do /henter 2x
Код:
 	 	 	5	 	1739.51794	-1857.72742	13.41406	0.00000	0.00000	0.00000	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	1
 	 	 	4	 	1739.51794	-1857.72742	13.41406	0.00000	0.00000	0.00000	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	1
Reply
#2

anything?
Reply
#3

SHow us SaveHouses();
Reply
#4

It was converted from file to mysql

pawn Код:
forward SaveHouses();
public SaveHouses()
{
    new sql[384];
    new idx;
    while (idx < sizeof(HouseInfo))
    {
        //new coordsstring[512];
        //format(coordsstring, sizeof(coordsstring), "%s|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\n",
        format(sql, sizeof(sql), "UPDATE property SET Howner='%s', Enterx='%f', Entery='%f', Enterz='%f', Exitx='%f', Exity='%f',Exitz='%f',Hint=%d,Hworld=%d,Hprice=%d,Rentprice=%d,Hrentable=%d,Hlocked='%d',Hdrugs='%d',Hmats=%d,Hgun1=%d,Hammo1=%d,Hgun2=%d,Hammo2=%d,Hgun3=%d,Hammo3=%d,Hmoney=%d,Howned=%d,Hlevel=%d WHERE id=%d",
        HouseInfo[idx][hOwner],
        HouseInfo[idx][hEnterX],
        HouseInfo[idx][hEnterY],
        HouseInfo[idx][hEnterZ],
        HouseInfo[idx][hExitX],
        HouseInfo[idx][hExitY],
        HouseInfo[idx][hExitZ],
        HouseInfo[idx][EnterInterior],
        HouseInfo[idx][EnterWorld],
        HouseInfo[idx][hPrice],
        HouseInfo[idx][hRentPrice],
        HouseInfo[idx][hRentable],
        HouseInfo[idx][hLocked],
        HouseInfo[idx][hDrugs],
        HouseInfo[idx][hMaterials],
        HouseInfo[idx][hGun1],
        HouseInfo[idx][hGunAmmo1],
        HouseInfo[idx][hGun2],
        HouseInfo[idx][hGunAmmo2],
        HouseInfo[idx][hGun3],
        HouseInfo[idx][hGunAmmo3],
        HouseInfo[idx][hMoney],
        HouseInfo[idx][hOwned],
        HouseInfo[idx][hLevel],
        HouseInfo[idx][hId]);
        mysql_query(sql);
    //  return 1;
    }
    return 1;
}
/*        if(idx == 0)
        {
            file2 = fopen("South-WestRP/Houses/Houses.ini", io_write);
        }
        else
        {
            file2 = fopen("South-WestRP/Houses/Houses.ini", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
Reply
#5

Well its file anyway, but I can't find a bug in script, check if you have rewrited all as need etc
Reply
#6

If i put houses in the database and then use my command it updates them but i need that command to insert them in to the database so i can add houses in game
Reply
#7

R u filling in variables in that format() line? It ends with ','
Reply
#8

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
R u filling in variables in that format() line? It ends with ','
The one on the savehouses or the command?.
Reply
#9

Quote:
Originally Posted by ihatetn931
Посмотреть сообщение
The one on the savehouses or the command?.
At the savehouses callback.
Reply
#10

Query to insert something into database:

INSERT INTO table (column1,column2,column3) VALUES ('abcdefg','1','abc@email.com')
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)