02.04.2011, 08:50
(
Last edited by PCheriyan007; 03/04/2011 at 02:18 AM.
)
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:
Here is the timer:
Here are the other timers' codes:
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.
Here are the variables:
pawn Code:
new RadioAd1[MAX_PLAYERS];
new RadioAd2[MAX_PLAYERS];
new RadioAd3[MAX_PLAYERS];
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;
}
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);
}