streaming music problem
#1

Hello i was trying to making this music system actually it is limited range music but i wanted to play for all that who will came at music range but at this its works for 1 person that who use this commands so how can i play music for all people that who came at range thanks in advance
PHP код:
CMD:musicforall(playeridparams[])
{
        new 
Float:XFloat:YFloat:ZFloat:Distance 45.0;
        new 
url[200];
        if(
sscanf(params,"s[200]"url)) return SendClientMessage(playerid0x9C9C9CAA,"Syntax: /asdj[url]");
        foreach(new 
iPlayer)
        
GetPlayerPos(playeridXYZ);
        
PlayAudioStreamForPlayer(playeridurl1209.9148,762.6340,13.3429Distance1);
        return 
1;

Reply
#2

This isn't tested but should work fine...

Код:
CMD:musicforall(playerid, params[])
{
  	if(sscanf(params,"s[128]", params[0])) return SendClientMessage(playerid, -1, "Syntax: /musicforall [url]");
  	new Float:X, Float:Y, Float:Z;
  	GetPlayerPos(playerid, X, Y, Z);
   	foreach(new i: Player)
   	{
   	    if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z)) //Change "7.0" obviously, depending of the range that you want
   	    {
    		PlayAudioStreamForPlayer(i, params[0]);
	    }
	}
        return 1;
}
Reply
#3

No need to use sscanf for just one input. (nor foreach)

Код:
CMD:musicforall(playerid, params[]) 
{ 
    new Float: Pos[3];
    if(isnull(params))
        return SendClientMessage(playerid, -1, "/musicforall (url)");

    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); 
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 10.0, Pos[0], Pos[1], Pos[2]))
   	{
            PlayAudioStreamForPlayer(i, params);
	}
    }
    return 1; 
}
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
And that is why you don't post untested code.

Also, why use sscanf for one string?
Why not?, it's a better question considering you're the most experienced scripter who replied

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
No need to use sscanf for just one input. (nor foreach)

Код:
CMD:musicforall(playerid, params[]) 
{ 
    new Float: Pos[3];
    if(isnull(params))
        return SendClientMessage(playerid, -1, "/musicforall (url)");

    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); 
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 10.0, Pos[0], Pos[1], Pos[2]))
   	{
            PlayAudioStreamForPlayer(i, params);
	}
    }
    return 1; 
}
I thought using normal vars is better than using arrays for these cases
Reply
#5

Quote:
Originally Posted by lautaro97
Посмотреть сообщение
Why not?, it's a better question considering you're the most experienced scripter who replied



I thought using normal vars is better than using arrays for these cases
Yes normal variables are faster, it's just a habit. Feel free to change it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)