Jump to content
Sign in to follow this  
Nexus Payne

Creating a lightpoint for multiplayer missions using a script

Recommended Posts

Hi,

 

i would like to create a lightpoint for our multiplayer mission. i decided to place a logic-object named it "light_blue_1" and wrote "this exec "light_b.sqf" in the initline.

 

this is what "light_b.sqf" looks like:

 

this = "#lightpoint" createVehicle position this;

 

this setLightBrightness 0.015;
this setLightColor [0, 0, 255];
this setLightAmbient [0, 0, 255];

 

i got an error:

 

"Error: Nicht definierte Variable im Audruck: this"

"Error: Undefined variable in..."

 

as you see i am not very skilled in scripting so i need a little help from you guys.

 

 

 

thx

Share this post


Link to post
Share on other sites

You can't use this or any other script commands as a variable name.

Share this post


Link to post
Share on other sites

Do not use "this" as variable to write to. Change that anything else really. 

 

The light you are creating is there for everyone as it was created with createVehicle  and not createVehicleLocal. The next step is to set the right brightness and color. The commands you are using are the correct ones, BUT those are sadly local only. So only the machine that ran these commands will have the changes. What you can do is to remote exec those commands so everyone sees them.

 

_light = "#lightpoint" createVehicle position this;
[_light,0.015] remoteExec ["setLightBrightness",0,_light];
[_light,[0, 0, 255]] remoteExec ["setLightColor",0,_light];
[_light,[0, 0, 255]] remoteExec ["setLightAmbient",0,_light];

You will also add jip support as well well, as the command will run on any new client connection as long "_light" is still present and not deleted.

 

But since you are creating the light with a logic object you want this to be local to all, that means your code needs some small changes.

_light = "#lightpoint" createVehicleLocal position this;
_light setLightBrightness 0.015;
_light setLightColor [0, 0, 255];
_light setLightAmbient [0, 0, 255];

When you place a logic object and execute code through it, it will automatically execute on all machine connecting, so if you leave it as global there will be a new light for the server and every client connecting to it, even reconnecting clients will spawn yet another one.

  • Confused 1

Share this post


Link to post
Share on other sites
36 minutes ago, diwako said:

_light = "#lightpoint" createVehicleLocal position this;

_light setLightBrightness 0.015;

_light setLightColor [0, 0, 255];

_light setLightAmbient [0, 0, 255];

 

so this must be in the *.sqf?

 

i tried but the error saying:

 

"Error: Nicht definierte Variable im Audruck: this"

"Error: Undefined variable in..."

 

is still present

Share this post


Link to post
Share on other sites

Oh yeah, I forgot that part. It should be "_this" instead. I take it you execute the sqf with something like [0,0,0] execvm "script.sqf"? Then using "_this" would be correct.

 

_this is basically whatever you give into the script. It could be anything thus knowing how you execute the code is kind of important.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×