14.09.2017, 17:54
Hi, I have this filterscript.
It must play stream put in /speaker command. For example /speaker http://site.com/music.mp3
Problem is that it doesn't stream music for any player around.
What's fault is this?
It must play stream put in /speaker command. For example /speaker http://site.com/music.mp3
Problem is that it doesn't stream music for any player around.
What's fault is this?
PHP код:
#define FILTERSCRIPT
// Incl
#include <a_samp>
#include <streamer>
#include <foreach>
#include <zcmd>
#include <sscanf2>
// Defs
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0000FF
#define COLOR_LIGHTBLUE 0x33CCFFFF
#define COLOR_GREY 0xAFAFAFFF
public OnPlayerConnect(playerid)
{
DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ"); DeletePVar(playerid, "bboxareaid");
DeletePVar(playerid, "author");
if(IsValidDynamicObject(GetPVarInt(playerid, "BoomboxObject"))) DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
return 1;
}
public OnPlayerDisconnect(playerid)
{
if(GetPVarType(playerid, "BoomboxObject"))
{
DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "author"));
if(GetPVarType(playerid, "bboxareaid"))
{
foreach(new i : Player)
{
if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
{
StopAudioStreamForPlayer(i);
}
}
}
}
return 1;
}
CMD:speaker(playerid, params[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[GrandProject] Для доступа к данной команде нужен клиренс RCON уровня.");
new string[128];
if(!GetPVarType(playerid, "BoomboxObject"))
{
if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_RED, "[SH-SS][Помощь]: /speaker [URL]");
foreach(new i : Player)
{
if(GetPVarType(i, "BoomboxObject"))
{
if(IsPlayerInRangeOfPoint(playerid, 40.0, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ")))
{
SendClientMessage(playerid, COLOR_GREY, "[SH-SS] Рядом где-то уже есть спикер. Поставьте где-нибудь в другом месте.");
return 1;
}
}
}
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a);
SetPVarInt(playerid, "BoomboxObject", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
format(string, sizeof(string), "{FFFFFF}[SH-SS] Колонку поставил\n{FF0000}куратор %s", name);
SetPVarInt(playerid, "author", _:CreateDynamic3DTextLabel(string, 0xFFFFFFFF, x, y, z + 1.0, 20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
SetPVarFloat(playerid, "bposX", x); SetPVarFloat(playerid, "bposY", y); SetPVarFloat(playerid, "bposZ", z);
SetPVarInt(playerid, "bboxareaid", CreateDynamicSphere(x, y, z, 40.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
format(string, sizeof(string), "[SH-SS] Колонка выставлена на вашей позиции.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
foreach(new i : Player)
{
if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
{
PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
}
}
SetPVarString(playerid, "BoomboxURL", params);
}
else
{
DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "author"));
DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ");
if(GetPVarType(playerid, "bboxareaid"))
{
foreach(new i : Player)
{
if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
{
StopAudioStreamForPlayer(i);
}
}
DeletePVar(playerid, "bboxareaid");
}
SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SH-SS] Спикер убран.");
}
return 1;
}
CMD:setmusic(playerid, params[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[GrandProject] Для доступа к данной команде нужен клиренс RCON уровня.");
if(!GetPVarType(playerid, "BoomboxObject")) return SendClientMessage(playerid, COLOR_GREY, "[SH-SS] У Вас нет спикера.");
if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[SH-SS][Помощь]: /setmusic [URL]");
SendClientMessage(playerid, COLOR_GREY, "[SH-SS] Музыка успешно изменена.");
foreach(new i : Player)
{
if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
{
PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
}
}
SetPVarString(playerid, "BoomboxURL", params);
return 1;
}
public OnPlayerEnterDynamicArea(playerid, areaid)
{
foreach(new i : Player)
{
if(GetPVarType(i, "bboxareaid"))
{
new station[256];
GetPVarString(i, "BoomboxURL", station, sizeof(station));
if(areaid == GetPVarInt(i, "bboxareaid"))
{
PlayAudioStreamForPlayer(playerid, station, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ"), 30.0, 1);
return 1;
}
}
}
return 1;
}
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
foreach(new i : Player)
{
if(GetPVarType(i, "bboxareaid"))
{
if(areaid == GetPVarInt(i, "bboxareaid"))
{
StopAudioStreamForPlayer(playerid);
return 1;
}
}
}
return 1;
}