Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

хелп таймер

Июл
349
116
Активный
Йоу, помогите сделать таймер для запуска притона/вышки на определенное кол-во секунд
код команды
Код:
CMD:startbattles(playerid, params[])
{
new time;

    if(!IsOsnovatel(playerid))

    if (strlen(params) == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "{ffffff}Использование: /startbattles [тип]");
        return 1;
    }
    new type;
    if (sscanf(params, "i", type))
    {
        SendClientMessage(playerid, COLOR_RED, "{ffffff}[Ошибка]. Используйте: /startbattles [0 - притон, 1 - нефтевышки.]");
        return 1;
    }
    switch (type)
    {
        case 0:
        {
            StartBattles(1);
            SCM(playerid, COLOR_RED, "[Успешно]{ffffff} Вы начали битву за притон.");
        }
        case 1:
        {
            StartBattles(2);
            SCM(playerid, COLOR_RED, "[Успешно]{ffffff} Вы начали битву за нефтевышки.");
        }
        default:
        {
            SendClientMessage(playerid, COLOR_RED, "{ffffff}[Ошибка]. Используйте: /startbattles [0 - притон, 1 - нефтевышки.] [время]");
        }
    }
    return 1;
}
Код stock
Pawn:
stock StartBattles(type)
{
    foreach(Player, i)
    {
        if IsAtGang(i) or IsAtMafia(i) *then
        {
            for new j; j < sizeof gangs_Id; j ++ do
            {
                if PI[i][pMember] == gangs_Id[j] *then
                    if(GetPlayerGangZone(i) == 66 or GetPlayerGangZone(i) == 291)
                        OrgBattlesCountMember[gangs_Id[j]]++;
            }

            ShowBattlesTD(i);
            SCMF(i, COLOR_OLDRED, "[Битва за %s] Внимание! Началась битва за %s! Отправляйтесь на территорию %s.", type == 1 ? "притон" : "нефтевышки", type == 1 ? "притон" : "нефтевышки", type == 1 ? "притона" : "наземных нефтевышек");
            SCMF(i, COLOR_OLDRED, "[Битва за %s] У вас есть 5 минут, чтобы добраться до %s.", type == 1 ? "притон" : "нефтевышки", type == 1 ? "притона" : "наземных нефтевышек");
            OrgBattlesTimer[0] = 1;
            OrgBattlesTimer[1] = OrgBattlesTimer[2] = 0;
            UpdateBattlesTD(i, true);
            GangZoneFlashForAll(GangZone[type == 1 ? 66 : 291], 0xFF0000FF);
            OrgBattlesState = type;
            OrgBattlesTimeKick = 300;
            CheckNeactiveOrgBattles = true;
        }
    }
    return 1;
}
 
𝚖𝚎𝚖𝚎𝚗𝚝𝚘 𝚖𝚘𝚛𝚒.
Мар
1,129
11,433
Команда форума
Администратор
@Nagisa
Pawn:
new testTimer;

CMD:test(playerid, params[]) {
    if(sscanf(params, "d", params[0]))
        return SendClientMessage(playerid, -1, "Используйте: /test [sec]");
    
    if(!params[0])
        return 1;

    SetPVarInt(playerid, "seconds_command", params[0]); //в твоем случае делать глобальную переменную, вместо pvar'a
    testTimer = SetTimerEx("testFunction", params[0] * 1000, true, "i", playerid);
    return 1;
}

forward testFunction(playerid);
public testFunction(playerid) {
    if(GetPVarInt(playerid, "seconds_command") <= 0)
        return DeletePVar(playerid, "seconds_command"), KillTimer(testTimer);
    
    SetPVarInt(playerid, "seconds_command", GetPVarInt(playerid, "seconds_command") - 1);
    SendClientMessage(playerid, -1, "Сработал");
    return 1;
}
 
Июл
349
116
Активный
@Nagisa
Pawn:
new testTimer;

CMD:test(playerid, params[]) {
    if(sscanf(params, "d", params[0]))
        return SendClientMessage(playerid, -1, "Используйте: /test [sec]");
   
    if(!params[0])
        return 1;

    SetPVarInt(playerid, "seconds_command", params[0]); //в твоем случае делать глобальную переменную, вместо pvar'a
    testTimer = SetTimerEx("testFunction", params[0] * 1000, true, "i", playerid);
    return 1;
}

forward testFunction(playerid);
public testFunction(playerid) {
    if(GetPVarInt(playerid, "seconds_command") <= 0)
        return DeletePVar(playerid, "seconds_command"), KillTimer(testTimer);
   
    SetPVarInt(playerid, "seconds_command", GetPVarInt(playerid, "seconds_command") - 1);
    SendClientMessage(playerid, -1, "Сработал");
    return 1;
}
спасибо, попробую завтра, напишу если будут ошибки или вопросы
 
Июл
349
116
Активный
@Nagisa
Pawn:
new testTimer;

CMD:test(playerid, params[]) {
    if(sscanf(params, "d", params[0]))
        return SendClientMessage(playerid, -1, "Используйте: /test [sec]");
  
    if(!params[0])
        return 1;

    SetPVarInt(playerid, "seconds_command", params[0]); //в твоем случае делать глобальную переменную, вместо pvar'a
    testTimer = SetTimerEx("testFunction", params[0] * 1000, true, "i", playerid);
    return 1;
}

forward testFunction(playerid);
public testFunction(playerid) {
    if(GetPVarInt(playerid, "seconds_command") <= 0)
        return DeletePVar(playerid, "seconds_command"), KillTimer(testTimer);
  
    SetPVarInt(playerid, "seconds_command", GetPVarInt(playerid, "seconds_command") - 1);
    SendClientMessage(playerid, -1, "Сработал");
    return 1;
}
хелп, не могу понять как подставить сюда
Pawn:
forward battletimer(playerid);
stock StartBattles(type)
{
    foreach(Player, i)
    {
        if IsAtGang(i) or IsAtMafia(i) *then
        {
            for new j; j < sizeof gangs_Id; j ++ do
            {
                if PI[i][pMember] == gangs_Id[j] *then
                    if(GetPlayerGangZone(i) == 66 or GetPlayerGangZone(i) == 291)
                        OrgBattlesCountMember[gangs_Id[j]]++;
            }

            ShowBattlesTD(i);
            SCMF(i, COLOR_OLDRED, "[Битва за %s] Внимание! Началась битва за %s! Отправляйтесь на территорию %s.", type == 1 ? "притон" : "нефтевышки", type == 1 ? "притон" : "нефтевышки", type == 1 ? "притона" : "наземных нефтевышек");
            SCMF(i, COLOR_OLDRED, "[Битва за %s] У вас есть 5 минут, чтобы добраться до %s.", type == 1 ? "притон" : "нефтевышки", type == 1 ? "притона" : "наземных нефтевышек");
            OrgBattlesTimer[0] = 1;
            OrgBattlesTimer[1] = OrgBattlesTimer[2] = 60;
            UpdateBattlesTD(i, true);
            GangZoneFlashForAll(GangZone[type == 1 ? 66 : 291], 0xFF0000FF);
            OrgBattlesState = type;
            OrgBattlesTimeKick = 300;
            CheckNeactiveOrgBattles = true;
        }
    }
    return 1;
}
и правильно ли я сделал?
Pawn:
CMD:startbattles(playerid, params[])
{
    if(!IsOsnovatel(playerid))

    if (strlen(params) == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "{ffffff}Использование: /startbattles [тип] [таймер]");
        return 1;
    }
    new type;
    if (sscanf(params, "i", type))
    if(sscanf(params, "d", params[0]))
    {
        SendClientMessage(playerid, COLOR_RED, "{ffffff}[Ошибка]. Используйте: /startbattles [0 - притон, 1 - нефтевышки] [таймер]");
        return 1;
    }
    switch (type)
    {
        case 0:
        {
            StartBattles(1);
            SetPVarInt(playerid, "battletimertest", params[0]); //в твоем случае делать глобальную переменную, вместо pvar'a
            battletimer = SetTimerEx("battletimer", params[0] * 1000, true, "i", playerid);
            SCM(playerid, COLOR_RED, "[Успешно]{ffffff} Вы начали битву за притон.");
        }
        case 1:
        {
            StartBattles(2);
            SetPVarInt(playerid, "battletimertest", params[0]); //в твоем случае делать глобальную переменную, вместо pvar'a
            battletimer = SetTimerEx("battletimer", params[0] * 1000, true, "i", playerid);
            SCM(playerid, COLOR_RED, "[Успешно]{ffffff} Вы начали битву за нефтевышки.");
        }
        default:
        {
            SendClientMessage(playerid, COLOR_RED, "{ffffff}[Ошибка]. Используйте: /startbattles [0 - притон, 1 - нефтевышки.] [время]");
        }
    }
    return 1;
}
 
Сверху