17.07.2014, 21:58
I can't seem to wrap my head around what i'm doing. This is an old project from a few months ago that I picked up today. It's a map editor. What i'm trying to do is have multiple 'projects' to enter and make my maps with. On the first project, all of the objects save fine. But on the second project, the first object over writes the first object in the other project and so forth. Because they are player objects, and deleted when you leave the project, I stored the object id given by the gamemode into a database, but i'm trying to get the id that is saved in the 'ID' in the database to update it, though i've had no success. This is what i've tried.
EDIT: to better explain, the bottom line of text, where it says "edited object 1" should say "Edited object 3"
pawn Code:
stock CreateSavingObject(playerid, Model, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Project)
{
new id = 0, Query[200], string[100];
id = CreatePlayerObject(playerid, Model, X, Y, Z, rX, rY, rZ);
format(Query,sizeof(Query), "INSERT INTO `OBJECTS` (`PROJECT`, `MODEL`, `PROJID`) VALUES (%d, %d, %d)", Project, Model, id);
mysql_query(Query);
format(Query, sizeof(Query), "SELECT `ID` FROM `OBJECTS` WHERE `PROJECT` = %d AND `PROJID` = %d)", Project, id);
mysql_query(Query);
mysql_store_result();
while(mysql_fetch_row_format(Query,"|"))
{
mysql_fetch_field_row(string, "ID"); id = strval(string);
}
mysql_free_result();
ObjectInfo[id][oX] = X;
ObjectInfo[id][oY] = Y;
ObjectInfo[id][oZ] = Z;
ObjectInfo[id][orX] = rX;
ObjectInfo[id][orY] = rY;
ObjectInfo[id][orZ] = rZ;
ObjectInfo[id][oModel] = Model;
ObjectInfo[id][oProject] = Project;
ObjectInfo[id][oProjid] = id;
format(string, sizeof(string), "You have created an object in slot %d.", id);
InfoMessage(pid, string);
EditPlayerObject(pid, id);
return 1;
}
