Update NetworkCreateSynchronisedScene.md#1143
Update NetworkCreateSynchronisedScene.md#1143koketoo wants to merge 1 commit intocitizenfx:masterfrom
Conversation
Added an example code and a line in the description saying that the scene is replicated to everyone.
| while not NetworkHasControlOfEntity(sceneObject) do | ||
| NetworkRequestControlOfEntity(sceneObject) | ||
| Wait(0) | ||
| end |
There was a problem hiding this comment.
| while not NetworkHasControlOfEntity(sceneObject) do | |
| NetworkRequestControlOfEntity(sceneObject) | |
| Wait(0) | |
| end |
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
| NetworkRequestControlOfEntity(sceneObject) | ||
| Wait(0) | ||
| end | ||
| local animRot, animCo, animDict = GetEntityRotation(sceneObject), GetEntityCoords(sceneObject), 'anim@heists@ornate_bank@grab_cash' |
There was a problem hiding this comment.
| local animRot, animCo, animDict = GetEntityRotation(sceneObject), GetEntityCoords(sceneObject), 'anim@heists@ornate_bank@grab_cash' | |
| local animRot = GetEntityRotation(sceneObject) | |
| local animCoords = GetEntityCoords(sceneObject) | |
| local animDict = 'anim@heists@ornate_bank@grab_cash' |
Having multiple definitions on one line is hard to read, some abbreviations make the code hard to read.
| 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.
| cutScenes[i] = NetworkCreateSynchronisedScene(animCo, animRot, 2, true, false, 1065353216, 0, 1.3) -- We create the scene of our anim pack | |
| cutScenes[i] = NetworkCreateSynchronisedScene(animCoords, animRot, 2, true, false, 1065353216, 0, 1.3) -- We create the scene of our anim pack |
| ## Examples | ||
| ```lua | ||
| RegisterCommand('scenetest', function () | ||
| RequestModel('hei_p_m_bag_var22_arm_s') |
There was a problem hiding this comment.
| RequestModel('hei_p_m_bag_var22_arm_s') | |
| RequestModel(`hei_p_m_bag_var22_arm_s`) |
| ```lua | ||
| RegisterCommand('scenetest', function () | ||
| RequestModel('hei_p_m_bag_var22_arm_s') | ||
| while not HasModelLoaded('hei_p_m_bag_var22_arm_s') do Wait(0) end |
There was a problem hiding this comment.
| while not HasModelLoaded('hei_p_m_bag_var22_arm_s') do Wait(0) end | |
| while not HasModelLoaded(`hei_p_m_bag_var22_arm_s`) do Wait(0) end |
| 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 | ||
| 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.
| if i==2 then | |
| if i == 2 then |
| end | ||
|
|
||
| NetworkStartSynchronisedScene(cutScenes[1]) | ||
| Wait(1750) |
There was a problem hiding this comment.
If these can use GetAnimDuration then it probably should so it doesn't look like these are just magical numbers.
|
|
||
| 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 | ||
| 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.
reuse the previously localized declared `PlayerPedId()
|
|
||
| ## Examples | ||
| ```lua | ||
| RegisterCommand('scenetest', function () |
There was a problem hiding this comment.
Examples shouldn't be in a command.
| DeleteObject(bag) | ||
| DeleteObject(sceneObject) | ||
| RemoveAnimDict(animDict) | ||
| SetModelAsNoLongerNeeded('hei_prop_hei_cash_trolly_01') |
There was a problem hiding this comment.
| SetModelAsNoLongerNeeded('hei_prop_hei_cash_trolly_01') | |
| SetModelAsNoLongerNeeded(`hei_prop_hei_cash_trolly_01`) |
This can also probably be done directly after the model is created.
|
|
||
| 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. |
There was a problem hiding this comment.
| The scenes are replicated to everyone. |
Redundant information, this is what "networked" implies here.
Added an example code and a line in the description saying that the scene is replicated to everyone.