Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Items don't dissapear after use


aiko
 Share

Recommended Posts

I used this script:
```
Sub TakeItem(index, item, value)
If value = "all" Then
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = item Then
Call SetPlayerInvItemNum(index, SLOT, 0)
Call SetPlayerInvItemValue(index, SLOT, 0)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
Else
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = item Then
Call SetPlayerInvItemNum(index, SLOT, 0)
Call SetPlayerInvItemValue(index, SLOT, GetPlayerInvItemValue(index, SLOT) - value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
End If

Sub GiveItem(index, item, value)
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = 0 Then
Call SetPlayerInvItemNum(index, SLOT, item)
Call SetPlayerInvItemValue(index, SLOT, value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
```And placed it right here:
```
Sub SetBank(Map, X, Y)
Call SetAttribute(Map, X, Y, 23, 0, 0, 0, "", "", "")
End Sub

' Tests scripts up to the location of Sub TestMain(Index).
' Leave this sub at the bottom to test the entire script file.
Sub TestMain(Index)
Call PlayerMsg(Index, "Scripts are working properly.", BRIGHTGREEN)
End Sub

Sub TakeItem(index, item, value)
If value = "all" Then
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = item Then
Call SetPlayerInvItemNum(index, SLOT, 0)
Call SetPlayerInvItemValue(index, SLOT, 0)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
Else
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = item Then
Call SetPlayerInvItemNum(index, SLOT, 0)
Call SetPlayerInvItemValue(index, SLOT, GetPlayerInvItemValue(index, SLOT) - value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
End If

Sub GiveItem(index, item, value)
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = 0 Then
Call SetPlayerInvItemNum(index, SLOT, item)
Call SetPlayerInvItemValue(index, SLOT, value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
```
And still, takeitem isn't working….

I already checked this:
```
' Tests scripts up to the location of Sub TestMain(Index).
' Leave this sub at the bottom to test the entire script file.
Sub TestMain(Index)
Call PlayerMsg(Index, "Scripts are working properly.", BRIGHTGREEN)
End Sub
```But they also said: place it a the very bottom, so…

Can someone give me:
The reason why it isn't working(Even when it's a noob fault)
Or give me the right script?
Link to comment
Share on other sites

Hello aiko!

I suggest you use [http://www.touchofdeathforums.com/smf/index.php/topic,28174.0.html](http://www.touchofdeathforums.com/smf/index.php/topic,28174.0.html), just don't forget to give him credit.

It includes useful commands like GetFreeSlots, GiveItem, GiveCurrency, CanTake and TakeItem. Actually… That's pretty much all of them. In his post he gives out the code itself plus instruction on how to you it and documentation. The easiest way for you to use the code would be to place it at the end of your main.txt. Don't worry about the TestMain, sub placement usually doesn't matter in the main.txt. I keep the TestMain at the bottom, though, just because it says so.

Good luck! ^_^
Link to comment
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
 Share

×
×
  • Create New...