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;
}
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;
}
Well its file anyway, but I can't find a bug in script, check if you have rewrited all as need etc
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
INSERT INTO table (column1,column2,column3) VALUES ('abcdefg','1','abc@email.com')