28.01.2015, 04:07
Hi im trying to create object like this with a command, but getting an error:
Creating the object:
Loading the actual object:
Error Log:
I don't understand why its printing an error about ObjectID when its clearly being used in LoadSingleObject function.. What should i do to fix this problem?
Creating the object:
pawn Код:
CMD:createobject(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsABuilder(playerid) && PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
new model,Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
if(sscanf(params, "i", model)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /createobject [model ID]");
format(dquery, sizeof(dquery), "INSERT INTO objects (ModelID, oX, oY, oZ, roX, roY, roZ) VALUES (%d, %f, %f, %f, %f, %f, %f)", model, x+2, y, z, 0, 0, 0); // ModelID
mysql_query(dquery,0,0,1);
mysql_function_query(1, "SELECT MAX(ScriptID) FROM objects", true, "LoadSingleObject", "iiffffffi", playerid, sizeof(object),x +2,y,z,0,0,0,model);
return 1;
}
pawn Код:
forward LoadSingleObject(playerid, limit,Float:x, Float:y, Float:z, Float:rox, Float:roy, Float:roz,modelid);
public LoadSingleObject(playerid, limit,Float:x, Float:y, Float:z, Float:rox, Float:roy, Float:roz, modelid)
{
new rows, fields, data[50], string[128];
cache_get_data(rows, fields);
for(new i; i < rows; i++)
{
for(new h; h <sizeof(object); h++)
{
if(object[h][oScriptID] == 0)
{
cache_get_field_content(i, "MAX(ScriptID)", data); object[h][oScriptID] = strval(data);
object[h][oModelID] = modelid;
object[h][oX] = x;
object[h][oY] = y;
object[h][oZ] = z;
object[h][roX] = rox;
object[h][roY] = roy;
object[h][roZ] = roz;
object[h][oObjectID] = CreateDynamicObject(object[h][oModelID], object[h][oX], object[h][oY], object[h][oZ], object[h][roX], object[h][roY], object[h][roZ]);
format(dstring, sizeof(dstring), "Object ID %d created. Objects Memory slot: %d",object[h][oScriptID],h);
SendClientMessage(playerid, COLOR_LIGHTBLUE, dstring);
format(dquery, sizeof(dquery), "UPDATE objects SET ObjectID = %d WHERE ScriptID = %d",object[h][oObjectID],object[h][oScriptID]);
mysql_query(dquery,0,0,1);
format(string, sizeof(string), "BuilderWarn: %s has created object ID %d. (Object: %d)", RPN(playerid), object[h][oScriptID], object[h][oObjectID]);
SendBuilderMessage(COLOR_GREEN, string);
break;
}
}
}
return 1;
}
pawn Код:
1364 Field 'ObjectID' doesn't have a default value OnQueryFinish INSERT INTO objects (ModelID, oX, oY, oZ, roX, roY, roZ) VALUES (1256, 1734.731567, -1860.233642, 13.578986, 0.000000, 0.000000, 0.000000) 1