PlayAudioStreamForPlayer ... can't seem to get it to work. -
Scenario - 13.01.2013
As the title of this topic says, I can't seem to get PlayAudioStreamForPlayer to work. Honestly, this damn function hardly ever works for me.
I have the audio file on two separate servers, neither one works.
This is my code:
pawn Code:
#include <a_samp>
#include <zcmd>
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(HOLDING(KEY_SUBMISSION))
{
new Float:fPos[3];
GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
PlayAudioStreamForPlayer(playerid, "http://infinitumgaming.com/sounds/dual_horn.mp3", fPos[0], fPos[1], fPos[2], 30.0, 1);
}
if(RELEASED(KEY_SUBMISSION))
{
new Float:fPos[3];
GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
StopAudioStreamForPlayer(playerid);
}
return 1;
}
It can also be found on:
http://ls-gov.us/pd/dual_horn.mp3
As you can tell, both of them play.
Can someone else see if this code works for them?
I have run the code on the bare game-mode script on my localhost, as well as the same server as the infinitumgaming.com/sounds/dual_horn.mp3 sound is hosted on.
I'm stumped.
Re: PlayAudioStreamForPlayer ... can't seem to get it to work. -
InActtive™ - 13.01.2013
Below your PlayAudioStreamForPlayer, create a
pawn Code:
SendClientMessage(playerid, -1, "On");
Below your StopAudioStreamForPlay, create a
pawn Code:
SendClientMessage(playerid, -1, "Off");
Now go ingame and press your hotkeys and check to see if both of them show up. If they don't then you command isn't even going through.. Tell me exactly what you see.
Re: PlayAudioStreamForPlayer ... can't seem to get it to work. -
Threshold - 13.01.2013
If they don't work, try using PRESSED instead.
pawn Code:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_SUBMISSION))
{
new Float:fPos[3];
GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
PlayAudioStreamForPlayer(playerid, "http://infinitumgaming.com/sounds/dual_horn.mp3", fPos[0], fPos[1], fPos[2], 30.0, 1);
}
else
{
//No need for getting positions here
StopAudioStreamForPlayer(playerid);
}
return 1;
}
Just give it a try.
Re: PlayAudioStreamForPlayer ... can't seem to get it to work. -
Scenario - 13.01.2013
I have already used SendClientMessage and print(), both if statements are being called.
Re: PlayAudioStreamForPlayer ... can't seem to get it to work. -
Vince - 13.01.2013
So, do you have the radio enabled in your GTA SA settings? The volume of the audio stream is affected by that setting.
Re: PlayAudioStreamForPlayer ... can't seem to get it to work. -
Konstantinos - 13.01.2013
Have you tried any other link for the music, just to make sure that it's not something with it.
Re: PlayAudioStreamForPlayer ... can't seem to get it to work. -
Scenario - 13.01.2013
... shoot me in the face someone, please.
Thank you, Vince!