27.05.2015, 02:56
їWhat system try to develop?
Objects IG system with MySQL database.
їWhat problem I have?
My problem is this, the command /createobject [Object ID] everything works perfectly into the data but when using /editobject [ID], and when finished giving to customize the database object does not update the new coordinates.
Note: In the "" if (response == EDIT_RESPONSE_FINAL) "" place a SendClientMessage within it and when should give out the message of SendClientMessage, moves the object, not save the new coordinates, and shows the SendClientMessage.
їWhat is the problem?
Objects IG system with MySQL database.
їWhat problem I have?
My problem is this, the command /createobject [Object ID] everything works perfectly into the data but when using /editobject [ID], and when finished giving to customize the database object does not update the new coordinates.
Note: In the "" if (response == EDIT_RESPONSE_FINAL) "" place a SendClientMessage within it and when should give out the message of SendClientMessage, moves the object, not save the new coordinates, and shows the SendClientMessage.
їWhat is the problem?
PHP код:
COMMAND:editobject(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new id,count;
if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /editobject [object id]");
for(new i; i < sizeof(object); i++){
if(object[i][oScriptID] == id){
EditDynamicObject(playerid, object[i][oObjectID]);
count++;
break;
}
}
if(count == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error: That object ID do not exist.");
return 1;
}
return 1;
}
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
if(response == EDIT_RESPONSE_FINAL)
{
new query[258];
new Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz;
GetDynamicObjectPos(objectid,x,y,z);
GetDynamicObjectRot(objectid,rx,ry,rz);
for(new i; i < sizeof(object); i++){
if(object[i][oObjectID] == objectid){
object[i][oX] = fX;
object[i][oY] = fY;
object[i][oZ] = fZ;
object[i][roX] = fRotX;
object[i][roY] = fRotY;
object[i][roZ] = fRotZ;
format(dquery, sizeof(dquery), "UPDATE objects SET oX = %f, oY = %f, oZ = %f, roX = %f, roY = %f, roZ = %f WHERE ScriptID = %d",object[i][oX],object[i][oY],object[i][roX],object[i][roY],object[i][roZ],object[i][oZ],object[i][oScriptID]);
mysql_query(1, query);
DestroyDynamicObject(objectid);
object[i][oObjectID] = CreateDynamicObject(object[i][oModelID], object[i][oX], object[i][oY], object[i][oZ], object[i][roX], object[i][roY], object[i][roZ]);
break;
}
}
}
if(response == EDIT_RESPONSE_CANCEL)
{
for(new i; i < sizeof(object); i++){
if(object[i][oObjectID] == objectid){
DestroyDynamicObject(objectid);
object[i][oObjectID] = CreateDynamicObject(object[i][oModelID], object[i][oX], object[i][oY], object[i][oZ], object[i][roX], object[i][roY], object[i][roZ]);
break;
}
}
}
return 1;
}