-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update NetworkCreateSynchronisedScene.md #1143
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ int NETWORK_CREATE_SYNCHRONISED_SCENE(float x, float y, float z, float xRot, flo | |||||||||
|
||||||||||
Creates a networked synchronized scene. | ||||||||||
Be sure to actually start the scene with [`NETWORK_START_SYNCHRONISED_SCENE`](#_0x9A1B3FCDB36C8697) after you're done adding peds or entities to the scene. | ||||||||||
The scenes are replicated to everyone. | ||||||||||
|
||||||||||
## Parameters | ||||||||||
* **x**: X coord of the scene position (If the scene is for an object, the position should be of the object's coordinates most of the time) | ||||||||||
|
@@ -28,3 +29,51 @@ Be sure to actually start the scene with [`NETWORK_START_SYNCHRONISED_SCENE`](#_ | |||||||||
## Return value | ||||||||||
Returns the network synchronized scene's handle. You can get information regarding the phase, rate etc of this synchronised scene by using local synchronized scene natives (e.g [`GET_SYNCHRONIZED_SCENE_PHASE`](#_0xE4A310B1D7FA73CC)). | ||||||||||
Do note that you need to get the local scene handle from the network scene handle (using [`NETWORK_GET_LOCAL_SCENE_FROM_NETWORK_ID`](#_0x02C40BF885C567B6)) and then pass the returned value to the local synchronized scene info natives. | ||||||||||
|
||||||||||
## Examples | ||||||||||
```lua | ||||||||||
RegisterCommand('scenetest', function () | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Examples shouldn't be in a command. |
||||||||||
RequestModel('hei_p_m_bag_var22_arm_s') | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
while not HasModelLoaded('hei_p_m_bag_var22_arm_s') do Wait(0) end | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
local bag = CreateObject('hei_p_m_bag_var22_arm_s', GetEntityCoords(PlayerPedId()), true, false, false) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please localize the |
||||||||||
local objectPos = vector4(103.4413, 332.7415, 111.2320, 303.7820) -- Random coords | ||||||||||
local sceneObject = CreateObject('hei_prop_hei_cash_trolly_01', objectPos, true, false, false) -- Diamond casino heist trolley prop | ||||||||||
while not NetworkHasControlOfEntity(sceneObject) do | ||||||||||
NetworkRequestControlOfEntity(sceneObject) | ||||||||||
Wait(0) | ||||||||||
end | ||||||||||
Comment on lines
+42
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This native is recommended to not be used ans is very buggy/broken, also if the player created it they should be the owner of the prop |
||||||||||
local animRot, animCo, animDict = GetEntityRotation(sceneObject), GetEntityCoords(sceneObject), 'anim@heists@ornate_bank@grab_cash' | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Having multiple definitions on one line is hard to read, some abbreviations make the code hard to read. |
||||||||||
RequestAnimDict(animDict) | ||||||||||
while not HasAnimDictLoaded(animDict) do Wait(0) end | ||||||||||
local animPack = { | ||||||||||
{"intro", "bag_intro"}, | ||||||||||
{"grab", "bag_grab", "cart_cash_dissapear"}, | ||||||||||
{"exit", "bag_exit"} | ||||||||||
} | ||||||||||
|
||||||||||
local cutScenes = {} | ||||||||||
|
||||||||||
for i=1, #animPack do -- For every anim pack we have in our table we execute this once | ||||||||||
cutScenes[i] = NetworkCreateSynchronisedScene(animCo, animRot, 2, true, false, 1065353216, 0, 1.3) -- We create the scene of our anim pack | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
NetworkAddPedToSynchronisedScene(PlayerPedId(), cutScenes[i], animDict, animPack[i][1], 1.5, -4.0, 1, 16, 1148846080, 0) -- We add the player with it's anim and some params that you can check in the native docs | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reuse the previously localized declared `PlayerPedId() |
||||||||||
NetworkAddEntityToSynchronisedScene(bag, cutScenes[i], animDict, animPack[i][2], 4.0, -8.0, 1) -- We add the bag because it also moves | ||||||||||
|
||||||||||
if i==2 then | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
NetworkAddEntityToSynchronisedScene(sceneObject, cutScenes[i], animDict, animPack[i][3], 4.0, -8.0, 1) -- If we're on the second scene we start removing the diamonds in it | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
NetworkStartSynchronisedScene(cutScenes[1]) | ||||||||||
Wait(1750) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these can use |
||||||||||
NetworkStartSynchronisedScene(cutScenes[2]) | ||||||||||
Wait(37000) -- This numbers have been achieved by testing, you could do it with GetAnimDuration() tho | ||||||||||
NetworkStartSynchronisedScene(cutScenes[3]) | ||||||||||
Wait(2000) | ||||||||||
ClearPedTasks(PlayerPedId()) | ||||||||||
DeleteObject(bag) | ||||||||||
DeleteObject(sceneObject) | ||||||||||
RemoveAnimDict(animDict) | ||||||||||
SetModelAsNoLongerNeeded('hei_prop_hei_cash_trolly_01') | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This can also probably be done directly after the model is created. |
||||||||||
end) | ||||||||||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant information, this is what "networked" implies here.