Created
December 27, 2017 18:12
-
-
Save TomGrobbe/1915f29f665a8cb49cf4eac739d7fbbe to your computer and use it in GitHub Desktop.
Particle spawner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RegisterCommand('particle', function(source, args, rawCommand) | |
local dict = args[1] | |
local name = args[2] | |
local loop = tostring(args[3]) | |
if dict == nil or name == nil then | |
Citizen.Trace('[Particles] Invalid arguments.') | |
TriggerEvent('chatMessage', '', {255,255,255}, '[Particles] ^8Error: ^1Invalid arguments.') | |
else | |
RequestNamedPtfxAsset(dict) | |
while not HasNamedPtfxAssetLoaded(dict) do | |
Citizen.Wait(0) | |
end | |
Citizen.Trace("[Particles] Dict loaded.") | |
TriggerEvent('chatMessage', '', {255,255,255}, '[Particles] ^8Dict loaded.') | |
UseParticleFxAssetNextCall(dict) | |
local coords = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 8.0, 0.5) | |
if loop == "true" or loop == "1" then | |
Citizen.Trace("[Particles] Starting looped particle effect") | |
TriggerEvent('chatMessage', '', {255,255,255}, '[Particles] ^8Starting ^*looped^r^8 particle effect.') | |
local particle = StartParticleFxLoopedAtCoord(name, coords, 1.0, 1.0, 1.0, 1.0, false, false) | |
Citizen.Wait(5000) -- wait 5 seconds before stopping the particle effect. | |
StopParticleFxLooped(particle) | |
Citizen.Trace("[Particles] Stopping looped particle effect") | |
TriggerEvent('chatMessage', '', {255,255,255}, '[Particles] ^8Stopping ^*looped ^r^8particle effect.') | |
else | |
Citizen.Trace("[Particles] Starting non-looped particle effect") | |
TriggerEvent('chatMessage', '', {255,255,255}, '[Particles] ^8Starting ^*non-looped^r^8 particle effect.') | |
local particle = StartParticleFxNonLoopedAtCoord(name, coords, 1.0, 1.0, 1.0, 1.0, false, false) | |
end | |
end | |
end, false) | |
Citizen.CreateThread(function() | |
TriggerEvent('chat:addSuggestion', '/particle', 'Spawn a particle 8 meters in front of you.', {{name="dictionary", help="This is the name of the particle dictionary."}, {name="effect", help="This is the name of the particle effect."}, {name="looped", help="True/False (should the animation be looped?)"}}) | |
end) | |
--- ## /particle <string: dictionaryName> <string: effectName> [bool: looped] ## | |
-- looped is optional, defaults to false. Some particles only work if you spawn them looped, others only work if you don't spawn them looped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment