I was curious if there are any known limitations related to PLAY_SOUND_FROM_ENTITY - Cfx.re Docs
void PLAY_SOUND_FROM_ENTITY(int soundId, char* audioName, Entity entity, char* audioRef, BOOL p4, Any p5);
I have noticed that in Luxart Vehicle Control that after 100 vehicles with sirens on, the sirens fail, at car 99 they intermediately fail, and at 100 PLAY_SOUND_FROM_ENTITY simply does nothing. No errors. Game engine limitation?
_4iY
January 11, 2021, 4:26pm
2
Just to make sure, does that happen overall (over the whole server) or in a finite area?
Anywhere in the map. I have no clipped far from the issue and the problem still remains. Deleting vehicles down to 98 fixes the issue.
I do not think it is a game engine limitation but could be how this function works, I just don’t understand how.
function SetLxSirenStateForVeh(veh, newstate)
if DoesEntityExist(veh) and not IsEntityDead(veh) then
if newstate ~= state_lxsiren[veh] then
if snd_lxsiren[veh] ~= nil then
StopSound(snd_lxsiren[veh])
ReleaseSoundId(snd_lxsiren[veh])
snd_lxsiren[veh] = nil
end
snd_lxsiren[veh] = GetSoundId()
PlaySoundFromEntity(snd_lxsiren[veh], siren_string_lookup[newstate], veh, 0, 0, 0)
TogMuteDfltSrnForVeh(veh, true)
state_lxsiren[veh] = newstate
end
end
end
I have found some relevant information regarding ReleaseSoundId and GetSoundId, its regarding ■■■■ but same natives:
nta
January 11, 2021, 9:33pm
5
Given that we more accurately implement game script runtime functionality, releasing sound IDs should work fine on FiveM.
Your code does not appear to be doing so at this time.
Here is a log of what GetSoundId returns, I spawn 100 emergency vehicles, activate there sirens, never deactivating. At car 99 I am unable to change tones constantly.
[ 443828] [ GTAProcess] MainThrd/ Starting: 0 //Testing toggling siren
[ 444328] [ GTAProcess] MainThrd/ Stopping: 0
[ 444328] [ GTAProcess] MainThrd/ Starting: 1
[ 446250] [ GTAProcess] MainThrd/ Stopping: 1
[ 446250] [ GTAProcess] MainThrd/ Starting: 0
[ 446672] [ GTAProcess] MainThrd/ Stopping: 0
[ 446687] [ GTAProcess] MainThrd/ Starting: 1
[ 451219] [ GTAProcess] MainThrd/ Stopping: 1
[ 451219] [ GTAProcess] MainThrd/ Starting: 0
[ 451594] [ GTAProcess] MainThrd/ Stopping: 0
[ 451594] [ GTAProcess] MainThrd/ Starting: 1
[ 462250] [ GTAProcess] MainThrd/ Stopping: 1
[ 462265] [ GTAProcess] MainThrd/ Starting: 0
[ 468500] [ GTAProcess] MainThrd/ Stopping: 0
[ 468500] [ GTAProcess] MainThrd/ Starting: 1 //Begin spawning cars
[ 482219] [ GTAProcess] MainThrd/ Starting: 0
[ 484125] [ GTAProcess] MainThrd/ Starting: 2
[ 486219] [ GTAProcess] MainThrd/ Starting: 3
[ 488250] [ GTAProcess] MainThrd/ Starting: 4
[ 490656] [ GTAProcess] MainThrd/ Starting: 5
[ 492390] [ GTAProcess] MainThrd/ Starting: 6
[ 494437] [ GTAProcess] MainThrd/ Starting: 7
[ 496312] [ GTAProcess] MainThrd/ Starting: 8
[ 498172] [ GTAProcess] MainThrd/ Starting: 9
[ 500140] [ GTAProcess] MainThrd/ Starting: 10
[ 502265] [ GTAProcess] MainThrd/ Starting: 11
[ 503875] [ GTAProcess] MainThrd/ Starting: 12
[ 505937] [ GTAProcess] MainThrd/ Starting: 13
[ 508312] [ GTAProcess] MainThrd/ Starting: 14
[ 510187] [ GTAProcess] MainThrd/ Starting: 15
[ 512562] [ GTAProcess] MainThrd/ Starting: 16
[ 514625] [ GTAProcess] MainThrd/ Starting: 17
[ 516750] [ GTAProcess] MainThrd/ Starting: 18
[ 518640] [ GTAProcess] MainThrd/ Starting: 19
[ 520344] [ GTAProcess] MainThrd/ Starting: 20
[ 522437] [ GTAProcess] MainThrd/ Starting: 21
[ 524656] [ GTAProcess] MainThrd/ Starting: 22
[ 526765] [ GTAProcess] MainThrd/ Starting: 23
[ 528890] [ GTAProcess] MainThrd/ Starting: 24
[ 530515] [ GTAProcess] MainThrd/ Starting: 25
[ 532453] [ GTAProcess] MainThrd/ Starting: 26
[ 534531] [ GTAProcess] MainThrd/ Starting: 27
[ 536562] [ GTAProcess] MainThrd/ Starting: 28
[ 538500] [ GTAProcess] MainThrd/ Starting: 29
[ 540765] [ GTAProcess] MainThrd/ Starting: 30
[ 542969] [ GTAProcess] MainThrd/ Starting: 31
[ 544734] [ GTAProcess] MainThrd/ Starting: 32
[ 546640] [ GTAProcess] MainThrd/ Starting: 33
[ 548719] [ GTAProcess] MainThrd/ Starting: 34
[ 550937] [ GTAProcess] MainThrd/ Starting: 35
[ 552625] [ GTAProcess] MainThrd/ Starting: 36
[ 554687] [ GTAProcess] MainThrd/ Starting: 37
[ 556703] [ GTAProcess] MainThrd/ Starting: 38
[ 558828] [ GTAProcess] MainThrd/ Starting: 39
[ 560500] [ GTAProcess] MainThrd/ Starting: 40
[ 562406] [ GTAProcess] MainThrd/ Starting: 41
[ 564562] [ GTAProcess] MainThrd/ Starting: 42
[ 566578] [ GTAProcess] MainThrd/ Starting: 43
[ 568859] [ GTAProcess] MainThrd/ Starting: 44
[ 570515] [ GTAProcess] MainThrd/ Starting: 45
[ 572562] [ GTAProcess] MainThrd/ Starting: 46
[ 574390] [ GTAProcess] MainThrd/ Starting: 47
[ 576390] [ GTAProcess] MainThrd/ Starting: 48
[ 578484] [ GTAProcess] MainThrd/ Starting: 49
[ 580375] [ GTAProcess] MainThrd/ Starting: 50
[ 582312] [ GTAProcess] MainThrd/ Starting: 51
[ 584656] [ GTAProcess] MainThrd/ Starting: 52
[ 586531] [ GTAProcess] MainThrd/ Starting: 53
[ 588390] [ GTAProcess] MainThrd/ Starting: 54
[ 590375] [ GTAProcess] MainThrd/ Starting: 55
[ 592328] [ GTAProcess] MainThrd/ Starting: 56
[ 594344] [ GTAProcess] MainThrd/ Starting: 57
[ 596297] [ GTAProcess] MainThrd/ Starting: 58
[ 598609] [ GTAProcess] MainThrd/ Starting: 59
[ 600672] [ GTAProcess] MainThrd/ Starting: 60
[ 602734] [ GTAProcess] MainThrd/ Starting: 61
[ 604734] [ GTAProcess] MainThrd/ Starting: 62
[ 606656] [ GTAProcess] MainThrd/ Starting: 63
[ 608578] [ GTAProcess] MainThrd/ Starting: 64
[ 610531] [ GTAProcess] MainThrd/ Starting: 65
[ 612515] [ GTAProcess] MainThrd/ Starting: 66
[ 614437] [ GTAProcess] MainThrd/ Starting: 67
[ 616562] [ GTAProcess] MainThrd/ Starting: 68
[ 618828] [ GTAProcess] MainThrd/ Starting: 69
[ 620875] [ GTAProcess] MainThrd/ Starting: 70
[ 622953] [ GTAProcess] MainThrd/ Starting: 71
[ 624875] [ GTAProcess] MainThrd/ Starting: 72
[ 626812] [ GTAProcess] MainThrd/ Starting: 73
[ 628937] [ GTAProcess] MainThrd/ Starting: 74
[ 630953] [ GTAProcess] MainThrd/ Starting: 75
[ 632922] [ GTAProcess] MainThrd/ Starting: 76
[ 634984] [ GTAProcess] MainThrd/ Starting: 77
[ 636890] [ GTAProcess] MainThrd/ Starting: 78
[ 639062] [ GTAProcess] MainThrd/ Starting: 79
[ 640937] [ GTAProcess] MainThrd/ Starting: 80
[ 642719] [ GTAProcess] MainThrd/ Starting: 81
[ 644765] [ GTAProcess] MainThrd/ Starting: 82
[ 647031] [ GTAProcess] MainThrd/ Starting: 83
[ 649109] [ GTAProcess] MainThrd/ Starting: 84
[ 651125] [ GTAProcess] MainThrd/ Starting: 85
[ 652922] [ GTAProcess] MainThrd/ Starting: 86
[ 655125] [ GTAProcess] MainThrd/ Starting: 87
[ 657031] [ GTAProcess] MainThrd/ Starting: 88
[ 658984] [ GTAProcess] MainThrd/ Starting: 89
[ 661453] [ GTAProcess] MainThrd/ Starting: 90
[ 663234] [ GTAProcess] MainThrd/ Starting: 91
[ 665484] [ GTAProcess] MainThrd/ Starting: 92
[ 667312] [ GTAProcess] MainThrd/ Starting: 93
[ 669172] [ GTAProcess] MainThrd/ Starting: 94
[ 670750] [ GTAProcess] MainThrd/ Starting: 95
[ 672531] [ GTAProcess] MainThrd/ Starting: 96
[ 674750] [ GTAProcess] MainThrd/ Starting: 97
[ 676937] [ GTAProcess] MainThrd/ Starting: 98
[ 679500] [ GTAProcess] MainThrd/ Starting: 99
[ 687922] [ GTAProcess] MainThrd/ Stopping: 99
[ 687937] [ GTAProcess] MainThrd/ Starting: -1 //Failures Begin
[ 695531] [ GTAProcess] MainThrd/ Stopping: -1
[ 695531] [ GTAProcess] MainThrd/ Starting: 99
[ 696812] [ GTAProcess] MainThrd/ Stopping: 99
[ 696828] [ GTAProcess] MainThrd/ Starting: -1
[ 698062] [ GTAProcess] MainThrd/ Stopping: -1
[ 698078] [ GTAProcess] MainThrd/ Starting: 99
[ 698531] [ GTAProcess] MainThrd/ Stopping: 99
[ 698547] [ GTAProcess] MainThrd/ Starting: -1
[ 736844] [ GTAProcess] MainThrd/ Stopping: -1
[ 736859] [ GTAProcess] MainThrd/ Starting: 98 //Deleted vehicle | Working Below
[ 738469] [ GTAProcess] MainThrd/ Stopping: 98
[ 738484] [ GTAProcess] MainThrd/ Starting: 99
[ 739609] [ GTAProcess] MainThrd/ Stopping: 99
[ 739609] [ GTAProcess] MainThrd/ Starting: 98
[ 741109] [ GTAProcess] MainThrd/ Stopping: 98
[ 741109] [ GTAProcess] MainThrd/ Starting: 99
[ 743859] [ GTAProcess] MainThrd/ Stopping: 99
[ 743875] [ GTAProcess] MainThrd/ Starting: 98
[ 748390] [ GTAProcess] MainThrd/ Stopping: 98
[ 748390] [ GTAProcess] MainThrd/ Starting: 99
Functions:
function SetLxSirenStateForVeh(veh, newstate) //on siren button
if DoesEntityExist(veh) and not IsEntityDead(veh) then
if newstate ~= state_lxsiren[veh] then
if snd_lxsiren[veh] ~= nil then
print("Stopping: "..snd_lxsiren[veh])
StopSound(snd_lxsiren[veh])
ReleaseSoundId(snd_lxsiren[veh])
snd_lxsiren[veh] = nil
end
snd_lxsiren[veh] = GetSoundId()
print("Starting: "..snd_lxsiren[veh])
PlaySoundFromEntity(snd_lxsiren[veh], siren_string_lookup[newstate], veh, 0, 0, 0)
TogMuteDfltSrnForVeh(veh, true)
state_lxsiren[veh] = newstate
end
end
end
function CleanupSounds() //400th tick
if count_sndclean_timer > delay_sndclean_timer then
count_sndclean_timer = 0
for k, v in pairs(state_lxsiren) do
if v > 0 then
if not DoesEntityExist(k) or IsEntityDead(k) then
if snd_lxsiren[k] ~= nil then
StopSound(snd_lxsiren[k])
ReleaseSoundId(snd_lxsiren[k])
snd_lxsiren[k] = nil
state_lxsiren[k] = nil
end
end
end
end
else
count_sndclean_timer = count_sndclean_timer + 1
end
end
Resource: [Release] Luxart Vehicle Control
Setup Screenshot: https://i.gyazo.com/95224f5639e0d852a09033abed7aa5ed.jpg
Any ideas?
nta
January 12, 2021, 9:03am
7
TrevorBarns:
Any ideas?
Yeah, deactivate them if the car e.g. goes out of scope?! In what realistic case will you hit ‘100 sirens’ to be in scope at the same time, heh.
Anyway, R* limitation, would need some game RE to increase if at all possible/viable. However unlike that issue you linked you can see releasing IDs works fine here.