Jump to content

Recommended Posts

Posted

Hi everyone,

 

Like Jetfan16ladd i do have a problem when spawning lightnings. In my first try i have successfully spawned lightnings which dealt damages on other entities and put the ground on fire but that only works in single player. When i tried in multiplayer the server crashed. I looked in my code and found that rayTrace(double,float) is client side only.

 

So i tried to use the isRemote() method. The lightning appears in the world but it looks like it's only on the client side so the lighting don't deal any damage or put things on fire. From what i've read the client renders the lightning but it's the server's job to handle the damages (which is logic :) ).

 

So does someone know how to make the lightning deal damages without crashing the server ?

 

Here is the code i'm using:

 

  Reveal hidden contents

 

Posted

Thanks, it looks like it works :)

 

I have 2 (minor) questions thought :

 

1) It appears that in single player i can burn the grass but not in multiplayer. Is there a reason to that ?

 

2) With the getMovingObjectPositionFromPlayer method it works but only when i right-click near the player. Do you know if there is a way to extend the distance ?

 

If not, no problem, i can still work with that !!

 

Anyway, thank you :)

Posted

Well for my code it's the same. I just replace the ray method with the one you gave me.

 

 

  Reveal hidden contents

 

 

By copy, you mean i override the getMovingObjectPositionFromPlayer method right ? I'll try that.

Posted

Ok it works great now, the entities take damages and are set to fire (the grass not but it's not a big deal) and i can adjust the distance !

 

Thank you very much :)

 

For those who are interested, here is my final code to spawn lightning when that player right-clicks an item :

 

 

  Reveal hidden contents

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.