Jump to content
garganeo

Remove equipped items on death script

Recommended Posts

Hello there!
Please guys, help me out - I am very new to lua and I want to make a simple script for my mangoszero - I want my players to lose equipped items on death ... I am having very bad time and it should be very short and simple... still I can't do it myself, can any1 please help :? Thanks in advance!

Edited by garganeo

Share this post


Link to post
Share on other sites

Many thanks ... looks very interesting I might try to implement it too ... Btw I solved my issue I'm thinking what if I add this to my destroy items on death function ... and would the 2 of them co-exist just fine, or will the item destroy script trigger first and then make the above script unable to pick up an item... anyhow, here is the topic containing the code used for item destroy if some1 else needs it, Rochet2 wrote it for me :

 

  • Like 1

Share this post


Link to post
Share on other sites

although i am from the old days of programming before scripting etiquette , I do want to bring up the point to also work on your art of `code block indentation`.

local function RemoveItemsOnDeath (_, killer, killed) 			
local bag = 255;

		for slot = 0, 18;
			local item = killed:GetItemByPos( bag, slot );

				if item then
					killed:RemoveItem(item, 1);
				end
		end
end

RegisterPlayerEvent(6, RemoveItemsOnDeath)

also you can use `_` to replace a variable name in your function declaration since it's a value not being used in the function so this will send it straight to the garbage collector rather than taking up memory by storing the value.

Edited by slp13at420

Share this post


Link to post
Share on other sites

Nice, man thank you! Losing items on death has certainly been an amazing experience ! I am wondering though are there any ready made player loot scripts ... Like when you die all your gear is dropped in some form ... let's say for any1 to pick it up no matter the faction... does this exist ? Because I myself may try to do it if it doesnt... I saw one solution for player loot but it contained another sql table where the items that are going to become the loot are stored. I thought that is somehow over-complicated so I'm wondering is this done in lua only? Does any1 have it for share ?
thank you!


 

Share this post


Link to post
Share on other sites

I have seen this feature before. The way they handled it was to drop a chest when the player died, which then could be looted by anyone. A chest can be spawned with a LUA script on player died, but the loot table for that specific chest must change real time if it's going to contain the items which that dead player had equipped. This means that you must somehow connect the dead player with the exact (by GUID?) chest he spawns.

I imagine that the best way to do this would be to create a DB table where you'd inject the players currently equipped item ID's along with his character GUID, then use that as a loot table for the chest spawned on player died. Which is not possible in eluna.

The other option would be to temporarily store the loot in RAM, but how it then would be added to the loot table of the object I am not sure. I do not believe that is currently possible with eluna.

Share this post


Link to post
Share on other sites

tbh would not be to hard to script.. upon death , spawn the empty chest then loop through the victim's complete equipped/unequipped items , delete each one from the victim's inventory then add the same item(new GUID ofc) to the chest's loot table , attach a timer to the chest and despawn or remove the chest after the timer expires.

 

Edited by slp13at420

Share this post


Link to post
Share on other sites

If you add the loot to that chest's loot table, it will drop from all currently spawned chests. You have to add it to the exact chest that drops from that player.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you guys I will start working on this the other week. Seems ppl like the concept.

My server is in open beta since yesterday and currently the death penalty is all equipped items are removed.
There are other changes too, I am aiming at improving the game without breaking the vanilla feeling ...
Join our discord if u want to check it out or  also help us develop it.
Will post back when I try the chest thing...
Cheers!
Discord: https://discord.gg/7Q5gcBk

Share this post


Link to post
Share on other sites

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

Contact Us

To contact us click here
You can also email us at [email protected]

Privacy Policy | Terms & Conditions

Repositories

The Link to the master list
of MaNGOS repositories:
Copyright © getMaNGOS. All rights Reserved.

This website is in no way associated with or endorsed by Blizzard Entertainment®
×
×
  • Create New...