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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.