Jump to content

ElementData


TorNix~|nR

Recommended Posts

Posted (edited)

Hello guys, I have a event that appears sometimes, is a boss, and it's element is "boss"

I want when the element is activated, the zombies doesn't appear, and when it's disabled

the zombies appear again, help?

local aa = getElementData("zombie")

if getElementData("boss") ~= true then
destroyElement(aa)

How can I do it?

Edited by TorNix~|nR

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted
function isBossActivated(bb)
local ee = getElementData(bb,"zombie")		 
if getElementData(bb,"boss") ~= true then
if isElement(ee) then return false end
	end
end

it's not working?

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

  • Moderators
Posted

You will have to study the script that is creating the `boss`, because this is just bull:~ code and will not get you anywhere.

Check for export functions or custom events you could trigger.

 

 

  • Thanks 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

I do not found the solution I try at least 100 times, even I use outputChatBox, and it didn't show :/

I just want when the boss is activated, the zombies disappear.

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

  • Moderators
Posted

Before you can try, you have to understand else those 100 times are for nothing.

So tell me what did you learn from the code?

 

 

  • Thanks 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)

I think I should not use true

I should use, like this

local boss = getElementData(source, "boss")
if boss then

is it?

Also I found this little code (example) on my client-side, so I think it's like that

addEventHandler("onClientPedDamage", root,
function  (attacker, weapon)
 	local boss = getElementData(source, "boss")
 	if boss and antiWeapon[weapon] then
		cancelEvent()
	end
end)

but the problem, I do not know how to do it..

Edited by TorNix~|nR

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

  • Moderators
Posted

Because you haven't found it yet. The boss is probably created serverside, because it has to be synced with all other players.

 

I do not know the script, neither I am going to spend time searching it for you (I don't have that luxury either). This will be your first research case, where you have to search and find a component you want to edit.

Did you know that I spend more than 30 hours researching a single resource? (one of the first large resources I came in contact with) While researching I started to edit things on the way, which makes researching a bit more interesting.

Tell me @TorNix~|nR, how much energy and time are you going to spend on achieving this?

 

  • Thanks 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
addEventHandler('onClientPedDamage',root,function(attacker,weapon,bodyPart,loss)
	if loss then
		local boss = getElementData(source,'boss')
		if boss then -- if you want to get its actual data.. if boss == 'yes its the :Oin boss xD' then
			cancelEvent()
			setElementHealth(source,(getElementHealth(source)-(loss%5))) -- this is if you want the boss to SLOWLY lose health..
		end
	end
end)

--[[
getElementData(element element, string dataName [, inherit = true/false])
setElementData(element element, string dataName, var value [, bool sync = true/false])
]]

Everything inside [] are optional arguments, the rest is required (usually).
Note that it is Element First, meaning ped, player, vehicle, whatever you are targeting.. Then after element is the data name..

Edited by ShayF
  • Thanks 1
Posted

@ShayF, Thank you, but I just want to stop spawning zombies while the boss is activated

and when the boss died, zombies come back, like that..

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Zombies aren't just appearing randomly, some part of the code is spawning them.. go there, add an if statement to check whether a boss is spawned and that's it. There's more than likely a timer or something already there that keeps the code running over and over again, so a simple if statement should be enough. 

  • Thanks 1
Posted

Done! guys I fixed it, and it was so easy xD, I just use startResource and stopResource, while the boss is activated :D 

Thanks for everyone!

  • Like 1

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

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