0xNull

Not working simple code

Recommended Posts

Hello, i am writing simple code, with the spawned the car after the player joined to the server. Why he dont work?

Code:

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

mp.events.add('playerDeath', (player) => {
    player.spawn(spawnPoints[Math.floor(Math.random() * spawnPoints.length)]);
    player.health = 100;
});
mp.events.add('playerJoin', (player, _, vehName) =>{
    player.spawn(spawnPoints[Math.floor(Math.random() * spawnPoints.length)]);
    player.outputChatBox(`You joined!`);
    player.customData = {};
    let pos = player.position;
    pos.x += 2;
    player.customData.vehicle = mp.vehicles.new(mp.joaat(t20), pos);
  });
mp.events.add('playerChat', (player, message) => {
    mp.players.broadcast(`${player.name}[ID ${player.id}]: ${message}`);
});
 

Error:

ReferenceError: t20 is not defined
    player.customData.vehicle = mp.vehicles.new(mp.joaat(t20), pos);

 

Share this post


Link to post
Share on other sites

if t20 is a variable, you need to create it, if not, use player.customData.vehicle = mp.vehicles.new(mp.joaat('t20'), pos);

Edited by Delta

Share this post


Link to post
Share on other sites
17 минут назад, Delta сказал:

if t20 is a variable, you need to create it, if not, use player.customData.vehicle = mp.vehicles.new(mp.joaat('t20'), pos);

Thank you :)

Share this post


Link to post
Share on other sites

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.