A question

Started by ℛḝξ☂, Aug 16, 2017, 09:45 AM

Previous topic - Next topic

ℛḝξ☂

Is there any way to sync the infrared ray of weapon laser sniper? It should work like: when you use that weapon to aim someone, or some objects, there will be a red point shown where you're aiming at, and all players in server can see this.
I may be a slow walker but I am always walking.

EK.IceFlake

Yes. Make an object that looks like a red sphere and use GetPlayerAimDir or GetPlayerAimPos (whichever one works) and raytrace to there (extend it by a few miles) and place the object where the ray collided.

Xmair

Quote from: EK.IceFlake on Aug 16, 2017, 10:47 AMYes. Make an object that looks like a red sphere and use GetPlayerAimDir or GetPlayerAimPos (whichever one works) and raytrace to there (extend it by a few miles) and place the object where the ray collided.
player.AimPos I think it is

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

ℛḝξ☂

Quote from: EK.IceFlake on Aug 16, 2017, 10:47 AM..and raytrace to there (extend it by a few miles) and place the object where the ray collided.
How to do this?
I may be a slow walker but I am always walking.

Xmair

#4
Quote from: Rest on Aug 16, 2017, 02:59 PM
Quote from: EK.IceFlake on Aug 16, 2017, 10:47 AM..and raytrace to there (extend it by a few miles) and place the object where the ray collided.
How to do this?
RayTraces are client side stuff
QuoteRayTrace

When ray trace is created, the properties from it will contain the results.

Constructor RayTrace(start, end, flags)
Parameter types: Vector, Vector, flags
Flag values can be or-ed together with the | operator to select which types of entities it should check: RAY_BUILDING, RAY_PED, RAY_VEHICLE, RAY_OBJECT.

Property Collided (read-only)
Type: bool
True when the ray hit something.

Property Entity (read-only)
Type: entity
The entity that was hit, or null if nothing was hit. May also be null if the entity has been destroyed.

Property Position
Type: Vector
The position of the collision, or zero vector if nothing was hit.
You simply do something like
local rayTrace = RayTrace( World.FindLocalPlayer( ).Position, aimPosFewMilesAway, ( OBJ_PLAYER | OBJ_VEHICLE | OBJ_BUILDING ) );
if ( rayTrace.Collided( ) ) sendStreamToServer( );
You need to do some kind of math for the aim pos

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD