Giter VIP home page Giter VIP logo

Comments (8)

saul avatar saul commented on August 23, 2024

UserIDs certainly don't change throughout the game - are you sure rain didn't disconnect before the game ended?

from demofile.

RaphaelHippe avatar RaphaelHippe commented on August 23, 2024

Hey,

I just now tested further for disconnects:

    demoFile.entities.on('beforeremove', e => {
      if (e.entity.userInfo) {
        console.log('user entity gets removed:');
        console.log(e.entity.name, e.entity);
      }
    });
    demoFile.gameEvents.on('client_disconnect', e => {
      console.log('a client disconnected');
      let testPlayerIds = demoFile.players.map(p => p.userId);
      console.log('testPlayerIds', testPlayerIds);
    });

while the event client_disconnect never fires, the beforeremove shows me that rains entity indeed gets deleted right before the end event of the demoFile gets fired.

So I am not quite sure how to precede from here.

my goal is to get all actual player Ids (onle the 10 who play and not any players, that spectate or something which demoFile.players.map(p => p.userId); seems to include)

I tried to look at the e.entity for the beforeremove event but I didn't find an ID in there. And since the entity just gets remove I couldn't override my current ID for rain anyhow.

from demofile.

saul avatar saul commented on August 23, 2024

You can check if a player is on a team by checking their team number is 2 or 3. 0 = Unassigned, 1 = Spectator, 2 = Terrorist and 3 = CT.

Also player_disconnect is the event you're looking for.

If you want to take stats at the end of the game, you can check when the game phase switches to match end:

  demo.entities.on('DT_CSGameRules.m_gamePhase', e => {
    if (e.newValue == 5) {
      // Game finished
    }
  });

from demofile.

RaphaelHippe avatar RaphaelHippe commented on August 23, 2024

Thank you!

for game events I am using this reference: https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events

and player_disconnect is not on that reference. Do you have one thats more up to date?

Cheers

from demofile.

saul avatar saul commented on August 23, 2024

from demofile.

RaphaelHippe avatar RaphaelHippe commented on August 23, 2024

Hey,
sadly, DT_CSGameRules.m_gamePhase doesn't get fired at all when I am listening on demoFile.entities

code block:

demoFile.entities..on('DT_CSGameRules.m_gamePhase', e => {
  console.log('TEST', e);
  if(e.newValue == 5) {
    console.log('TEST 2');
  }
});

Cheers

from demofile.

saul avatar saul commented on August 23, 2024

Sorry, that should have been ‘change’ and you should be checking e.tableName and e.varName

from demofile.

RaphaelHippe avatar RaphaelHippe commented on August 23, 2024

Thanks, that works :-)

from demofile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.