Help with Audio Plugin - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with Audio Plugin (
/showthread.php?tid=245846)
Random Variables -
PCheriyan007 - 02.04.2011
How would I be able to make it so that my script would select a random variable according to a timer.
Here are the variables:
pawn Code:
new RadioAd1[MAX_PLAYERS];
new RadioAd2[MAX_PLAYERS];
new RadioAd3[MAX_PLAYERS];
Here is the timer:
pawn Code:
forward Advertisements(playerid);
new Ad1;
new Ad2;
new Ad3;
SetTimer("Advertisements", 180000, true);
public Advertisements(playerid)
{
if(Listening[playerid] = 1)
{
if(RadioAd1[playerid] = 1)
{
Audio_Pause(Radio[playerid]);
Ad1 = SetTimer("RadioAdvert1", 29162, true);
Audio_PlayForAll(1);
}
else if(RadioAd2 = 1)
{
Audio_Pause(Radio[playerid]);
Ad2 = SetTimer("RadioAdvert2", 29833, true);
Audio_PlayForAll(2);
}
else if(RadioAd3 = 1)
{
Audio_Pause(Radio[playerid]);
Ad3 = SetTimer("RadioAdvert3", 33393, true);
Audio_PlayForAll(3);
}
}
return 1;
}
Here are the other timers' codes:
pawn Code:
public RadioAdvert1(playerid)
{
Audio_Resume(Radio[playerid]);
KillTimer(Ad1);
}
public RadioAdvert2(playerid)
{
Audio_Resume(Radio[playerid]);
KillTimer(Ad2);
}
public RadioAdvert3(playerid)
{
Audio_Resume(Radio[playerid]);
KillTimer(Ad3);
}
What I am doing is making it so whichever variable is selected it will play a sound and start a timer that is equivalent to the length of the sound. When the timer is done it will start playing the Radio Station that the player was listening to.