• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Player leaves the game

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2013
Messages
90
Well I was trying to find a way in which player when leaves the game there would be a message displayed to all others: ''[Name of Player] Has Left the game.'' Then his units will be removed his items got sold automatically and gold will be splitted to his teammates
 
Level 25
Joined
Sep 26, 2009
Messages
2,387
I'm not sure if you can somehow find out the price of an item directly... if not, I would do it via some dummy unit specifically meant for this. This dummy unit would have the backpack ability.
You would need to keep check of all heroes that player has.
Then when player leaves, you remove all items from every hero, then one by one you give it to the dummy unit and make it sell that item.
I don't really know how else you could get the sum of gold from every item that player had.

Once that is done, then it is simply a matter of picking all units of said player and removing them; and taking his gold and splitting it between his allies (sum each player gets = gold of leaving player / number of his allies).

Note though, that the sum may not be exactly split.
Gold is an integer number (number without decimal point), which means everything behind decimal point is lost when that number is converted into integer.
E.g. 44/5 = 8.8 --> converted to integer (= all behind decimal point is lost) --> 8
When you calculate it back, 5*8 = 40, so you ultimately lost 4 gold.
Unless you make the gold system more complicated so it will ~evenly split the gold between allies, you will always have inaccurace ranging between 0 to (number of allies -1).
 
Last edited:
Level 29
Joined
Oct 24, 2012
Messages
6,543
You can use my system to detect what gold an item is worth. http://www.hiveworkshop.com/forums/spells-569/item-unit-cost-system-v1-0-1-0-a-245280/
Note: My system tells how much an item is bought for. If you want the sell price simply divide the bought price by 2.

This way you could get rid of the sell order. It would make it much faster.
Then you would have to do like Nichilus said and remove all units owned by player.
Then split gold among other players.
 
Status
Not open for further replies.
Top