Help making a global play command please
#1

Im trying to make a global play command for 0.3d's built in PlayAudioStreamForPlayer function, but I dont know how to go about doing it. Could anyone assist me? Im making the command /gplay [link here]
Reply
#2

pawn Код:
for(new i = 0;i<MAX_PLAYERS;i++)
    {
    if(IsPlayerConnected(i))
        {
        PlayAudioStreamForPlayer(i,"url");
        }
    }
Reply
#3

pawn Код:
foreach(Player, i)
    PlayAudioStreamForPlayer( i, url );
Reply
#4

pawn Код:
for( new slots = GetMaxPlayers( ), i; i < slots; i++ )
{
    if ( !IsPlayerConnected( i ) ) continue;

    PlayAudioStreamForPlayer( i, "URL" );
}
Fastest plain player-loop...
PS: Not faster than foreach...
Reply
#5

Quote:
Originally Posted by aRoach
Посмотреть сообщение
pawn Код:
for( new slots = GetMaxPlayers( ), i; i < slots; i++ )
{
    if ( !IsPlayerConnected( i ) ) continue;

    PlayAudioStreamForPlayer( i, "URL" );
}
Fastest plain player-loop...
PS: Not faster than foreach...
This would be faster, using MAX_PLAYERS or any variable defining the slots is faster than having to call GetMaxPlayers();

Код:
for(new i; i < MAX_PLAYERS; i++)
{
	if(!IsPlayerConnected(i))
		continue;

	PlayAudioSteamForPlayer(i, "url");
}
Reply
#6

Nope... GetMaxPlayers get exactly the number of max players, MAX_PLAYERS is only a define that, default is '500', the fastest is mine...
There is a prove: https://sampforum.blast.hk/showthread.php?tid=216730
Reply
#7

Quote:
Originally Posted by aRoach
Посмотреть сообщение
Nope... GetMaxPlayers get exactly the number of max players, MAX_PLAYERS is only a define that, default is '500', the fastest is mine...
There is a prove: https://sampforum.blast.hk/showthread.php?tid=216730
Its not faster, there was a thread comparing GetMaxPlayers to defines and it was proven that it is slower to use GetMaxPlayers, It is indeed faster to use a number than a function.
Reply
#8

Dude, the loop repeat 500 times, when you use the Define.
When you use GetMaxPlayers, the loop will repeat only .. times....
Reply
#9

Quote:
Originally Posted by aRoach
Посмотреть сообщение
Dude, the loop repeat 500 times, when you use the Define.
When you use GetMaxPlayers, the loop will repeat only .. times....
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
Reply
#10

Quote:
Originally Posted by aRoach
Посмотреть сообщение
Dude, the loop repeat 500 times, when you use the Define.
When you use GetMaxPlayers, the loop will repeat only .. times....
Код:
for( new slots = GetMaxPlayers( ), i; i < slots; i++ )
{
    if ( !IsPlayerConnected( i ) ) continue;

    PlayAudioStreamForPlayer( i, "URL" );
}
faster:
Код:
for( new i = GetMaxPlayers( ); i < slots; i++ )
{
    if ( !IsPlayerConnected( i ) ) continue;

    PlayAudioStreamForPlayer( i, "URL" );
}
You are creating slots variable and i variable in loop instead of only one variable doing the same...

And if you have MAX_PLAYERS defined as your max players slots, it's faster than GetMaxPlayers.

EDIT: 3 replies at -almost- same time, lol.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)