tomjscott@
Your code is continuously calling the Prompt command and the PlaySound0 command when you are standing within PlayerDist..
This is OK for the Prompt command ... but the PlaySound0 command will be
always being told to start the sound so never starts...
We need a new command IsSoundPlaying or something so we don't start the sound if it is already playing...
Or you could use a global variable something like this..
isPlaying = 0
function function_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 160 then
Prompt("Say something here");
if isPlaying < 1
isPlaying = 1
PlaySound0(e);
end
else
isPlaying = 0
end
end
We reset the isPlaying = 0 when we are greater than PlayerDist from entity..
Have not tried this but hope it will help...