Play sound for all players -
MathijsS - 27.11.2011
hello.
I made a simple countdown from 5 till start, butt i want i with sound. I have no idee, butt what i now have does'nt work. Here is my code:
Код:
forwarding:
forward b1(playerid);
forward b2(playerid);
forward b3(playerid);
forward b4(playerid);
forward b5(playerid);
forward b6(playerid);
the countdown
public b1(playerid)
{
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}5...");
GameTextForAll("~b~5...",1000,3);
}
public b2(playerid)
{
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}4...");
GameTextForAll("~b~4...",1000,3);
}
public b3(playerid)
{
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}3...");
GameTextForAll("~b~3...",1000,3);
}
public b4(playerid)
{
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}2...");
GameTextForAll("~b~2...",1000,3);
}
public b5(playerid)
{
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}1...");
GameTextForAll("~b~1...",1000,3);
}
public b6(playerid)
{
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}Start!");
GameTextForAll("~b~Start!",1000,3);
}
And the command:
if (strcmp("/countdown", cmdtext, true) == 0)
{
SendClientMessageToAll(COLOR_MBLUE, "[INFO]{FFFFFF} Aftellen gestart (5 seconde)");
SetTimer("b1", 1000, false);
SetTimer("b2", 2000, false);
SetTimer("b3", 3000, false);
SetTimer("b4", 4000, false);
SetTimer("b5", 5000, false);
SetTimer("b6", 6000, false);
SetTimer("b7", 6000, false);
return 1;
}
Re: Play sound for all players -
MathijsS - 27.11.2011
can anyone help me?
Re: Play sound for all players -
SmiT - 27.11.2011
pawn Код:
forward b1();
forward b2();
forward b3();
forward b4();
forward b5();
forward b6();
public b1()
{
for ( new i = 0; i != MAX_PLAYERS; ++i ) PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}5...");
GameTextForAll("~b~5...",1000,3);
}
public b2()
{
for ( new i = 0; i != MAX_PLAYERS; ++i ) PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}4...");
GameTextForAll("~b~4...",1000,3);
}
public b3()
{
for ( new i = 0; i != MAX_PLAYERS; ++i ) PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}3...");
GameTextForAll("~b~3...",1000,3);
}
public b4()
{
for ( new i = 0; i != MAX_PLAYERS; ++i ) PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}2...");
GameTextForAll("~b~2...",1000,3);
}
public b5()
{
for ( new i = 0; i != MAX_PLAYERS; ++i ) PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0);
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}1...");
GameTextForAll("~b~1...",1000,3);
}
public b6()
{
for ( new i = 0; i != MAX_PLAYERS; ++i ) PlayerPlaySound(i, 1056, 0.0, 0.0, 10.0);
SendClientMessageToAll( COLOR_MBLUE, "[TIMER] {FFFFFF}Start!" );
GameTextForAll("~b~Start!",1000,3);
}
if (strcmp("/countdown", cmdtext, true) == 0)
{
SendClientMessageToAll(COLOR_MBLUE, "[INFO]{FFFFFF} Aftellen gestart (5 seconde)");
SetTimer("b1", 1000, false);
SetTimer("b2", 2000, false);
SetTimer("b3", 3000, false);
SetTimer("b4", 4000, false);
SetTimer("b5", 5000, false);
SetTimer("b6", 6000, false);
SetTimer("b7", 6000, false);
return 1;
}
Re: Play sound for all players -
Jochemd - 27.11.2011
What is exactly your problem? What doesn't work?
Re: Play sound for all players -
HyperZ - 27.11.2011
pawn Код:
Forwarding:
forward b1(playerid);
forward b2(playerid);
forward b3(playerid);
forward b4(playerid);
forward b5(playerid);
forward b6(playerid);
The Countdown:
public b1(playerid) {
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}5...");
GameTextForAll("~b~5...",1000,3);
PlaySoundForAllEx();
}
public b2(playerid) {
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}4...");
GameTextForAll("~b~4...",1000,3);
PlaySoundForAllEx();
}
public b3(playerid) {
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}3...");
GameTextForAll("~b~3...",1000,3);
PlaySoundForAllEx();
}
public b4(playerid) {
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}2...");
GameTextForAll("~b~2...",1000,3);
PlaySoundForAllEx();
}
public b5(playerid) {
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}1...");
GameTextForAll("~b~1...",1000,3);
PlaySoundForAllEx();
}
public b6(playerid) {
SendClientMessageToAll(COLOR_MBLUE, "[TIMER] {FFFFFF}Start!");
GameTextForAll("~b~Start!",1000,3);
PlaySoundForAllEx();
}
And the command:
if (strcmp("/countdown", cmdtext, true) == 0)
{
SendClientMessageToAll(COLOR_MBLUE, "[INFO]{FFFFFF} Aftellen gestart (5 seconde)");
SetTimer("b1", 1000, false);
SetTimer("b2", 2000, false);
SetTimer("b3", 3000, false);
SetTimer("b4", 4000, false);
SetTimer("b5", 5000, false);
SetTimer("b6", 6000, false);
SetTimer("b7", 6000, false);
return 1;
}
forward PlaySoundForAllEx();
public PlaySoundForAllEx() {
for(new i = 0; i < MAX_PLAYERS; i++) {
TogglePlayerControllable(i,true);
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
}
}
Re: Play sound for all players -
MP2 - 27.11.2011
That code is really bad. You don't create 5 timers, you create one and use a variable.
pawn Код:
forward CountDown();
public CountDown()
{
countdown--;
for(new i=0; i<MAX_PLAYERS; i++) PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
new cdstring[32];
format(cdstring, sizeof(cdstring), "[TIMER] {FFFFFF}%i...", countdown);
SendClientMessageToAll(COLOR_MBLUE, cdstring);
format(cdstring, sizeof(cdstring), "~B~%i...", countdown);
GameTextForAll(cdstring, 1500, 3);
if(countdown != 0) SetTimer("CountDown", 1000, false);
}
new countdown; // Top of script (not the first line, with your other 'new's
if (strcmp("/countdown", cmdtext, true) == 0)
{
SendClientMessageToAll(COLOR_MBLUE, "[INFO]{FFFFFF} Aftellen gestart (5 seconde)");
countdown = 6;
SetTimer("CountDown", 1, false);
return 1;
}
Un-tested.