Jump to content

chat/commands not working


Recommended Posts

Posted

Hi, new to this. I've followed tutorials on wiki on how to make server. I've made my way up until part where you make some simple commands: "hp", "armor" and "kill". https://wiki.rage.mp/index.php?title=Getting_Started_with_Development

What happens is I am able to connect to server but then when I type anything in chat nothing shows, also doing any of the commands doesn't work. I'm typing "/armor". I get no response. It does not say that commands was not found as mentioned in some other tickets.

My code is exactly same as in tutorial all files are placed in packages folder. Index.js does require both commands and events.

 

index.js:
 

require('./events.js')
require('./commands.js')

commands.js

mp.events.addCommand('hp', (player) => {
    player.health = 100;
});

mp.events.addCommand('armor', (player) => {
    player.armour = 100;
});

mp.events.addCommand('kill', (player) => {
    player.health = 0;
});

events.js:

let spawnPoints = require('./spawn_points.json').SpawnPoints;

mp.events.add('playerDeath', (player) => {
    player.spawn(spawnPoints[Math.floor(Math.random() * spawnPoints.length)]);
    player.health = 100;
});

spawn_points.json

{
    "SpawnPoints": [
        { "x": -425.517, "y": 1123.620, "z": 325.8544 },
        { "x": -415.777, "y": 1168.791, "z": 325.854 },
        { "x": -432.534, "y": 1157.461, "z": 325.854 },
        { "x": -401.850, "y": 1149.482, "z": 325.854 }
    ]
}
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...