Mysql_function_query problem. -
Larry123 - 02.03.2014
I have this code.
Код:
new query[350];
format(query, sizeof(query), "INSERT INTO `scriptcars` (`CarType`, `UserGroupID`, `Model`, `Color1`, `Color2`, `PosX`, `PosY`, `PosZ`, `Angle`,`ParkX`, `ParkY`, `ParkZ`, `ParkAngle`, `Fuel`, `Health`) VALUES ('2', '%d', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '100', '100')", grupp, mode, colo1, colo2, Pos[0], Pos[1], Pos[2], Pos[3], Pos[0], Pos[1], Pos[2], Pos[3]);
mysql_function_query(gSQL, query, true, "LoadingSCar", "i", mysql_insert_id());
The problem is, that that won`t give the right parameter, mysql_insert_id should be "8", but its always 0.
Код:
publicEx LoadingSCar(carSql)
{
// PROBLEM ---> carSql = 0 <<<----- Always
new rows, fields;
cache_get_data(rows, fields, gSQL);
new temp[40];
cache_get_field_content(carSql, "ID", temp), ScriptCarInfo[carSql][ID] = strval(temp),
cache_get_field_content(carSql, "CarType", temp), ScriptCarInfo[carSql][CarType] = strval(temp),
cache_get_field_content(carSql, "UserGroupID", temp), ScriptCarInfo[carSql][UserGroupID] = strval(temp),
cache_get_field_content(carSql, "Model", temp), ScriptCarInfo[carSql][Model] = strval(temp),
cache_get_field_content(carSql, "Color1", temp), ScriptCarInfo[carSql][Color1] = strval(temp),
cache_get_field_content(carSql, "Color2", temp), ScriptCarInfo[carSql][Color2] = strval(temp),
cache_get_field_content(carSql, "PosX", temp), ScriptCarInfo[carSql][PosX] = floatstr(temp),
cache_get_field_content(carSql, "PosY", temp), ScriptCarInfo[carSql][PosY] = floatstr(temp),
cache_get_field_content(carSql, "PosZ", temp), ScriptCarInfo[carSql][PosZ] = floatstr(temp),
cache_get_field_content(carSql, "Angle", temp), ScriptCarInfo[carSql][Angle] = floatstr(temp),
cache_get_field_content(carSql, "ParkX", temp), ScriptCarInfo[carSql][ParkX] = floatstr(temp),
cache_get_field_content(carSql, "ParkY", temp), ScriptCarInfo[carSql][ParkY] = floatstr(temp),
cache_get_field_content(carSql, "ParkZ", temp), ScriptCarInfo[carSql][ParkZ] = floatstr(temp),
cache_get_field_content(carSql, "ParkAngle", temp), ScriptCarInfo[carSql][ParkAngle] = floatstr(temp),
cache_get_field_content(carSql, "Health", temp), ScriptCarInfo[carSql][Health] = floatstr(temp);
}
How could i fix it?
Re: Mysql_function_query problem. -
Richie© - 02.03.2014
Put insert id inside Loadinscar callback.
Re: Mysql_function_query problem. -
Larry123 - 02.03.2014
I forgot to tell you one thing, when gamemode starts, it will load my cars like that, so it would mess it up when i add mysql_insert_id over there.
Код:
publicEx LoadingSCars()
{
new rows, fields;
cache_get_data(rows, fields, gSQL);
new load;
if(rows)
{
while(load < rows)
{
LoadingSCar(load);
load ++;
}
}
return 1;
}
Maybe i can do somekind of
"Define.."
and
"IfDefined.."
or something?
Or other suggestions? I don`t have the other idea to make them double.
Re: Mysql_function_query problem. -
Richie© - 02.03.2014
Make 2 functions. Mysql_insert_id will always return 0 the way you are using it now.
Re: Mysql_function_query problem. -
Larry123 - 02.03.2014
So you mean, i should do one specially for the INSERT-ing and one specially for the loading cars when gm starts?
Re: Mysql_function_query problem. -
Richie© - 02.03.2014
Yup.
Re: Mysql_function_query problem. -
Larry123 - 02.03.2014
I got this that way :P
Код:
#define AddingCar
new query[350];
format(query, sizeof(query), "INSERT INTO `scriptcars` (`CarType`, `UserGroupID`, `Model`, `Color1`, `Color2`, `PosX`, `PosY`, `PosZ`, `Angle`,`ParkX`, `ParkY`, `ParkZ`, `ParkAngle`, `Fuel`, `Health`) VALUES ('2', '%d', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '100', '100')", grupp, mode, colo1, colo2, Pos[0], Pos[1], Pos[2], Pos[3], Pos[0], Pos[1], Pos[2], Pos[3]);
mysql_function_query(gSQL, query, true, "LoadingSCar", "i", mysql_insert_id());
Код:
publicEx LoadingSCar(carSql)
{
#if defined AddingCar
carSql = mysql_insert_id();
#endif
new rows, fields;
cache_get_data(rows, fields, gSQL);
new temp[40];
cache_get_field_content(carSql, "ID", temp), ScriptCarInfo[carSql][ID] = strval(temp),
cache_get_field_content(carSql, "CarType", temp), ScriptCarInfo[carSql][CarType] = strval(temp),
cache_get_field_content(carSql, "UserGroupID", temp), ScriptCarInfo[carSql][UserGroupID] = strval(temp),
cache_get_field_content(carSql, "Model", temp), ScriptCarInfo[carSql][Model] = strval(temp),
cache_get_field_content(carSql, "Color1", temp), ScriptCarInfo[carSql][Color1] = strval(temp),
cache_get_field_content(carSql, "Color2", temp), ScriptCarInfo[carSql][Color2] = strval(temp),
cache_get_field_content(carSql, "PosX", temp), ScriptCarInfo[carSql][PosX] = floatstr(temp),
cache_get_field_content(carSql, "PosY", temp), ScriptCarInfo[carSql][PosY] = floatstr(temp),
cache_get_field_content(carSql, "PosZ", temp), ScriptCarInfo[carSql][PosZ] = floatstr(temp),
cache_get_field_content(carSql, "Angle", temp), ScriptCarInfo[carSql][Angle] = floatstr(temp),
cache_get_field_content(carSql, "ParkX", temp), ScriptCarInfo[carSql][ParkX] = floatstr(temp),
cache_get_field_content(carSql, "ParkY", temp), ScriptCarInfo[carSql][ParkY] = floatstr(temp),
cache_get_field_content(carSql, "ParkZ", temp), ScriptCarInfo[carSql][ParkZ] = floatstr(temp),
cache_get_field_content(carSql, "ParkAngle", temp), ScriptCarInfo[carSql][ParkAngle] = floatstr(temp),
cache_get_field_content(carSql, "Health", temp), ScriptCarInfo[carSql][Health] = floatstr(temp);
#if defined AddingCar
#undef AddingCar
#endif
}
Thank you