How to make a count so that a certain event starts

0

Good morning guys, I'm new to programming in C # I created a method to load a npc that appears on the map where I was a member of Party, type a boss invasion just wanted to do a timer to make it happen. Any tips?

Ex. The Event starts at 10 p.m., at 9:55 a mgs "5 Minutes to Invasion is missing"

         public static void LoadBossRud(int index)
    {

        //EXTEND
        if (Extensions.ExtensionApp.ExtendMyApp
            (MethodBase.GetCurrentMethod().Name, index) != null)
        {
            return;
        }
        // Verifica se membros em party
        int partynum = PStruct.party[partymembers].leader;
        // Se nao hover party envia mgs para Cliente 
        if (partynum <= 0)
        {
            SendData.Send_MsgToPlayer(index, lang.player_for_party_members, Globals.ColorRed, Globals.Msg_Type_Server);
            return;
        }
        // Verificar se tem jogadores em Pary
        int partylevel = PStruct.party[partynum].leader;
        // Verificar se tem 5 jogadores no map
        int playermap = partylevel * 5;

        if (PStruct.character[index, PStruct.player[index].SelectedChar].Map < playermap)
        {
            SendData.Send_MsgToPlayer(index, lang.you_dont_have_map_to_create_boss, Globals.ColorRed, Globals.Msg_Type_Server);
            // return;
        }
        //ainda vou analisar 
        int mapnum = PStruct.character[index, PStruct.player[index].SelectedChar].Map;
        int i2 = MStruct.GetMapNpcSlot(mapnum);
        if (i2 <= 1)




        //Criar um Boss

        NStruct.npc[mapnum, i2].Name = "Senhor do Caos";
        NStruct.npc[mapnum, i2].Map = mapnum;
        NStruct.npc[mapnum, i2].X = NStruct.npc[mapnum, 1].X;
        NStruct.npc[mapnum, i2].Y = NStruct.npc[mapnum, 1].Y;
        NStruct.npc[mapnum, i2].Vitality = (PStruct.party[partynum].leader * 1000) + 1000;
        NStruct.npc[mapnum, i2].Spirit = (PStruct.party[partynum].leader * 200) + 200;
        NStruct.tempnpc[mapnum, i2].Target = 0;
        NStruct.tempnpc[mapnum, i2].X = NStruct.npc[mapnum, i2].X;
        NStruct.tempnpc[mapnum, i2].Y = NStruct.npc[mapnum, i2].Y;
        NStruct.tempnpc[mapnum, i2].curTargetX = NStruct.npc[mapnum, i2].X;
        NStruct.tempnpc[mapnum, i2].curTargetY = NStruct.npc[mapnum, i2].Y;
        NStruct.tempnpc[mapnum, i2].Vitality = NStruct.npc[mapnum, i2].Vitality;
        NStruct.npc[mapnum, i2].Attack = (PStruct.party[partynum].leader * 34) + 34;
        NStruct.npc[mapnum, i2].Defense = (PStruct.party[partynum].leader * 22) + 22; ;
        NStruct.npc[mapnum, i2].Agility = (PStruct.party[partynum].leader * 4) + 4; ;
        NStruct.npc[mapnum, i2].MagicDefense = (PStruct.party[partynum].leader * 26) + 26;
        NStruct.npc[mapnum, i2].MagicAttack = (PStruct.party[partynum].leader * 48) + 48;
        NStruct.npc[mapnum, i2].Luck = (PStruct.party[partynum].leader * 4) + 4;
        NStruct.npc[mapnum, i2].Sprite = "$sprite (84)";
        NStruct.npc[mapnum, i2].index = 0;
        NStruct.npc[mapnum, i2].Type = 1;
        NStruct.npc[mapnum, i2].Range = 1;
        NStruct.npc[mapnum, i2].Animation = 2;
        NStruct.npc[mapnum, i2].SpeedMove = 256;
        NStruct.tempnpc[mapnum, i2].movespeed = NStruct.npc[mapnum, i2].SpeedMove / 64;
        NStruct.npc[mapnum, i2].Respawn = 0;
        NStruct.npc[mapnum, i2].Exp = 0;
        NStruct.npc[mapnum, i2].Gold = 0;
        NStruct.tempnpc[mapnum, i2].guildnum = partynum;
        NStruct.tempnpc[mapnum, i2].prev_move = new NStruct.Point[7];

        //Atualizaro número de npc's no mapa
        MStruct.tempmap[mapnum].NpcCount = MStruct.GetMapNpcCount(mapnum);

        //Enviar dados para todos.
        SendData.Send_MapGuildToMap(mapnum);
        SendData.Send_NpcToMap(mapnum, i2);
        SendData.Send_MsgToPlayer(partynum, lang.a_boss_has_been_created_in + " " + MStruct.map[mapnum].name + ".", Globals.ColorYellow, Globals.Msg_Type_Server);

    }

    public static int partymembers { get; set; }
}
    
asked by anonymous 08.10.2017 / 16:16

1 answer

0

You can make a timer and it will pick up the current time from the guy's PC, then check the time for the desired time and then call the method you want.

Example:

Timer tempo = new Timer();

tempo.Interval = 1000;// um segundo

Tempo.tick = daí ele sugere pra tu criar o método que agora não tenho de cabeça.

And in the method you do:

Datetime agora = DateTime.Now();

And then you can manipulate it any way you want:

If agora.Hour==9 && agora.minute == 55 

Excerpt from the code you want.

From there it makes another if for the 10

    
09.10.2017 / 04:55