d0p3t / fivem-js

Javascript and Typescript wrapper for the FiveM natives API
https://d0p3t.nl
Other
143 stars 57 forks source link

Not working (basic example command) - ReferenceError #6

Closed Taerarenai closed 5 years ago

Taerarenai commented 5 years ago

Ok so i'm trying the simple example command to spawn an adder (just for testing purposes) and i'm already encountering quite a few errors.

I'm not that new to JS, so i've tried like this (among other things such as require instead of import)

import {World} from 'fivem-js/lib/World';

RegisterCommand("adder", async(source, args) => {
    const vehicle = await World.CreateVehicle(new Cfx.Model("adder"), new Cfx.Vector3(1, 2, 3), 4);
    Cfx.Game.PlayerPed.SetIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
}, false);

That throws a server error such as IsModelAVehicle is not defined pointing to Model.js isVehicle

The other thing i've tried was to clone the repo and use the example JS provided. That one is using an older version of the fivem-js lib, but i kept it as it is. While trying the command it throws PlayerId is not defined

Any tips ?

d0p3t commented 5 years ago

I'll have a look tonight

Taerarenai commented 5 years ago

I'll have a look tonight

Awesome. Let me know if you need more info.

Setting up a discord server for the repo would be a good idea if you plan to support it for a longer period of time (and since i haven't seen any other...it might get used quite a lot by JS devs for FiveM).

d0p3t commented 5 years ago
Screenshot 2019-03-22 at 18 39 51

I have a Discord server https://discord.gg/SBwfEda

d0p3t commented 5 years ago

This was handled via the Discord. Turns out the issue creator was using

server_script "dist/index.js" instead of client_script "dist/index.js"

Problem solved 👍