mkafrin / mka-lasers Goto Github PK
View Code? Open in Web Editor NEWCreate moving lasers in FiveM!
License: MIT License
Create moving lasers in FiveM!
License: MIT License
So I got the lasers working and they are so cool, now im trying to add a function to just add
SetPlayerWantedLevel(playerId, 4, false)
SetPlayerWantedLevelNow(playerId, false)
to set a wanted level on player hit.
I tried this to no avail.
CreateThread(function()
if playerBeingHit then
local playerId = PlayerId()
SetPlayerWantedLevel(playerId, 4, false)
SetPlayerWantedLevelNow(playerId, false)
-- Laser just hit the player
else
-- Laser just stopped hitting the player
-- hitPos will just be a zero vector here
end
end)
Im having a terrible time getting the lasers to active period .
Ive been able to create a lazer , and its produced into the lazer.txt document
From here im a little lost ('@mka-lasers/client/client.lua',
'your_scripts_client.lua', ) am i dropping both of these into the lets say for example BankHeist Fxmanifest ?
If so awesome im on the right track
Now the whole laser.active(true) where is that going ? do i take the part of code from the Lazer.txt file add it into the BankHeist Client side then add laser.active .
Example
-- Name: legionbank | 2021-12-09T21:25:31Z
Laser.new()
vector3(147.805, -1046.457, 28.597),
{vector3(148.751, -1044.211, 28.471)},
{travelTimeBetweenTargets = {1.0, 1.0}, waitTimeAtTargets = {0.0, 0.0}, randomTargetSelection = true, name = "legionbank"}
)
Where would i add the extra getactive , get color , etc . maybe by any chance can you release a quick video of you creating a laser ?
thanks
So with the latest commit you need to just Invoke the native as the names have changed (Im assuming) for StartShapeTestRay, StartExpensiveSynchronousShapeTestLosProbe and GetShapeTestResult
local function RayCast(origin, destination, flags)
local ray = Citizen.InvokeNative(0x377906D8A31E5586, origin.x, origin.y, origin.z, destination.x, destination.y, destination.z, flags, nil, 0)
return Citizen.InvokeNative(0x3D87450E15D9869, ray)
end
This still is causing issues with playerhit detection and returning everything as nil in your _onPlayerHitTest
local _, hit, hitPos, _, hitEntity = RayCast(origin, destination, 12)
Hey, I don't really know alot about scripting and I don't understand how to trigger the lasers. Can you give me an example?
Can you make a example where you call setActive(true) I got only errors when I try to turn them on. Attempt to call nil value (field 'setActive'). I've tried Lazer.setActive(true), self.setActive(true) and setActive(true). My fxmanifest is ok and i have imported the lasers to my client file.
could you please send for me any sample i don't know how i can make playerhit
Hi mkafrin
I have recently tried to use this script to add an extra layer of fun to my qb-bankrobbery but cant seem to get lasers to be visible or active we have tried mutiple variations of how to get it working and still cant figure it out please see below the code we are using at the bottom of our qb-bankrobbery file. Cheers for any help on the matter
Jason
//qb-bankrobbery coding//
-- Name: PaletoVault | 2022-06-21T09:47:42Z
local laser = Laser.new(
vector3(-101.272, 6467.252, 31.888),
{vector3(-104.084, 6464.408, 31.908)},
{travelTimeBetweenTargets = {1.0, 1.0}, waitTimeAtTargets = {0.0, 0.0}, randomTargetSelection = true, name = "PaletoVault"}
)
-- Using methods on laser (in this case, calling setActive(true), which turns on the laser)
laser.setActive(true)
Should work like onPlayerInOut in PolyZone. Basically takes a callback that is triggered whenever the player is hit by the laser.
I have completed the previous steps in the readme file. Also put Laser.new()
in my client file. But when I try to call setActive(true)
in the same lua file as my script is supposed to activate the lasers, all I get is an error:
SCRIPT ERROR: @vaultrobbery/client:53: attempt to call a nil value (field 'setActive')
Hopefully I imported the script correctly. Followed your steps and put @ before the mentioned, which I assume means it import any folder in the resource folder(?) and doesnt have to be inside my vaultrobbery folder
I'm trying to make this work.
I made a laser named 'testlaser'
Do I need to activated it with 'testlaser.setActive(true)' or 'Laser['testlaser'].setActive(true)' or ?
I can't seem to figure it out
Hey I found you from nopixel as developer and I seen you're using lasers in the big vault I wanted to try it out and I created my lasers and I followed your steps and it was not showing i created new resource with _resource.lua and put the client script code and i pasted the generated code to another file client.lua and when i run server it not showing.
Add the ability to have multiple origin points. This will enable scenarios where you have the origin and target moving, like a horizontal laser that moves back and forth along the wall.
hello i used this code in here and it says its not working and idea why?
CreateThread(function()
while true do
Laser.onPlayerHit(function(playerBeingHit, hitPos)
if playerBeingHit then
QBCore.Functions.Notify('1', 'error', 7500)
print("True")
else
-- Laser just stopped hitting the player
-- hitPos will just be a zero vector here
end
end)
end
end)
--edit nvm i got it working
When using onPlayerHit Function it returns StartShapeTestRay as nil
when running through where the lasers have been setup its printing "person hit" as expected
however there are no lasers visible
FIX: REMOVED use_experimental_fxv2_oal 'yes' FROM MANIFEST
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.