loading houses from mysql.
#1

Hey,

first

im loading a name and description from a mysql database, wuts wrong (i got this from file based shit :P)

and im loading positions, but they dont load properly they go ingame to 0.0 0.0 0.0..

pawn Код:
public LoadHouse(houseid)
{
    MySQLConnect();
    new Data[1024];
    new Field[64];
    new rcnt = 1;
    format(query, sizeof(query), "SELECT * FROM houses WHERE house_id = '%d' LIMIT 1", houseid); samp_mysql_query(query); samp_mysql_store_result();
    samp_mysql_strtok(Field, "|", Data);
    while (samp_mysql_strtok(Field, "|", "")==1)
    {
        if(rcnt == 2) Houses[houseid][ex] = strval(Field);
        if(rcnt == 3) Houses[houseid][ey] = strval(Field);
        if(rcnt == 4) Houses[houseid][ez] = strval(Field);
        if(rcnt == 5) Houses[houseid][xx] = strval(Field);
        if(rcnt == 6) Houses[houseid][xy] = strval(Field);
        if(rcnt == 7) Houses[houseid][xz] = strval(Field);
        if(rcnt == 16) strmid(Houses[houseid][owner], Field, 0, strlen(Field), 255);
        if(rcnt == 17) strmid(Houses[houseid][descr], Field, 0, strlen(Field), 255); // Deleted other variables because you wont need em ;D
        rcnt++;
    }
    samp_mysql_free_result();
}
Reply
#2

Quote:
Originally Posted by Pandabeer1337
Hey,

first

im loading a name and description from a mysql database, wuts wrong (i got this from file based shit :P)

and im loading positions, but they dont load properly they go ingame to 0.0 0.0 0.0..

pawn Код:
public LoadHouse(houseid)
{
    MySQLConnect();
    new Data[1024];
    new Field[64];
    new rcnt = 1;
    format(query, sizeof(query), "SELECT * FROM houses WHERE house_id = '%d' LIMIT 1", houseid); samp_mysql_query(query); samp_mysql_store_result();
    samp_mysql_strtok(Field, "|", Data);
    while (samp_mysql_strtok(Field, "|", "")==1)
    {
        if(rcnt == 2) Houses[houseid][ex] = strval(Field);
        if(rcnt == 3) Houses[houseid][ey] = strval(Field);
        if(rcnt == 4) Houses[houseid][ez] = strval(Field);
        if(rcnt == 5) Houses[houseid][xx] = strval(Field);
        if(rcnt == 6) Houses[houseid][xy] = strval(Field);
        if(rcnt == 7) Houses[houseid][xz] = strval(Field);
        if(rcnt == 16) strmid(Houses[houseid][owner], Field, 0, strlen(Field), 255);
        if(rcnt == 17) strmid(Houses[houseid][descr], Field, 0, strlen(Field), 255); // Deleted other variables because you wont need em ;D
        rcnt++;
    }
    samp_mysql_free_result();
}
hm... not sure mate everything looks ok.
Reply
#3

1) Make sure its defined as a float in the MYSQL Table
2) Use floatstr not strval
And to Jeff, If you have nothing to say then dont post
Reply
#4

Quote:
Originally Posted by JeNkStAX
1) Make sure its defined as a float in the MYSQL Table
2) Use floatstr not strval
And to Jeff, If you have nothing to say then dont post
i was letting him know that at least someone looked at it.
Reply
#5

Quote:
Originally Posted by Jeff_Maxwell
Quote:
Originally Posted by JeNkStAX
1) Make sure its defined as a float in the MYSQL Table
2) Use floatstr not strval
And to Jeff, If you have nothing to say then dont post
i was letting him know that at least someone looked at it.
No, Its called Spam
Reply
#6

Quote:
Originally Posted by JeNkStAX
1) Make sure its defined as a float in the MYSQL Table
2) Use floatstr not strval
And to Jeff, If you have nothing to say then dont post
what should i use for simple coords like:

-1913.316162 1253.743408 19.500000

i got this: FLOAT( 6, 6 ) = good?
Reply
#7

What are you connecting to?

pawn Код:
MySQLConnect();
Reply
#8

Coordinates are floating point numbers.

Take a look at the "Float:" tag, and also at "floatstr".
Reply
#9

Quote:
Originally Posted by FUNExtreme
What are you connecting to?

pawn Код:
MySQLConnect();
thats my function to connect / check the connection ;P

Quote:
Originally Posted by kc
Coordinates are floating point numbers.

Take a look at the "Float:" tag, and also at "floatstr".
doh, im talking bout mysql shit >

so again:

what should i use for simple coords like:

-1913.316162 1253.743408 19.500000

i got this: FLOAT( 6, 6 ) = good?


edit: ERROR i got FLOAT( 4, 4) now, but its not working properly >.>

Код:
0 row(s) edited.
Warning: #1264 Out of range value adjusted for column 'ex' at row 1

UPDATE `samp`.`houses` SET `ex` = '-1913.316162' WHERE `houses`.`house_id` =1 LIMIT 1 ;
Reply
#10

meh, please read xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)