MySQL Problem - Loading a float ?
#1

How am i able to load a float from MySQL ?

This is my current code, all works fine except from the floats.

pawn Код:
new data[2][50]; //The data strings
            new data2[9]; //The data variables
            sscanf(line, "p|ssddddddfff", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data2[4], data2[5], data2[6], data2[7], data2[8]); //Splits the line with sscanf
            PInfo[playerid][Money] = data2[0];
            PInfo[playerid][AdminLevel] = data2[1];
            PInfo[playerid][Kills] = data2[2];
            PInfo[playerid][Deaths] = data2[3];
            PInfo[playerid][HoursPlayed] = data2[4];
            PInfo[playerid][Interior] = data2[5];
            PInfo[playerid][PosX] = data2[6];
            PInfo[playerid][PosY] = data2[7];
            PInfo[playerid][PosZ] = data2[8];
            mysql_free_result();
Thanks for the help..
Reply
#2

I don't recommend using mysql_free_result().
Reply
#3

Quote:
Originally Posted by Schurman
Посмотреть сообщение
I don't recommend using mysql_free_result().
Are you stupid?

It's loading statistics - it's an upcoming roleplay server so it's going to be pretty large when i'm finished with it.

I didn't ask for suggestions, i need the help..
Reply
#4

Create new variables to store the floats:
pawn Код:
new
    Float:fVars[3];

sscanf(line, "p|ssddddddfff", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data2[4], data2[5], fVars[0], fVars[1], fVars[2]); //Splits the line with sscanf

PInfo[playerid][PosX] = fVars[0];
PInfo[playerid][PosY] = fVars[1];
PInfo[playerid][PosZ] = fVars[2];
Reply
#5

Make sure your pos' are marked with Float:

for example

pawn Код:
new Float:PosX,Float:PosY,Float:PosZ;
EDIT: fuck, Lethal beat me to it.
Reply
#6

Schurman that was no way correct, at all.

Thanks l3th4l, i'll try that now.
EDIT: Works perfectly - Thanks alot !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)