Comments (4)
Hi can you provide some code so I can see what you're doing, thanks.
from amongus-protocol.
import {
AmongusClient,
MasterServers
} from 'amongus-protocol'
const server = MasterServers.EU[0]
const name = 'AUBot'
const name2 = '2AUBot'
const code = process.argv[2]
const second = async() => {
const client = new AmongusClient
await client.connect(server[0], server[1], name2)
const game = await client.join(code)
await game.awaitSpawns()
game.me.setName(name2)
}
(async() => {
const client = new AmongusClient
await client.connect(server[0], server[1], name)
const game = await client.join(code)
await game.awaitSpawns()
game.me.setName(name)
game.on('playerJoin', async p => {
console.log(p.name())
})
second()
})()
from amongus-protocol.
- Firstly, name is a getter, so
p.name
is correct. - Secondly, this might be happening because the
playerJoin
event does not necessarily mean the player has spawned, so you mustp.awaitSpawn()
. - Thirdly, the player sends their name after they have spawned, and the player's game data containing their colour and name is delayed until after they have spawned too, so even
p.awaitSpawn()
won't be enough.
Solution: I've pushed some changes so you'll have to update.
If you want to specifically listen for name updates, you'll have to use the event playerData
given off by the GameData
component in the GameData
object.
await game.awaitSpawns();
game.GameData.GameData.on("playerData", player => {
console.log(player.name);
});
I'll leave this open in case you have any more issues.
from amongus-protocol.
I'm gonna close this issue now, feel free to open another if you have any more issues.
from amongus-protocol.
Related Issues (20)
- Running test script throws Join error: 0 - (Forcibly disconnected from server.) HOT 2
- Module '"util"' has no default export. HOT 2
- Support for joining games through LAN (Originally "How to connect to a local server?") HOT 11
- clientver in the Hello packet should be parsed as int32BE instead of int32LE HOT 1
- Question HOT 5
- Question HOT 1
- Error HOT 3
- random crash while playing HOT 2
- Can only vote once HOT 1
- TypeError: Cannot read property 'PlayerControl' of undefined HOT 4
- host a game with option doesn't work HOT 1
- Proper Tut? HOT 1
- Error HOT 2
- ERR_REQUIRE_ESM HOT 2
- ExpirementalWarning HOT 4
- Install fails horribly [typescript issue] HOT 2
- Add more versatile logging system HOT 1
- Server: You are running an old version of the game HOT 2
- Mistike on Game Code Wikipage HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amongus-protocol.