Jump to content

[Question]How can I add fx?


kieranb

Recommended Posts

Hello,  the title says it all... how can I add fx?  I am currently trying to learn from the fxAddWaterHydrant  on the wiki. here's all I got so far, this is just something to help me learn a little more about it and understand it.

function createHydrants(local)
	local x, y, z = getElementPosition(localPlayer) -- Get your location.
	for i=0, 20 do -- 20 Hydrants.
		fxAddWaterHydrant(x + math.random(-5,5), y + math.random(-5,5), z) -- Using math.random, and your current location 20 water hydrants are created.
	end
end
addCommandHandler("hyd", createHydrants)

The only error is on line 4, "Attempt to call fxAddWaterHydrant (a nil value)"

Link to comment
20 minutes ago, StormFighter said:

It says that fxAddWaterHydrant is not an existing command. Now. fx functions are client side. I assume your tried to do that on server side.

Both.... same thing happens :/ 

Nvm, I made a typo, I found a list of GTA effects on forum though, are only a few included in MTA or are all there since it runs off of GTA? (I tried using fxAddFireLarge  (fire_large) and nothing happened).

Link to comment
-----------------
-- CLIENT SIDE --
-----------------
function createHydrants()
	local x, y, z = getElementPosition(localPlayer) -- Get your location.
	for i=0, 20 do -- 20 Hydrants.
		fxAddWaterHydrant(x + math.random(-5,5), y + math.random(-5,5), z) -- Using math.random, and your current location 20 water hydrants are created.
	end
end
addCommandHandler("hyd", createHydrants)

Here it is. The working code. The problem was the "local" in the functions arguments. local is a reserved word for lua. You can't use it as variable, and you don't have to define it.

Link to comment
34 minutes ago, StormFighter said:

-----------------
-- CLIENT SIDE --
-----------------
function createHydrants()
	local x, y, z = getElementPosition(localPlayer) -- Get your location.
	for i=0, 20 do -- 20 Hydrants.
		fxAddWaterHydrant(x + math.random(-5,5), y + math.random(-5,5), z) -- Using math.random, and your current location 20 water hydrants are created.
	end
end
addCommandHandler("hyd", createHydrants)

Here it is. The working code. The problem was the "local" in the functions arguments. local is a reserved word for lua. You can't use it as variable, and you don't have to define it.

Thanks! :D Also there is a heli dust effect in the effects list called "heli_dust" is there a way of putting this in? I tried it as is and also fxAddHeliDust but still nothing. :(

Link to comment
22 minutes ago, StormFighter said:

createEffect()

 

Not working, done this:

function Jets()
	local x, y, z = getElementPosition(localPlayer)
		for i=0, 20 do 
		createEffect (petrolcan, (x + math.random(-5,5), y + math.random(-5,5), z) 
		end
	end
end	
addCommandHandler("jet", Jets)

Basically the exact same except I replaced fxAdd with createEffect, no errors.....

Link to comment
effect createEffect ( string name, float x, float y, float z [, float rX, float rY, float rZ, float drawDistance = 0 ] )

 

function Jets()
	local x, y, z = getElementPosition(localPlayer)
	for i=0, 20 do 
		createEffect ("petrolcan", x + math.random(-5,5), y + math.random(-5,5), z) 
	end
end	
addCommandHandler("jet", Jets)

-- There were multiple problems. First of all, local isn't a function. You don't have to close it. local just makes variables exist only in the code block it is in. In other words, varibales starting with local like "local pig = 'animal'" only exist until you end the function it is in.
-- createEffect's first argument have to be string.
-- You had a "(" before x, but you did not close it.

 

Edited by StormFighter
  • Like 1
Link to comment

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...