• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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 28
Joined
Sep 26, 2009
Messages
2,520
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:
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