SA-MP Forums Archive
loading houses from mysql. - 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: loading houses from mysql. (/showthread.php?tid=71798)



loading houses from mysql. - Think - 03.04.2009

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



Re: loading houses from mysql. - Donvalley - 03.04.2009

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.


Re: loading houses from mysql. - ICECOLDKILLAK8 - 04.04.2009

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


Re: loading houses from mysql. - Donvalley - 04.04.2009

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.


Re: loading houses from mysql. - ICECOLDKILLAK8 - 04.04.2009

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


Re: loading houses from mysql. - Think - 04.04.2009

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?


Re: loading houses from mysql. - FUNExtreme - 04.04.2009

What are you connecting to?

pawn Код:
MySQLConnect();



Re: loading houses from mysql. - kc - 04.04.2009

Coordinates are floating point numbers.

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


Re: loading houses from mysql. - Think - 04.04.2009

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 ;



Re: loading houses from mysql. - Think - 04.04.2009

meh, please read xD