03.04.2012, 16:58
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]
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
PlayAudioStreamForPlayer(i,"url");
}
}
foreach(Player, i)
PlayAudioStreamForPlayer( i, url );
for( new slots = GetMaxPlayers( ), i; i < slots; i++ )
{
if ( !IsPlayerConnected( i ) ) continue;
PlayAudioStreamForPlayer( i, "URL" );
}
pawn Код:
PS: Not faster than foreach... |
for(new i; i < MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; PlayAudioSteamForPlayer(i, "url"); }
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 |
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" ); }
for( new i = GetMaxPlayers( ); i < slots; i++ ) { if ( !IsPlayerConnected( i ) ) continue; PlayAudioStreamForPlayer( i, "URL" ); }