ProfVice

10-12-2014, 01:25 PM

Hello got a little problem on a script, the script readsout 3 Coordinates from an SQL DB and use a function to get if the player is in certain area defined by this 3 Coordinates.

so this is the code to readout the first X coordinate:

p0_x = WorldDBQuery("SELECT X1 FROM EventArea WHERE Map = " ..plr_map.. " AND AreaID= " ..area.. " ");

and it sends it to this:

local function ptInTriangle(p_x, p_y, p0_x, p0_y, p1_x, p1_y, p2_x, p2_y)

local A = 1/2 * (-p1_y * p2_x + p0_y * (-p1_x + p2_x) + p0_x * (p1_y - p2_y) + p1_x * p2_y);

....

but i just got an error that says: attempt to perform arithmetic on local p1_y (a userdata value)

so whats wrong? Do I need to convert the float of the SQL db to any other form of data to work within lua?

so this is the code to readout the first X coordinate:

p0_x = WorldDBQuery("SELECT X1 FROM EventArea WHERE Map = " ..plr_map.. " AND AreaID= " ..area.. " ");

and it sends it to this:

local function ptInTriangle(p_x, p_y, p0_x, p0_y, p1_x, p1_y, p2_x, p2_y)

local A = 1/2 * (-p1_y * p2_x + p0_y * (-p1_x + p2_x) + p0_x * (p1_y - p2_y) + p1_x * p2_y);

....

but i just got an error that says: attempt to perform arithmetic on local p1_y (a userdata value)

so whats wrong? Do I need to convert the float of the SQL db to any other form of data to work within lua?