Skip to content

Commit

Permalink
Merge pull request #824 from adib-yg/master
Browse files Browse the repository at this point in the history
Add more object functions docs
  • Loading branch information
adib-yg authored Jan 12, 2024
2 parents 0b523a4 + d14bc36 commit 7a5a8e5
Show file tree
Hide file tree
Showing 45 changed files with 1,927 additions and 69 deletions.
34 changes: 17 additions & 17 deletions docs/scripting/callbacks/OnPlayerEditAttachedObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ tags: ["player"]

This callback is called when a player ends attached object edition mode.

| Name | Description |
| -------------- | ------------------------------------------------------------- |
| playerid | The ID of the player that ended edition mode |
| response | 0 if they cancelled (ESC) or 1 if they clicked the save icon |
| index | The index of the attached object (0-9) |
| modelid | The model of the attached object that was edited |
| boneid | The bone of the attached object that was edited |
| Float:fOffsetX | The X offset for the attached object that was edited |
| Float:fOffsetY | The Y offset for the attached object that was edited |
| Float:fOffsetZ | The Z offset for the attached object that was edited |
| Float:fRotX | The X rotation for the attached object that was edited |
| Float:fRotY | The Y rotation for the attached object that was edited |
| Float:fRotZ | The Z rotation for the attached object that was edited |
| Float:fScaleX | The X scale for the attached object that was edited |
| Float:fScaleY | The Y scale for the attached object that was edited |
| Float:fScaleZ | The Z scale for the attached object that was edited |
| Name | Description |
|------------------------|--------------------------------------------------------------|
| playerid | The ID of the player that ended edition mode |
| EDIT_RESPONSE:response | 0 if they cancelled (ESC) or 1 if they clicked the save icon |
| index | The index of the attached object (0-9) |
| modelid | The model of the attached object that was edited |
| boneid | The bone of the attached object that was edited |
| Float:fOffsetX | The X offset for the attached object that was edited |
| Float:fOffsetY | The Y offset for the attached object that was edited |
| Float:fOffsetZ | The Z offset for the attached object that was edited |
| Float:fRotX | The X rotation for the attached object that was edited |
| Float:fRotY | The Y rotation for the attached object that was edited |
| Float:fRotZ | The Z rotation for the attached object that was edited |
| Float:fScaleX | The X scale for the attached object that was edited |
| Float:fScaleY | The Y scale for the attached object that was edited |
| Float:fScaleZ | The Z scale for the attached object that was edited |

## Returns

Expand Down Expand Up @@ -55,7 +55,7 @@ new ao[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][attached_object_data];

// The data should be stored in the above array when attached objects are attached.

public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
public OnPlayerEditAttachedObject(playerid, EDIT_RESPONSE:response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
if (response)
{
Expand Down
38 changes: 19 additions & 19 deletions docs/scripting/callbacks/OnPlayerEditObject.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
---
title: OnPlayerEditObject
description: This callback is called when a player finishes editing an object (EditObject/EditPlayerObject).
description: This callback is called when a player finishes editing an object (BeginObjectEditing/BeginPlayerObjectEditing).
tags: ["player"]
---

<VersionWarn name='callback' version='SA-MP 0.3e' />

## Description

This callback is called when a player finishes editing an object ([EditObject](../functions/EditObject)/[EditPlayerObject](../functions/EditPlayerObject)).

| Name | Description |
| ------------ | ------------------------------------------------------------------ |
| 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](../resources/objecteditionresponsetypes) |
| 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 is called when a player finishes editing an object ([BeginObjectEditing](../functions/BeginObjectEditing)/[BeginPlayerObjectEditing](../functions/BeginPlayerObjectEditing)).

| Name | Description |
|------------------------|-----------------------------------------------------------------|
| 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 |
| EDIT_RESPONSE:response | The [type of response](../resources/objecteditionresponsetypes) |
| 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:rotationX | The X rotation for the object that was edited |
| Float:rotationY | The Y rotation for the object that was edited |
| Float:rotationZ | The Z rotation for the object that was edited |

## Returns

Expand All @@ -34,7 +34,7 @@ It is always called first in filterscripts.
## Examples

```c
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
public OnPlayerEditObject(playerid, playerobject, objectid, EDIT_RESPONSE:response, Float:fX, Float:fY, Float:fZ, Float:rotationX, Float:rotationY, Float:rotationZ)
{
new
Float: oldX,
Expand All @@ -53,7 +53,7 @@ public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX,
return 1;
}
SetObjectPos(objectid, fX, fY, fZ);
SetObjectRot(objectid, fRotX, fRotY, fRotZ);
SetObjectRot(objectid, rotationX, rotationY, rotationZ);
}

switch (response)
Expand Down Expand Up @@ -95,8 +95,8 @@ When using 'EDIT_RESPONSE_UPDATE' be aware that this callback will not be called
The following functions might be useful, as they're related to this callback in one way or another.
- [EditPlayerObject](../functions/EditPlayerObject): Edit a player-object.
- [EditObject](../functions/EditObject): Edit an object.
- [BeginPlayerObjectEditing](../functions/BeginPlayerObjectEditing): Edit a player-object.
- [BeginObjectEditing](../functions/BeginObjectEditing): Edit an object.
- [CreateObject](../functions/CreateObject): Create an object.
- [DestroyObject](../functions/DestroyObject): Destroy an object.
- [MoveObject](../functions/MoveObject): Move an object.
28 changes: 14 additions & 14 deletions docs/scripting/callbacks/OnPlayerSelectObject.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
title: OnPlayerSelectObject
description: This callback is called when a player selects an object after SelectObject has been used.
description: This callback is called when a player selects an object after BeginObjectSelecting has been used.
tags: ["player"]
---

<VersionWarn name='callback' version='SA-MP 0.3e' />

## Description

This callback is called when a player selects an object after [SelectObject](../functions/SelectObject) has been used.
This callback is called when a player selects an object after [BeginObjectSelecting](../functions/BeginObjectSelecting) has been used.

| Name | Description |
| -------- | ---------------------------------------------------------- |
| playerid | The ID of the player that selected an object |
| type | The [type](../resources/selectobjecttypes) of selection |
| objectid | The ID of the selected object |
| modelid | The model of the selected object |
| Float:fX | The X position of the selected object |
| Float:fY | The Y position of the selected object |
| Float:fZ | The Z position of the selected object |
| Name | Description |
|--------------------|---------------------------------------------------------|
| playerid | The ID of the player that selected an object |
| SELECT_OBJECT:type | The [type](../resources/selectobjecttypes) of selection |
| objectid | The ID of the selected object |
| modelid | The model of the selected object |
| Float:fX | The X position of the selected object |
| Float:fY | The Y position of the selected object |
| Float:fZ | The Z position of the selected object |

## Returns

Expand All @@ -36,11 +36,11 @@ public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:f
printf("Player %d selected object %d", playerid, objectid);
if (type == SELECT_OBJECT_GLOBAL_OBJECT)
{
EditObject(playerid, objectid);
BeginObjectEditing(playerid, objectid);
}
else
{
EditPlayerObject(playerid, objectid);
BeginPlayerObjectEditing(playerid, objectid);
}
SendClientMessage(playerid, 0xFFFFFFFF, "You now are able to edit your object!");
return 1;
Expand All @@ -51,4 +51,4 @@ public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:f
The following functions might be useful, as they're related to this callback in one way or another.
- [SelectObject](../functions/SelectObject): Select an object.
- [BeginObjectSelecting](../functions/BeginObjectSelecting): Select an object.
42 changes: 25 additions & 17 deletions docs/scripting/functions/AttachObjectToObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,48 @@ tags: []

## Description

You can use this function to attach objects to other objects. The objects will folow the main object.

| Name | Description |
| ------------- | ----------------------------------------------------------------------- |
| objectid | The object to attach to another object. |
| attachtoid | The object to attach the object to. |
| Float:OffsetX | The distance between the main object and the object in the X direction. |
| Float:OffsetY | The distance between the main object and the object in the Y direction. |
| Float:OffsetZ | The distance between the main object and the object in the Z direction. |
| Float:RotX | The X rotation between the object and the main object. |
| Float:RotY | The Y rotation between the object and the main object. |
| Float:RotZ | The Z rotation between the object and the main object. |
| SyncRotation | If set to 0, objectid's rotation will not change with attachtoid's. |
You can use this function to attach objects to other objects. The objects will follow the main object.

| Name | Description |
|-------------------|---------------------------------------------------------------------------|
| objectid | The object to attach to another object. |
| attachtoid | The object to attach the object to. |
| Float:OffsetX | The distance between the main object and the object in the X direction. |
| Float:OffsetY | The distance between the main object and the object in the Y direction. |
| Float:OffsetZ | The distance between the main object and the object in the Z direction. |
| Float:RotX | The X rotation between the object and the main object. |
| Float:RotY | The Y rotation between the object and the main object. |
| Float:RotZ | The Z rotation between the object and the main object. |
| bool:SyncRotation | If set to `false`, objectid's rotation will not change with attachtoid's. |

## Returns

1: The function executed successfully.
`true` - The function executed successfully.

0: The function failed to execute. This means the first object (objectid) does not exist. There are no internal checks to verify that the second object (attachtoid) exists.
`false` - The function failed to execute. This means the first object (objectid) does not exist. There are no internal checks to verify that the second object (attachtoid) exists.

## Examples

```c
new gObjectId = CreateObject(...);
new gAttachToId = CreateObject(...);

AttachObjectToObject(gObjectId, gAttachToId, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1);
AttachObjectToObject(gObjectId, gAttachToId, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, true);
```
## Notes
:::tip
Both objects need to be created before attempting to attach them. There is no player-object version of this function (AttachPlayerObjectToObject), meaning it will not be supported by streamers.
Both objects need to be created before attempting to attach them.
:::
:::tip
There is no player-object version of this function in SA-MP.
But there is [AttachPlayerObjectToObject](AttachPlayerObjectToObject) in open.mp
:::
Expand Down
63 changes: 63 additions & 0 deletions docs/scripting/functions/AttachPlayerObjectToObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: AttachPlayerObjectToObject
description: You can use this function to attach player-objects to other player-objects.
tags: ["player", "object", "playerobject"]
---

<VersionWarn version='omp v1.1.0.2612' />

## Description

You can use this function to attach player-objects to other player-objects. The objects will follow the main object.

| Name | Description |
|-------------------|-------------------------------------------------------------------------|
| playerid | The ID of the player. |
| objectid | The player-object to attach to another player-object. |
| parentid | The object to attach the object to. |
| Float:OffsetX | The distance between the main object and the object in the X direction. |
| Float:OffsetY | The distance between the main object and the object in the Y direction. |
| Float:OffsetZ | The distance between the main object and the object in the Z direction. |
| Float:RotX | The X rotation between the object and the main object. |
| Float:RotY | The Y rotation between the object and the main object. |
| Float:RotZ | The Z rotation between the object and the main object. |
| bool:syncRotation | If set to `false`, objectid's rotation will not change with parentid's. |

## Returns

`true` - The function executed successfully.

`false` - The function failed to execute. This means the first object (objectid) does not exist. There are no internal checks to verify that the second object (parentid) exists.

## Examples

```c
new objectid = CreatePlayerObject(...);
new parentid = CreatePlayerObject(...);

AttachPlayerObjectToObject(playerid, objectid, parentid, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, true);
```
## Notes
:::tip
Both objects need to be created before attempting to attach them.
:::
## Related Functions
- [AttachObjectToObject](AttachObjectToObject): Attach an object to other object.
- [AttachObjectToPlayer](AttachObjectToPlayer): Attach an object to a player.
- [AttachObjectToVehicle](AttachObjectToVehicle): Attach an object to a vehicle.
- [AttachPlayerObjectToPlayer](AttachPlayerObjectToPlayer): Attach a player object to a player.
- [CreatePlayerObject](CreatePlayerObject): Create an object for only one player.
- [DestroyPlayerObject](DestroyPlayerObject): Destroy a player object.
- [IsValidPlayerObject](IsValidPlayerObject): Checks if a certain player object is vaild.
- [MovePlayerObject](MovePlayerObject): Move a player object.
- [StopPlayerObject](StopPlayerObject): Stop a player object from moving.
- [SetPlayerObjectPos](SetPlayerObjectPos): Set the position of a player object.
- [SetPlayerObjectRot](SetPlayerObjectRot): Set the rotation of a player object.
- [GetPlayerObjectPos](GetPlayerObjectPos): Locate a player object.
- [GetPlayerObjectRot](GetPlayerObjectRot): Check the rotation of a player object.
62 changes: 62 additions & 0 deletions docs/scripting/functions/BeginObjectEditing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: BeginObjectEditing
description: Allows a player to edit an object (position and rotation) using their mouse on a GUI (Graphical User Interface).
tags: ["player", "object"]
---

<VersionWarn version='omp v1.1.0.2612' />

## Description

Allows a player to edit an object (position and rotation) using their mouse on a GUI (Graphical User Interface).

| Name | Description |
| -------- | ------------------------------------------------- |
| playerid | The ID of the player that should edit the object. |
| objectid | The ID of the object to be edited by the player. |

## Returns

`true` - The function executed successfully. Success is reported when a non-existent object is specified, but nothing will happen.

`false` - The function failed to execute. The player is not connected.

## Examples

```c
new object;
public OnGameModeInit()
{
object = CreateObject(1337, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/oedit", true))
{
BeginObjectEditing(playerid, object);
SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: You can now edit the object!");
return 1;
}
return 0;
}
```
## Notes
:::tip
You can move the camera while editing by pressing and holding the spacebar (or W in vehicle) and moving your mouse.
:::
## Related Functions
- [CreateObject](CreateObject): Create an object.
- [DestroyObject](DestroyObject): Destroy an object.
- [MoveObject](MoveObject): Move an object.
- [BeginPlayerObjectEditing](BeginPlayerObjectEditing): Edit an object.
- [EditAttachedObject](EditAttachedObject): Edit an attached object.
- [BeginObjectSelecting](BeginObjectSelecting): Select an object.
- [EndObjectEditing](EndObjectEditing): Cancel the edition of an object.
Loading

0 comments on commit 7a5a8e5

Please sign in to comment.