[Tutorial] How to stream Shoutcast to your server
#18

You could use a variable to check if the player is already listening to the radio or not and display a message accordingly. Otherwise someone could easily abuse the radio command by sending too many requests to the ShoutCast server.

pawn Code:
new Radio[MAX_PLAYERS];

CMD:radio(playerid, params[])
{
    if(Radio[playerid] == 1) return SendClientMessage(playerid, -1, "You are already listening to the radio.");
    PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls");
    SendClientMessage(playerid, -1, "You are now listening to the Radio. Use /radiooff to turn off the radio.");
    Radio[playerid] = 1;
    return 1;
}

CMD:radiooff(playerid, params[])
{
    if(Radio[playerid] == 0) return SendClientMessage(playerid, -1, "You did not turn on the radio.");
    StopAudioStreamForPlayer(playerid);
    SendClientMessage(playerid, -1, "Radio turned off! Use /radio to turn on the radio.");
    Radio[playerid] = 0;
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)