OnPlayerEditObject
From SA-MP Wiki
(Please add code to reset the object for the player if he exits the edition mode by pressing ESC (else clause without code))
This callback is called when a player ends object edition mode.
(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
| playerid | The ID of the player that edited an object |
| playerobject | 0 if it is a global object or 1 if it is a playerobject. |
| objectid | The ID of the edited object |
| response | The type of response |
| Float:fX | The X offset for the object that was edited |
| Float:fY | The Y offset for the object that was edited |
| Float:fZ | The Z offset for the object that was edited |
| Float:fRotX | The X rotation for the object that was edited |
| Float:fRotY | The Y rotation for the object that was edited |
| Float:fRotZ | The Z rotation for the object that was edited |
This callback does not handle returns.
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; GetObjectPos(objectid, oldX, oldY, oldZ); GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ); if(!playerobject) // If this is a global object, move it for other players { if(!IsValidObject(objectid)) return; MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ); } if(response == EDIT_RESPONSE_FINAL) { // The player clicked on the save icon // Do anything here to save the updated object position (and rotation) } if(response == EDIT_RESPONSE_CANCEL) { //The player cancelled, so put the object back to it's old position if(!playerobject) //Object is not a playerobject { SetObjectPos(objectid, oldX, oldY, oldZ); SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ); } else { SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ); SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ); } } }
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- EditObject: Edit an object.
- CreateObject: Create an object.
- DestroyObject: Destroy an object.
- MoveObject: Move an object.
