• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Help with sqlite floats
#1
Hello for some reason floats are being loaded normaly (Armour and health is 1 and cordinates are like 5169131981403219871320)

Code:
enum PlayerStats{
    Mode,// 0-not logged   1-logged
    Team,
    Skin,
    Money,
    Score,
    Float:Health,
    Float:Armour,
    Float:X,
    Float:Y,
    Float:Z};

new Player[MAX_PLAYERS][PlayerStats];

Code:
GetPlayerPos(playerid, Player[playerid][X], Player[playerid][Y], Player[playerid][Z]);
format(Query,sizeof(Query),"UPDATE `USERS` SET TEAM = '%d', SKIN = '%d', MONEY = '%d', SCORE = '%d', HEALTH = '%f', ARMOUR = '%f', X = '%f', Y = '%f', Z = '%f' WHERE `NAME` = '%s' COLLATE NOCASE",
Player[playerid][Team],
Player[playerid][Skin],
GetPlayerMoney(playerid),//
GetPlayerScore(playerid),//
GetPlayerHealth(playerid, Player[playerid][Health]),//
GetPlayerArmour(playerid, Player[playerid][Armour]),//
Player[playerid][X],//
Player[playerid][Y],//
Player[playerid][Z],//
DB_Escape(name));
db_query(Database, Query);

Code:
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));
Result = db_query(Database, Query);
if(db_num_rows(Result)){
new Field[ 20 ]; //Creating a field to retrieve the data
db_get_field_assoc(Result, "TEAM", Field, 30);
Player[playerid][Team] = strval(Field);
db_get_field_assoc(Result, "SKIN", Field, 30);
Player[playerid][Skin] = strval(Field);
db_get_field_assoc(Result, "MONEY", Field, 30);
Player[playerid][Money] = strval(Field);
db_get_field_assoc(Result, "SCORE", Field, 30);
Player[playerid][Score] = strval(Field);
db_get_field_assoc_float(Result, "HEALTH");
Player[playerid][Health] = floatstr(Field);
db_get_field_assoc_float(Result, "ARMOUR");
Player[playerid][Armour] = floatstr(Field);
db_get_field_assoc_float(Result, "X");
Player[playerid][X] = floatstr(Field);
db_get_field_assoc_float(Result, "Y");
Player[playerid][Y] = floatstr(Field);
db_get_field_assoc_float(Result, "Z");
Player[playerid][Z] = floatstr(Field);


Code:
format(Query, sizeof(Query), "INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `TEAM`, `SKIN`, `MONEY`, `SCORE`, `HEALTH`, `ARMOUR`, `X`, `Y`, `Z`) VALUES('%s','%s','%s', '0', '0', '0', '0', '%f', '%f', '%f', '%f', '%f')", DB_Escape(name), DB_Escape(inputtext), DB_Escape(ip));

Let me know if you need more code to understand, thank you
  Reply


Messages In This Thread
Help with sqlite floats - by Turk54721 - 2021-04-11, 12:12 PM
RE: Help with sqlite floats - by DandoRYx - 2021-04-11, 01:52 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-11, 03:12 PM
RE: Help with sqlite floats - by DandoRYx - 2021-04-11, 03:43 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-11, 04:49 PM
RE: Help with sqlite floats - by DandoRYx - 2021-04-11, 06:08 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-11, 06:43 PM
RE: Help with sqlite floats - by DandoRYx - 2021-04-11, 06:56 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-11, 07:46 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-12, 06:48 AM
RE: Help with sqlite floats - by DandoRYx - 2021-04-12, 01:17 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-12, 04:41 PM
RE: Help with sqlite floats - by DandoRYx - 2021-04-14, 03:30 PM
RE: Help with sqlite floats - by Turk54721 - 2021-04-16, 07:59 AM

Forum Jump: