agar.io-clone
agar.io-clone copied to clipboard
Chat Commands
Which file contains the commands. (i.e. -dark, -ping) Also how do you add new commands such as add mass. (-massboost)
This is where you can register for new command and write the code logic for it https://github.com/huytd/agar.io-clone/blob/2a03b5039de738c1212c1bfbc3cf6ade8fa1129f/src/client/js/app.js#L426-L459
I would like to Re-Open this issue. I have added a command but it will not work. I have registered it in app.js and added logic in in sever.js. When I type it in the chat box and hit [ENTER] it just stays in the chat box and does not do anything else. Does not send it as a chat MSG or say the command does not exist, it just stays there.
@16beeyee Can you add the changes to your fork on GitHub? Can't really help if we don't know what you did.
There I put my changes in the src file in my fork.
Is there a guide on the command writing API / abstractions anywhere? Like the name of the user could be user.name or something.
@16beeyee how can you run your code? I mean, it's doesn't pass the test.
Just checked your fork, and here is what I get when running:
src/server/server.js: line 337, col 61, Expected ')' and instead saw ' used massboost successfully'. (W116)
src/server/server.js: line 337, col 91, Missing semicolon. (W033)
src/server/server.js: line 337, col 91, Expected an identifier and instead saw ')'. (E030)
src/server/server.js: line 337, col 91, Expected an assignment or function call and instead saw an expression. (W030)
src/server/server.js: line 331, col 17, 'datd' is not defined. (W117)
5 errors
After you fixed the errors above, it should work

Server logs:
Player Iq3oWgDPyX5-r7I4AAAA connected!
Total player: 1
hyoo is trying to use -massboost but isn't admin
User #Iq3oWgDPyX5-r7I4AAAA disconnected
I fixed the code in my fork i just miss-typed. Where I've been running from those errors weren't there. I did double check. This is what happened when i ran the code and typed the command. I couldn't take a screenshot to show.
$ npm start
[email protected] start /home/___________/agar.io-clone
gulp run
[09:09:13] Using gulpfile ~/agar.io-clone/gulpfile.js [09:09:13] Starting 'lint'... [09:09:13] Starting 'move-client'... [09:09:21] Finished 'move-client' after 7.89 s [09:09:21] Finished 'lint' after 8.29 s [09:09:21] Starting 'build-client'... [09:09:22] Starting 'build-server'... [09:09:22] Starting 'test'... [09:09:22] Finished 'test' after 7.48 ms
util.js
#massToRadius
✓ should return non-zero radius on zero input
✓ should convert masses to a circle radius
#validNick
[09:09:25] Finished 'build-server' after 3.56 s
✓ should allow empty player nicknames
✓ should allow ascii character nicknames
✓ should disallow unicode-dependent alphabets
✓ should disallow spaces in nicknames
#log
✓ should compute the log_{base} of a number
#getDistance
✓ should return a positive number
8 passing (2s)
[09:09:26] Version: webpack 1.12.6
Asset Size Chunks Chunk Names
app.js 211 kB 0 [emitted] main
[09:09:26] Finished 'build-client' after 4.89 s
[09:09:26] Starting 'build'...
[09:09:26] Finished 'build' after 7.37 μs
[09:09:26] Starting 'run'...
[09:09:26] Finished 'run' after 1.94 ms
[09:09:26] [nodemon] 1.8.1
[09:09:26] [nodemon] to restart at any time, enter rs
[09:09:26] [nodemon] watching: .
[09:09:26] [nodemon] starting node ./server/server.js config.json
{ x: 0, y: 0, h: 3500, w: 3500, maxChildren: 1, maxDepth: 5 }
listening on *:3000
A user connected! player
User #M3XK3xrDf_EN3aPuAAAA respawned
Player M3XK3xrDf_EN3aPuAAAA connecting
Player M3XK3xrDf_EN3aPuAAAA connected!
Total player: 1
User #M3XK3xrDf_EN3aPuAAAA disconnected
Are you sure you're running the version with your edits? It works fine for me after you fix the string to number issue. For better debugging, you could add a console.log along with sending the serverMSG
Alright, I've tried to do that I just can't seem to remember how.