Need some help with radio/CD player -
MichaelWharton101 - 28.03.2013
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;
}
Re: Need some help with radio/CD player -
Aprezt - 28.03.2013
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 ...
Re: Need some help with radio/CD player -
MichaelWharton101 - 28.03.2013
I mean so like just the person who uses /play can hear the music no one else
Re: Need some help with radio/CD player -
Joshman543 - 29.03.2013
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