16.01.2016, 15:19
PHP код:
CMD:editobject(playerid, params[])
{
new objectid;
if(sscanf(params, "d", objectid))
{
SendClientMessage(playerid, -1, "[USAGE]/editobject (objid)");
return 1;
}
EditDynamicObject(playerid, objectid);
return 1;
}
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ, Query[800];
GetObjectPos(objectid, oldX, oldY, oldZ);
GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
if(!playerobject)
{
if(!IsValidObject(objectid)) return 1;
SetObjectPos(objectid, fX, fY, fZ);
SetObjectRot(objectid, fRotX, fRotY, fRotZ);
}
if(response == EDIT_RESPONSE_UPDATE)
{
GetObjectPos(objectid, fX, fY, fZ);
GetObjectRot(objectid, fRotX, fRotY, fRotZ);
format(Query, sizeof(Query), "UPDATE loot SET objx = %f, objy = %f, objz = %f, objrx = %f, objry = %f, objrz = %f WHERE objid = %d",
fX, fY, fZ, fRotX, fRotY, fRotZ, objectid);
db_query(Loot, Query);
print(Query);
}
if(response == EDIT_RESPONSE_FINAL)
{
GetObjectPos(objectid, fX, fY, fZ);
GetObjectRot(objectid, fRotX, fRotY, fRotZ);
format(Query, sizeof(Query), "UPDATE loot SET objx = %f, objy = %f, objz = %f, objrx = %f, objry = %f, objrz = %f WHERE objid = %d",
fX, fY, fZ, fRotX, fRotY, fRotZ, objectid);
db_query(Loot, Query);
print(Query);
}
if(response == EDIT_RESPONSE_CANCEL)
{
if(!playerobject)
{
SetObjectPos(objectid, oldX, oldY, oldZ);
SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
}
else
{
SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
}
}
return 1;
}
PHP код:
if(response == EDIT_RESPONSE_FINAL)
{
GetObjectPos(objectid, fX, fY, fZ);
GetObjectRot(objectid, fRotX, fRotY, fRotZ);
format(Query, sizeof(Query), "UPDATE loot SET objx = %f, objy = %f, objz = %f, objrx = %f, objry = %f, objrz = %f WHERE objid = %d",
fX, fY, fZ, fRotX, fRotY, fRotZ, objectid);
db_query(Loot, Query);
print(Query);
}
Thanks