Multiplayer game stop a host in node js server in gamemaker studio

Поділитися
Вставка
  • Опубліковано 7 лис 2024

КОМЕНТАРІ • 9

  • @root......
    @root...... 2 роки тому

    As a 9th-grade student, I loved your series! Thank you, sir!

  • @Secret21bobby
    @Secret21bobby 2 роки тому +1

    How do you destroy the host if the player ends the game uncleanly (not clicking a disconnect button but closing the window/app)?

    • @navidrct
      @navidrct  2 роки тому

      In server side every ten second or every one minute we can check player set state . If it is updated or not . If it is not updated for a minute stop the host

  • @no_name4247
    @no_name4247 2 роки тому +3

    *First !!!))*

  • @MakeGamesIndia
    @MakeGamesIndia 2 роки тому

    Great bro.1) Can I upload game on google play store(android) and steam(windows). 2) is Game maker updated frequently? 3) I use App Game Kit but I want 1more alternative so is Game Maker will be right choice. Or better to go with unity. (I am not comparing free vs paid)

    • @navidrct
      @navidrct  2 роки тому

      1.Yes it is easy 2 .Yes several update each month 3.for 2d game , game maker is the best . Unity is much harder than game maker . The game that you can finish in one month you can do it in unity in three month

    • @MakeGamesIndia
      @MakeGamesIndia 2 роки тому

      @@navidrct ok. Can I upload game on steam?

  • @terohannula30
    @terohannula30 9 місяців тому

    Deleting host this way is problematic. First, you have error in your code.
    The "hosts" is array, which each element is an array. When you are using "indexOf", you are providing host number to search. As number can't equal to array, it will not find value, and it will return index -1.
    Now it means, in the video you actually did "hosts.splice(-1, 1);", which deletes last element from the array. It is wrong, but appears to be corret, when you have only one host to delete or deleting the last index.
    Secondly, host numbers as array indexes is problematic for another reason.
    Let's say you have created 3 hosts, and their host numbers are 0, 1, 2. Their data is stored in array like [host0, host1, host2]. Now you can correctly delete one host, let's say number 1. Now array holding hosts will look like [host0, host2]. The problem is, that host2 is now at the array index 1, so you can't use host numbers for array indexes anymore.
    Thirdly, currently creation of host returns host number, which is based on array size. When you have not deleted any host, this is fine. But as soon as you delete single host, and then create new one, there will be duplicate. Here is example. Let's say you have created three hosts [host0, host1, host2], then delete host1 so array is [host0, host2]. Now when you next time create a new host, it uses size of hosts-array as host number, which in this case would be 2. But problem lies that there is already host with number 2, so now there exists two hosts with same host number [host0, host2, host2].
    Of course there are many ways to avoid these issues. For example you could decouple host number from array size, and use running index instead. This way host numbers won't ever be reused. But then you can't use host number as array index. If you want to be able to use host numbers as array indexes, you can have "tombs", which holds recycleable indexes. So when host is stopped, it is not deleted hosts-array, but index is placed on tombs-array. Then whenever you are creating a new host, look first whether there are any recycleable ones in tombs-array. So creation either pops old recycleable index, or creates new one if there are no recycleables left.