PDA

View Full Version : Mysql r-41


Ryan50
14/02/2017, 01:34 AM
(2222) : warning 202: number of arguments does not match definition
(2225) : warning 219: local variable "ID" shadows a variable at a preceding level
(2228) : error 022: must be lvalue (non-constant)
(2228) : error 017: undefined symbol "cache_get_field_content_int"
(2228) : warning 215: expression has no effect
(2234) : error 017: undefined symbol "cache_get_field_content_int"
(2225) : warning 203: symbol is never used: "ID"
(2278) : error 017: undefined symbol "CamID"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.




enum SpeedTraps
{
Cam_ID,
Float:CamX,
Float:CamY,
Float:CamZ,
Float:CamAngle,
CamSpeed,
CamObj1,
CamObj2
}
new gCameras[MAX_CAMERAS][SpeedTraps];

CreateSpeedCamera(CamID, Float:x, Float:y, Float:z, Float:rot, MaxSpeed)
{
gCameras[CamID][Cam_ID] = CamID+1;
gCameras[CamID][CamX] = x;
gCameras[CamID][CamY] = y;
gCameras[CamID][CamZ] = z;
gCameras[CamID][CamAngle] = rot;
gCameras[CamID][CamSpeed] = MaxSpeed;
gCameras[CamID][CamObj1] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot);
//gCameras[CamID][CamObj2] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot + 180.0);
}

//Speed cam
forward LoadCams();
public LoadCams()
{
new rows = cache_get_row_count();
if(rows)
{
new i,ID;
while(i < rows)
{
ID = cache_get_field_content_int(i, "CamID")-1;
cache_get_value_name_float(i, "CamX", gCameras[ID][CamX]);
cache_get_value_name_float(i, "CamY", gCameras[ID][CamY]);
cache_get_value_name_float(i, "CamZ", gCameras[ID][CamZ]);
cache_get_value_name_float(i, "CamX", gCameras[ID][CamX]);
cache_get_value_name_float(i, "CamAngle", gCameras[ID][CamAngle]);
cache_get_field_content_int(i, "CamSpeed", gCameras[ID][CamSpeed]);
CreateSpeedCamera(ID, gCameras[ID][CamX], gCameras[ID][CamY], gCameras[ID][CamZ], gCameras[ID][CamAngle], gCameras[ID][CamSpeed]);
i++;
}
printf("Loaded %d cams",rows);
}
return 1;
}

CMD:addcam(playerid, params[])
{
new MaxSpeed;
if(sscanf(params, "i", MaxSpeed)) return SendClientMessage(playerid, -1, "Usage: /addcam [Max Speed]");

new Float:x, Float:y, Float:z, Float:Angle, string[128];
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, Angle);
SetPlayerPos(playerid, x, y + 1.0, z + 1.0);
for(new i=0; i < MAX_CAMERAS; i++)
{
if(!gCameras[i][Cam_ID])
{
CreateSpeedCamera(i, x, y, z-1.0, Angle, MaxSpeed);
format(string, sizeof(string),"INSERT INTO `Cams` VALUES (%d, %.4f, %.4f, %.4f, %.4f, %d);",i+1, x, y, z, Angle, MaxSpeed);
mysql_tquery(mysql, string);
format(string, sizeof(string), "You created a speed camera with ID: %i.", i+1);
SendClientMessage(playerid, -1, string);
return 1;
}
}
format(string, sizeof(string), "You cannot create more than %i speedcameras.", MAX_CAMERAS);
SendClientMessage(playerid, -1, string);
return 1;
}

CMD:delcam(playerid, params[])
{
new string[70];
for(new i; i < MAX_CAMERAS; i++)
if(gCameras[i][Cam_ID] > 0)
if(IsPlayerInRangeOfPoint(playerid, 5.0, gCameras[i][CamX], gCameras[i][CamY], gCameras[i][CamZ]))
{
format(string, sizeof(string), "DELETE FROM `Cams` WHERE `CamID`= %d", i+1);
mysql_tquery(connectionHandle, string);
if(gCameras[CamID][CamObj1] > 0)
DestroyDynamicObject(gCameras[i][CamObj1]);

if(gCameras[i][CamObj2] > 0)
DestroyDynamicObject(gCameras[i][CamObj2]);

gCameras[i][Cam_ID] = 0;
format(string, sizeof(string), "You deleted id camera %i", i+1);
SendClientMessage(playerid, -1, string);
break;
}

if(!string[0])
SendClientMessage(playerid, -1, "You're not near by an speed trap!");

return 1;
}

Rdx
14/02/2017, 11:48 AM
In MySQL R40 function cache_get_field_content was renamed.

renamed cache_get_field_content to cache_get_value_name (_int and _float likewise)
Source: https://github.com/pBlueG/SA-MP-MySQL/releases

Ryan50
14/02/2017, 11:49 AM
In MySQL R40 function cache_get_field_content was renamed.


Source: https://github.com/pBlueG/SA-MP-MySQL/releases

Still get errors.

Rdx
14/02/2017, 11:50 AM
So show them.

Ryan50
14/02/2017, 11:52 AM
So show them.

(2230) : warning 202: number of arguments does not match definition
(2236) : warning 202: number of arguments does not match definition
(2236) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


3 Warnings.



forward LoadCams();
public LoadCams()
{
new rows = cache_get_row_count();
if(rows)
{
new i;
while(i < rows)
{
cache_get_value_name_int(i, "CamID")-1;
cache_get_value_name_float(i, "CamX", gCameras[ID][CamX]);
cache_get_value_name_float(i, "CamY", gCameras[ID][CamY]);
cache_get_value_name_float(i, "CamZ", gCameras[ID][CamZ]);
cache_get_value_name_float(i, "CamX", gCameras[ID][CamX]);
cache_get_value_name_float(i, "CamAngle", gCameras[ID][CamAngle]);


cache_get_value_name_int(0, "CamSpeed", gCameras[ID][CamSpeed]);

CreateSpeedCamera(ID, gCameras[ID][CamX], gCameras[ID][CamY], gCameras[ID][CamZ], gCameras[ID][CamAngle], gCameras[ID][CamSpeed]);
i++;
}
printf("Loaded %d cams",rows);
}
return 1;
}

Rdx
14/02/2017, 11:58 AM
(2230)
(2236)
(2236)

Show these lines.

And i think problem is there:

cache_get_row_count();

This function needs argument.

Example from MySQL wiki:

new row_count;
if(!cache_get_row_count(row_count))
printf("couldn't retrieve row count");
else
printf("There are %d rows in the current result set.", row_count);

Ryan50
14/02/2017, 12:00 PM
(2230)
(2236)
(2236)

Show these lines.

Line 2230: new rows = cache_get_row_count();

Line 2236 : cache_get_value_name_int(i, "CamID")-1; <-- still the same error line as this (2236) : warning 215: expression has no effect

Rdx
14/02/2017, 12:01 PM
cache_get_value_name_int(i, "CamID")-1;

You can't use -1 here. And these line is wrong, you didnt placed destination array.

Example:

cache_get_value_name_int(i, "CamID", int_dest);

And about 2230, i've explained in previous post.

Ryan50
14/02/2017, 12:04 PM
You can't use -1 here. And these line is wrong, you didnt placed destination array.

And about 2230, i've explained in previous post.

fixed with cache_get_value_name_int(i, "CamID", gCameras[ID][Cam_ID]);

i only got one error


(2230) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
new rows = cache_get_row_count();

Rdx
14/02/2017, 12:11 PM
Replace it to:

new rows;
cache_get_row_count(rows);

Ryan50
14/02/2017, 12:14 PM
Replace it to:

It saved but have a problem it won't load the speedcam
OnGameModeInit:

mysql_tquery(mysql, "SELECT * FROM `cams` ORDER BY CamID ASC", "LoadCams");



/

CreateSpeedCamera(CamID, Float:x, Float:y, Float:z, Float:rot, MaxSpeed)
{
gCameras[CamID][Cam_ID] = CamID+1;
gCameras[CamID][CamX] = x;
gCameras[CamID][CamY] = y;
gCameras[CamID][CamZ] = z;
gCameras[CamID][CamAngle] = rot;
gCameras[CamID][CamSpeed] = MaxSpeed;
gCameras[CamID][CamObj1] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot);
//gCameras[CamID][CamObj2] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot + 180.0);
}

//Speed cam
forward LoadCams();
public LoadCams()
{

new rows;
cache_get_row_count(rows);
{
new i;
while(i < rows)
{
cache_get_value_name_int(i, "CamID", gCameras[ID][Cam_ID]);
cache_get_value_name_float(i, "CamX", gCameras[ID][CamX]);
cache_get_value_name_float(i, "CamY", gCameras[ID][CamY]);
cache_get_value_name_float(i, "CamZ", gCameras[ID][CamZ]);
cache_get_value_name_float(i, "CamX", gCameras[ID][CamX]);
cache_get_value_name_float(i, "CamAngle", gCameras[ID][CamAngle]);


cache_get_value_name_int(0, "CamSpeed", gCameras[ID][CamSpeed]);

CreateSpeedCamera(ID, gCameras[ID][CamX], gCameras[ID][CamY], gCameras[ID][CamZ], gCameras[ID][CamAngle], gCameras[ID][CamSpeed]);
i++;
}
printf("Loaded %d cams",rows);
}
return 1;
}

Rdx
14/02/2017, 12:18 PM
Any mysql errors in mysql.log?

printf("Loaded %d cams",rows);
Is that printing 0?

May be hard to help without test.

Ryan50
14/02/2017, 08:21 PM
Any mysql errors in mysql.log?


Is that printing 0?

May be hard to help without test.
the counting works if i create but it won't load
[15:11:54] [ERROR] error #1062 while executing query "INSERT INTO `cams` VALUES (1, -1603.1774, -2757.6096, 48.0013, 52.8374, 50);": Duplicate entry '1' for key 'PRIMARY'
[15:12:52] [ERROR] mysql_tquery: invalid connection handle '0'

format(string, sizeof(string),"INSERT INTO `cams` VALUES (%d, %.4f, %.4f, %.4f, %.4f, %d);",i+1, x, y, z, Angle, MaxSpeed);

Rdx
15/02/2017, 08:37 AM
Duplicate entry '1' for key 'PRIMARY'

It means script want to insert ID 1 again. You better place null instead of i+1 in insert into, it will use auto increment.

And how you get "[ID]" in LoadCams? It is not declared in that public.

Ryan50
15/02/2017, 11:35 AM
Duplicate entry '1' for key 'PRIMARY'

It means script want to insert ID 1 again. You better place null instead of i+1 in insert into, it will use auto increment.

And how you get "[ID]" in LoadCams? It is not declared in that public.

if i place null in the code it get an error

error 017: undefined symbol "NULL"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

format(string, sizeof(string),"INSERT INTO `cams` VALUES (%d, %.4f, %.4f, %.4f, %.4f, %d);",NULL, x, y, z, Angle, MaxSpeed);

http://i65.tinypic.com/e0li5d.png
http://i68.tinypic.com/2ywy1k6.png


it re-writes the IDS.

Runn3R
15/02/2017, 11:50 AM
Try "NULL" instead of 1.

format(string, sizeof(string),"INSERT INTO `cams` VALUES (NULL, %.4f, %.4f, %.4f, %.4f, %d);", x, y, z, Angle, MaxSpeed);

Ryan50
15/02/2017, 12:07 PM
Try "NULL" instead of 1.

format(string, sizeof(string),"INSERT INTO `cams` VALUES (NULL, %.4f, %.4f, %.4f, %.4f, %d);", x, y, z, Angle, MaxSpeed);

It still not loading and it reset the count .

mysql_tquery(mysql, "SELECT * FROM `cams` ORDER BY Cam_ID ASC", "LoadCams");

CreateSpeedCamera(CamID, Float:x, Float:y, Float:z, Float:rot, MaxSpeed)
{
gCameras[CamID][Cam_ID] = CamID+1;
gCameras[CamID][CamX] = x;
gCameras[CamID][CamY] = y;
gCameras[CamID][CamZ] = z;
gCameras[CamID][CamAngle] = rot;
gCameras[CamID][CamSpeed] = MaxSpeed;
gCameras[CamID][CamObj1] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot);
//gCameras[CamID][CamObj2] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot + 180.0);
}


forward LoadCams();
public LoadCams()
{

new rows;
cache_get_row_count(rows);
{
new i;
while(i < rows)
{
cache_get_value_name_int(i, "Cam_ID", gCameras[i][Cam_ID]);
cache_get_value_name_float(0, "CamX", gCameras[i][CamX]);
cache_get_value_name_float(0, "CamY", gCameras[i][CamY]);
cache_get_value_name_float(0, "CamZ", gCameras[i][CamZ]);
cache_get_value_name_float(0, "CamAngle", gCameras[i][CamAngle]);
cache_get_value_name_int(0, "CamSpeed", gCameras[i][CamSpeed]);

CreateSpeedCamera(i, gCameras[i][CamX], gCameras[i][CamY], gCameras[i][CamZ], gCameras[i][CamAngle], gCameras[i][CamSpeed]);
i++;
}
printf("Loaded %d cams",i);
}

return 1;
}




http://i65.tinypic.com/vxbymc.png

Runn3R
15/02/2017, 12:12 PM
Set CAM_ID as an auto_increment value if you want to use the NULL value.

And why are you doing camid + 1?

Ryan50
15/02/2017, 12:14 PM
Set CAM_ID as an auto_increment value if you want to use the NULL value.

And why are you doing camid + 1?

I'm using AUTO_INCREMENT in CAM_ID

what should gCameras[CamID][Cam_ID] = CamID+1; be?


should it be like this?/


forward LoadCams(CamID);
public LoadCams(CamID)


cause i see CreateSpeedCamera(CamID, Float:x, Float:y, Float:z, Float:rot, MaxSpeed)

Runn3R
15/02/2017, 12:22 PM
Well you tell me you are loading the auto_increment value from the database and using +1 on it for no reason.

And:
mysql_tquery(mysql, "SELECT * FROM `cams` ORDER BY Cam_ID ASC", "LoadCams");

Makes no sense you can just use this:
mysql_tquery(mysql, "SELECT * FROM `cams` WHERE 1", "LoadCams");

Cause it normally shows up from 1 to ∞.

Try now you missed the "where" clause.

Ryan50
15/02/2017, 08:30 PM
Well you tell me you are loading the auto_increment value from the database and using +1 on it for no reason.

And:
mysql_tquery(mysql, "SELECT * FROM `cams` ORDER BY Cam_ID ASC", "LoadCams");

Makes no sense you can just use this:
mysql_tquery(mysql, "SELECT * FROM `cams` WHERE 1", "LoadCams");

Cause it normally shows up from 1 to ∞.

Try now you missed the "where" clause.

Still won't load the speedcamera. but i'm sure it got to do with Cam_ID and CamID?

Ryan50
16/02/2017, 01:09 AM
bump

Ryan50
16/02/2017, 08:28 PM
bump

Ryan50
18/02/2017, 12:36 AM
Bump it's not loading

Ryan50
18/02/2017, 09:08 PM
bump why it's not calling the code

Ryan50
21/02/2017, 01:20 AM
Bump it's not calling the loading

[20:22:07] [ERROR] error #1062 while executing query "INSERT INTO `cams` VALUES (1, 2308.5476, -2342.9118, 13.5468, 322.7620, 6011313);": Duplicate entry '1' for key 'PRIMARY'

format(string, sizeof(string),"INSERT INTO `cams` VALUES (%d, %.4f, %.4f, %.4f, %.4f, %d);",i+1, x, y, z, Angle, MaxSpeed);


anyone know why it's not loading?

Ryan50
25/02/2017, 02:51 PM
Still not loading anyone?