Jump to content

Is it possible to...


megaman54

Recommended Posts

Posted

Hi! Is it possible to make a flashlight script, that you point your flashlight somewhere and it creates light there?

I'm not requesting you to do this for me i'm just asking is it possible and if it is, then how to do it.

Posted

hmm, you can create and move a corona marker to the point that player is aiming. but afair - player needs to click somewhere so you could get world position of click - which makes it impossible to move while moving mouse..

not sure about it anyway - maybe there is a chance to get aim world position.

Posted

Ok, thanks. I will try it as i have a script where you press I and it brings cursor to your screen and when you click somewhere it will create explosion there, i just change the explosion to marker or corona or whatever :wink:

Posted
hmm, you can create and move a corona marker to the point that player is aiming. but afair - player needs to click somewhere so you could get world position of click - which makes it impossible to move while moving mouse..

not sure about it anyway - maybe there is a chance to get aim world position.

getWorldFromScreenPosition and processLineOfSight can be used to get world position without clicking.

Posted
is the sight of the gun always in the center of screen?

you need to pass something to getWorldFromScreenPosition, i think passing center point will be ok

It's not the center, but near the center and it does not change.

Posted

First thing that comes into my mind is combining the position of a player's bones with LineOfSight.

Detailed: A gun is just an object that is attached to one of the bones of a player (the hand, in this case). If you know the position of the elbow of that arm ánd the hand, you can use those two positions to calculate a line as an extension of the line that the positions of the elbow and hand create, directed from the elbow to the hand. If you extend that line by, for example, 10 meters and use the position 10 meters "in front of the hand", you could process a line of sight to check if it hits something. If it does, move the marker to that position.

If you repeat this calculation on onClientPreRender, this might work. Again, it's just an idea: this is how I would try it.

[EEEEEEEEDIEET] Here's a nice drawing btw:

flashlight.jpg

Hope you get what I mean. Useful links:

https://wiki.multitheftauto.com/wiki/GetPedBonePosition (to get the two positions)

https://wiki.multitheftauto.com/wiki/ProcessLineOfSight (to get a hit position)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...