Xogy / xsound

Improved audio library for FiveM
MIT License
115 stars 82 forks source link

xsound server lua PlayUrlPos(source, name, url, volume, position, loop) calls not working #59

Closed reinhardjs closed 4 months ago

reinhardjs commented 4 months ago

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:

  1. Call PlayUrl or PlayUrlPos on server.lua
  2. add print('something') into xsound's server resource it self
  3. then look on in game console (press F8), then look at the screenshots i attached below
  4. 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 image

Suggested Solution

reinhardjs commented 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".....)

image

Xogy commented 4 months ago

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.

image image image image

So I will be closing your PR since it is working without editing anything else.

Xogy commented 4 months ago

image image

Also based on the error it looks like you have nil value for "name"

reinhardjs commented 4 months ago

I tested it on DLC level 2944 image

reinhardjs commented 4 months ago

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.

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:

  1. Call PlayUrl or PlayUrlPos on server.lua
  2. add print('something') into xsound's server resource it self
  3. then look on in game console (press F8), then look at the screenshots i attached below
  4. 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 image

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.

reinhardjs commented 4 months ago

image image

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?

reinhardjs commented 4 months ago

You can watch how I tested it here: https://youtu.be/UbGrjPFx_hk?t=15996

@Xogy

Xogy commented 4 months ago

You can watch how I tested it here: https://youtu.be/UbGrjPFx_hk?t=15996

@Xogy

image

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

image image

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.

image 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

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.