Closed reinhardjs closed 4 months ago
We should just keep our focus on fixing this part. Because the left part implementation is incorrect.
We should use table initialization like on the right side.
Because, if we used the left side, the listener keep receiving nil value.
So use the right side table initialization instead of the left then pass it to the TriggerClientEvent("xsound:stateSound".....)
You simply misunderstand how the function "TriggerClientEvent" works the arguments are following
(eventName, playerSourceID, ....)
I recommend checking out first docs for the triggerClientEvent
https://docs.fivem.net/docs/scripting-reference/runtimes/lua/functions/TriggerClientEvent/
Just in case I did testing if it wasn't working and it is not the case, most likely your implementation of the API is just wrong.
So I will be closing your PR since it is working without editing anything else.
Also based on the error it looks like you have nil value for "name"
I tested it on DLC level 2944
I mistakenly omitted the first parameter,
source
, on to theTriggerClientEvent
. It shouldn't be the first parameter, so I added a commit to revert it. After that, all my fixes were working correctly.
I mistakenly omitted the first parameter, source, on to the TriggerClientEvent. It shouldn't be the first parameter, so I added a commit to revert it. After that, all my fixes were working correctly.
Describe the bug I tried to call xsound from my server lua. the method I tried is PlayUrl and PlayUrlPos. It doesn't even play the sound or in other words, not working at all. It produces an error on the client console.
To Reproduce Steps to reproduce the behavior:
- Call PlayUrl or PlayUrlPos on server.lua
- add print('something') into xsound's server resource it self
- then look on in game console (press F8), then look at the screenshots i attached below
- See error
Expected behavior I expected the xsound working on the server side. Because i want to run xsound instance position updates only happen in server side. I want to attach sound into npc ped, so everytime the ped moved, it also update the xsound instance position.
Screenshots
Suggested Solution
- Change the way of sending data to the RegisterNetEvent listener on the client.
I mistakenly omitted the first parameter, source, on to the TriggerClientEvent. It shouldn't be the first parameter, so I added a commit to revert it. After that, all my fixes were working correctly.
Also based on the error it looks like you have nil value for "name"
No, actually, I have made sure that nothing is nil first. Trust me, it is an issue 😅. You can try logging both on the client listener and at the place where the server triggers.
If you find it to be a bug, could you consider reopening my pull request?
You can watch how I tested it here: https://youtu.be/UbGrjPFx_hk?t=15996
@Xogy
You can watch how I tested it here: https://youtu.be/UbGrjPFx_hk?t=15996
@Xogy
yes I do see and this proves the point I mentioned above that the "name" is nil
Also based on the code + error message you have in your console here
Neither the first or second arguments have any value meaning they're nil values. ( for some reason you kept changing during the stream the "source" for string, double, and number) but even an hour later ( fast skip ) the name argument is still not being initialized anywhere.
at 4 hours and 16 minutes, you changed the argument from non-existent to something that has already value but unfortunately because of the extra argument "source" in the "RegisterNetEvent" it didn't have any value.
You can just do a simple debug of arguments and it will tell you which arguments have what values.
Correct values should be this
function PlayUrlPos(source, name_, url_, volume_, pos, loop_)
print("PlayUrlPos", source, name_, url_, volume_, pos, loop_)
TriggerClientEvent("xsound:stateSound", source, "playpos", {
soundId = name_,
position = pos,
url = url_,
volume = volume_,
loop = loop_
})
end
Anything else is wrong.
The PR you made is pretty much the same code just in different colors there are no differences between what you did with the table vs what I have done.
So I simply won't be accepting it because as I mentioned the implementation was simply wrong.
ChatGPT isn't always a reliable way how to do things, you always have to verify the output it gives you.
Everyone makes mistakes it happens I do too. But this is not xsound fault but your implementation which I already showed you above what was wrong and what have you fixed.
With this, I don't have anything else to contribute to this conversation.
Describe the bug I tried to call xsound from my server lua. the method I tried is PlayUrl and PlayUrlPos. It doesn't even play the sound or in other words, not working at all. It produces an error on the client console.
To Reproduce Steps to reproduce the behavior:
Expected behavior I expected the xsound working on the server side. Because i want to run xsound instance position updates only happen in server side. I want to attach sound into npc ped, so everytime the ped moved, it also update the xsound instance position.
Screenshots
Suggested Solution