Jump to content
  • 0

Comanda /countdown


roscatu

Question

Am o comanda de countdown , dar am intalnit o problema la timer, nu executa functia, iar gametextul de inceput,sta cam mult on.Care ar fi problema?

forward count_one(playerid);
public count_one(playerid)
{
	GameTextForPlayer(playerid, "CountDown: ~b~3", 1000, 1);
}

forward count_two(playerid);
public count_two(playerid)
{
	foreach (new i : Player)
	{
		GameTextForPlayer(i, "CountDown: ~b~2", 1000, 1);
	}
}

forward count_three(playerid);
public count_three(playerid)
{
	foreach (new i : Player)
	{
		GameTextForPlayer(i, "CountDown: ~b~1", 1000, 1);
	}
}

forward count_four(i);
public count_four(i)
{
	GameTextForPlayer(i, "~r~GO ~y~GO ~b~GO", 1000, 1);
}

COMMAND:countdown(playerid,params[])
{
	new CountDownDistance;
	new Float:slx,Float:sly,Float:slz;

	CountDown = 3;

	if(PlayerInfo[playerid][pLogged] == 1)
	{
		if(PlayerInfo[playerid][pAdminLevel] >= 1)
		{
			if(sscanf(params,"i", CountDownDistance))
			{
				SCM(playerid, 0xBFC0C2FF, "{00FF00}Utilizare:{FFFFFF} /countdown [distanta]");
			}
			else
			{
				if(CountDown == 1)
				{
					SendClientMessage(playerid, 0xB4B5B7FF, "* E deja pornit timeru *");
					return 1;
				}
				else
				{
					foreach (new i : Player)
					{
						GetPlayerPos(playerid, slx, sly, slz);
						if(IsPlayerInRangeOfPoint(i, CountDownDistance, slx, sly, slz))
						{
							GameTextForPlayer(i, "~g~Pe Locuri !!!", 1000, 1);

							if(CountDown== 3)
							{
								SetTimerEx("count_one", 2000, false, "i", playerid);
								CountDown--;
							}
							else if(CountDown == 2)
							{
								SetTimerEx("count_two", 3000, false, "i", playerid);
								CountDown--;
							}
							else if(CountDown == 1)
							{
								SetTimerEx("count_three", 4000, false, "i", playerid);
								CountDown--;
							}
							else if(CountDown == 0)
							{
								SetTimerEx("count_four", 5000, false, "i", playerid);
								CountDown = 4;
							}
							return 1;
						}
					}
				}
			}
		}
	}
	return 1;
}

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Vezi daca merge. Daca nu merge, revino ci un post.

new Count[MAX_PLAYERS];

public count_timer(playerid, distance)
{
	new string[256], Float:slx, Float:sly, Float:slz;
	GetPlayerPos(playerid, slx, sly, slz);
	if(Count[playerid] >= 1)
	{
		Count[playerid]--;
	}
	foreach (new i : Player)
	{
		if(IsPlayerInRangeOfPoint(i, distance, slx, sly, slz))
		{
			if(Count[playerid] >= 1)
			{
				format(string, sizeof(string), "CountDown: ~b~%d", Count[playerid]);
				SetTimerEx("count_timer", 1000, 0, "id", playerid, distance);
			}
			else
			{
				format(string, sizeof(string), "~r~GO ~y~GO ~b~GO");
			}
			GameTextForPlayer(i, string, 1000, 1);
		}
	}
	return 1;
}

COMMAND:countdown(playerid,params[])
{
    new CountDownDistance;
    if(PlayerInfo[playerid][pLogged] == 1)
    {
        if(PlayerInfo[playerid][pAdminLevel] >= 1)
        {
            if(sscanf(params,"i", CountDownDistance))
            {
                SCM(playerid, 0xBFC0C2FF, "{00FF00}Utilizare:{FFFFFF} /countdown [distanta]");
            }
            else
            {
                if(Count[playerid] >= 1)
                {
                    SendClientMessage(playerid, 0xB4B5B7FF, "* E deja pornit timeru *");
                }
                else
                {
			Count[playerid] = 5;
			count_timer(playerid, CountDownDistance);
                }
            }
        }
    }
    return 1;
}

i0418xcttya707ofg.jpg

Link to comment
Share on other sites

Vezi daca merge. Daca nu merge, revino ci un post.

new Count[MAX_PLAYERS];

public count_timer(playerid, distance)
{
	new string[256], Float:slx, Float:sly, Float:slz;
	GetPlayerPos(playerid, slx, sly, slz);
	if(Count[playerid] >= 1)
	{
		Count[playerid]--;
	}
	foreach (new i : Player)
	{
		if(IsPlayerInRangeOfPoint(i, distance, slx, sly, slz))
		{
			if(Count[playerid] >= 1)
			{
				format(string, sizeof(string), "CountDown: ~b~%d", Count[playerid]);
				SetTimerEx("count_timer", 1000, 0, "id", playerid, distance);
			}
			else
			{
				format(string, sizeof(string), "~r~GO ~y~GO ~b~GO");
			}
			GameTextForPlayer(i, string, 1000, 1);
		}
	}
	return 1;
}

COMMAND:countdown(playerid,params[])
{
    new CountDownDistance;
    if(PlayerInfo[playerid][pLogged] == 1)
    {
        if(PlayerInfo[playerid][pAdminLevel] >= 1)
        {
            if(sscanf(params,"i", CountDownDistance))
            {
                SCM(playerid, 0xBFC0C2FF, "{00FF00}Utilizare:{FFFFFF} /countdown [distanta]");
            }
            else
            {
                if(Count[playerid] >= 1)
                {
                    SendClientMessage(playerid, 0xB4B5B7FF, "* E deja pornit timeru *");
                }
                else
                {
			Count[playerid] = 5;
			count_timer(playerid, CountDownDistance);
                }
            }
        }
    }
    return 1;
}

Nu functioneaza, imi arata doar count 4,dar 3,2,1,GO nu imi arata

Link to comment
Share on other sites

E facut in graba :

[pawn]

//comanda//

CMD:count(playerid,params[]) {

        if(CountDown == -1) {

CountDown = 6;

SetTimer("countdown",1000,0);

return CMDMessageToAdmins(playerid,"COUNTDOWN");

} else return SendClientMessage(playerid, red,"ERROR: Countdown in progress");

}

//publicul//

forward countdown();

public countdown()

{

if(CountDown==6) GameTextForAll("~p~Starting...",1000,6);

CountDown--;

if(CountDown==0)

{

GameTextForAll("~g~GO~ r~!",1000,6);

CountDown = -1;

for(new i = 0; i < MAX_PLAYERS; i++) {

TogglePlayerControllable(i,true);

PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);

}

return 0;

}

else

{

new text[7]; format(text,sizeof(text),"~w~%d",CountDown);

for(new i = 0; i < MAX_PLAYERS; i++) {

PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);

TogglePlayerControllable(i,false);

}

GameTextForAll(text,1000,6);

}

SetTimer("countdown",1000,0);

return 0;

}

[/pawn]

Daca ai vro eroare imi zici :)

Link to comment
Share on other sites

E facut in graba :

[pawn]

//comanda//

CMD:count(playerid,params[]) {

        if(CountDown == -1) {

CountDown = 6;

SetTimer("countdown",1000,0);

return CMDMessageToAdmins(playerid,"COUNTDOWN");

} else return SendClientMessage(playerid, red,"ERROR: Countdown in progress");

}

//publicul//

forward countdown();

public countdown()

{

if(CountDown==6) GameTextForAll("~p~Starting...",1000,6);

CountDown--;

if(CountDown==0)

{

GameTextForAll("~g~GO~ r~!",1000,6);

CountDown = -1;

for(new i = 0; i < MAX_PLAYERS; i++) {

TogglePlayerControllable(i,true);

PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);

}

return 0;

}

else

{

new text[7]; format(text,sizeof(text),"~w~%d",CountDown);

for(new i = 0; i < MAX_PLAYERS; i++) {

PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);

TogglePlayerControllable(i,false);

}

GameTextForAll(text,1000,6);

}

SetTimer("countdown",1000,0);

return 0;

}

[/pawn]

Daca ai vro eroare imi zici :)

Merge , doar ca ai gresit la if(CountDown == -1) , trebuia if(CountDown == 0) . In rest mersi :D functioneaza

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.