Need some help with radio/CD player
#1

Okay, so for the radio I need it to ONLY play for the people in the car.
Code:
CMD:radio(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /radio [url]");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be driving a car to use the radio.");
    format(string, sizeof(string), "%s switches the song on their radio to song '%s'.", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    format(string,sizeof(string),"http://americanrp.x10.mx/songs/%s",params);
    foreach(Player, i)
    {
        PlayAudioStreamForPlayer(i, string);
    }
    return 1;
}
But I still need it to show this '%s switches the song on their radio to song '%s'' to players around them.

Next thing, for the CD player i need this command to ONLY play for that player but still show the '%s switch thier CD player to song '%s''
Code:
CMD:play(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pCdplayer]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a CD player.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /play [url]");
   	if(IsPlayerInAnyVehicle(playerid))
	{
	    SendClientMessage(playerid, COLOR_GREY, "You need to be on foot to use this command.");
	    return 1;
	}
    format(string, sizeof(string), "%s switch thier CD player to song '%s'.", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    format(string,sizeof(string),"http://americanrp.x10.mx/songs/%s",params);
    foreach(Player, i)
    {
        PlayAudioStreamForPlayer(i, string);
    }
    return 1;
}
Reply
#2

pawn Code:
CMD:radio(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /radio [url]");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You need be on car when you want listen radio");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be driving a car to use the radio.");

    format(string, sizeof(string), "%s switches the song on their radio to song '%s'.", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    format(string,sizeof(string),"http://americanrp.x10.mx/songs/%s",params);
    foreach(Player, i)
    {
        PlayAudioStreamForPlayer(i, string);
    }
    return 1;
}
Other i cant understand what you want on CD player ...
Reply
#3

I mean so like just the person who uses /play can hear the music no one else
Reply
#4

pawn Code:
CMD:play(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pCdplayer]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a CD player.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /play [url]");
    if(IsPlayerInAnyVehicle(playerid))
    {
        SendClientMessage(playerid, COLOR_GREY, "You need to be on foot to use this command.");
        return 1;
    }
    format(string, sizeof(string), "%s switch thier CD player to song '%s'.", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    format(string,sizeof(string),"http://americanrp.x10.mx/songs/%s",params);
    PlayAudioStreamForPlayer(playerid, string);
    return 1;
}
You were using foreach, that's why
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)