Sign in to follow this  
He$h

How to run client scripts ?

Recommended Posts

hi all .

how can i make the server to run a .js script as client script ??

for example this code is inside a .js file , and i want it to be run as a client script .. how do i do that ? which folder do i put it in ? should i declare this file as client script in the 'index.js' or does it run automaticly ?

mp.events.add('render', () => {
    mp.game.graphics.drawText('This is called every frame.', [0.5, 0.005], 
    {
      font: 4,
      color: [255, 255, 255, 255],
      scale: [1.0, 1.0],
      outline: true
    });
});

 

Share this post


Link to post
Share on other sites

@ragempdev, please, answer to this.

I have same problem. If i put my client code in first file (/events.js, for example) it works.

If i put same code in second file (/folder/file.js), it doesn't work;

Help! :D

Share this post


Link to post
Share on other sites

I solved this so that the basic folder I made the index.js file and put the following code in it

require ('folder/index.js');

And then in the folder you can already name the js file

Edited by stawiara

Share this post


Link to post
Share on other sites

For me it works normally on the client side and the list itself updates itself probably after the server is started

Share this post


Link to post
Share on other sites

ahah ..  Got it :D

just like you put .js files and index.js file in packages for the server ,

you need to create a js file named "index.js" exactly in the 'client_packages' folder ..

and you can write your codes in other .js files and require them in 'index.js' . for example :

in folder 'client_packages' there is "index.js" and there is "mycode.js"

you write your codes in "mycode.js" , and in the "index'js" you write : require("./mycode.js")

and it work perfectly ..

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.