CMD:music(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: /music [url]"); if(!strcmp(params, "stop", true, 4)) { StopAudioStreamForPlayer(playerid); SendClientMessage(playerid, COLOR_LIGHTRED, " You have stopped listening to music."); return 1; } if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); format(string, sizeof(string), "AdmCmd: %s has started playing a song globally. ('/music stop' to stop listening)", RPN(playerid)); SendClientMessageToAll(COLOR_LIGHTRED, string); foreach(Player, i) { PlayAudioStreamForPlayer(i, params); } return 1; }
CMD:music(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: /music [url]");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0x00FF00AA,"You're not in a vehicle!");
if(!strcmp(params, "stop", true, 4))
{
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_LIGHTRED, " You have stopped listening to music.");
return 1;
}
if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
format(string, sizeof(string), "AdmCmd: %s has started playing a song globally. ('/music stop' to stop listening)", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
foreach(Player, i)
{
PlayAudioStreamForPlayer(i, params);
}
return 1;
}
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0x00FF00AA,"You're not in a vehicle!");
StopAudioStreamForPlayer under OnPlayerStateChange when oldstate is PLAYER_STATE_DRIVER or PLAYER_STATE_PASSENGER.
|
new radiostation[MAX_VEHICLES][128];
radiostation[vehicleid][128] = string;
PlayAudioStreamForPlayer(i, radiostation[vehicleid]);
well, you'll have to get a variable to save the radio station of each car and when they enter the car you'll just stream that for the player
something like: Код:
new radiostation[MAX_VEHICLES][128]; Код:
radiostation[vehicleid][128] = string; Код:
PlayAudioStreamForPlayer(i, radiostation[vehicleid]); |
CMD:music(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: /music [url]");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0x00FF00AA,"You're not in a vehicle!");
if(!strcmp(params, "stop", true, 4))
{
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_LIGHTRED, " You have stopped listening to music.");
MusicOn[playerid] = 0;
return 1;
}
if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
format(string, sizeof(string), "AdmCmd: %s has started playing a song globally. ('/music stop' to stop listening)", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
foreach(Player, i)
{
PlayAudioStreamForPlayer(i, params);
MusicOn[playerid] = 1;
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER )
{
if(MusicOn[playerid] == 1) return PlayAudioStream(blah blah)
}
else if(oldstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER && newstate == PPLAYER_STATE_ONFOOT )
{
StopAudioStream(blah blah)
}
return 1;
}