| Mirage Source http://miragesource.net/forums/ |
|
| TakeGold http://miragesource.net/forums/viewtopic.php?f=210&t=2887 |
Page 1 of 1 |
| Author: | William [ Tue Oct 16, 2007 5:17 pm ] |
| Post subject: | TakeGold |
Basicly I remade the TakeItem for this one. I didn't see TakeItem fitting my need on my travel system. Add this in a module: Code: Function TakeGold(ByVal index As Long, ByVal ItemNum As Long, ByVal ItemVal As Long) As Boolean Dim i As Long, N As Long TakeGold = False ' Check for subscript out of range If IsPlaying(index) = False Or ItemNum <= 0 Or ItemNum > MAX_ITEMS Then Exit Function End If For i = 1 To MAX_INV ' Check to see if the player has the item If GetPlayerInvItemNum(index, i) = ItemNum Then If Item(ItemNum).Type = ITEM_TYPE_CURRENCY Then ' Is what we are trying to take away more then what they have? If so just set it to zero If ItemVal <= GetPlayerInvItemValue(index, i) Then Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) - ItemVal) Call SendInventoryUpdate(index, i) TakeGold = True Exit Function End If End If End If Next i End Function Usage example: Code: If TakeGold(index, 1, 40) = True Then
Call PlayerWarp(index, 1, 10, 10) 'if you have 40 gold, this code will run. Else Call PlayerMsg(index, "You do not have 40 gold.", Red, 0) 'if you do not have 40 gold, this code will run. End If |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|