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

[EO] SellAll button problem


erkro1
 Share

Recommended Posts

EDIT: Well, I actually have 2 other questions, but don't wanna spam by making a topic for each.

So here they are:
1:
FIXED

2:
I have a Sell all [item name] button to sell all the items which have the same number, so that it sells all the Meat for example.

But the problem is that the code isn't working and I don't know how to fix it.
Here is the code:
```
Private Sub mnuSellAll_Click()
Dim InvNum, i As Long

InvNum = IsInvItem(LastItemX, LastItemY)

For i = 1 To MAX_INV
    If PlayerInv(i).num = InvNum Then
        SellItem PlayerInv(i).num
    End If
Next

SellItem InvNum
End Sub
```
Link to comment
Share on other sites

This code is run by SendExp to send the EXP from the server to the client. Can you elaborate on the nature of the error? (What did you expect - What happened) Can you post your SendEXP sub (server)?

Also, what is this "second player gets 0 EXP fix" (I searched and I was unable to find it). Can you post a link?
Link to comment
Share on other sites

@Justn:

> Maybe the second fix here? http://www.touchofdeathforums.com/smf/index.php/topic,77397.0.html

That sounds about right, anyway, this may (or may not) fix it.

* * *

Use this sub:

```
Private Sub HandlePlayerExp(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim i As Long
Dim TNL As Long

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()

    SetPlayerExp MyIndex, Buffer.ReadLong
    TNL = Buffer.ReadLong
    frmMain.lblEXP.Caption = GetPlayerExp(MyIndex) & "/" & TNL
    ' mp bar
    frmMain.imgEXPBar.width = ((GetPlayerExp(MyIndex) / EXPBar_Width) / (TNL / EXPBar_Width)) * EXPBar_Width

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "HandlePlayerExp", "modHandleData", Err.number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
Link to comment
Share on other sites

Wow, that fixed it, pretty stupid that I didn't tried it, thanks for your help. ;)

EDIT: Well, I actually have 2 other questions, but don't wanna spam by making a topic for each.

So here they are:

1:
When I move my mouse on txtMyChat it disappears under it, which is kinda annoying with editing the chat text, any idea where the problem could be?

2:
I have a Sell all [item name] button to sell all the items which have the same number, so that it sells all the Meat for example.

But the problem is that the code isn't working and I don't know how to fix it.
Here is the code:
```
Private Sub mnuSellAll_Click()
Dim InvNum, i As Long

InvNum = IsInvItem(LastItemX, LastItemY)

For i = 1 To MAX_INV
    If PlayerInv(i).num = InvNum Then
        SellItem PlayerInv(i).num
    End If
Next

SellItem InvNum
End Sub
```
Link to comment
Share on other sites

@Justn:

> I also have the mouse problem but on frmmenu txtbox.. only way I could fix it was deleting it and copy and pasting new one from a backup where it was working.. but still don't know what's causing it :/

I've copy/pasted from serveral backups but it doesn't fix it. :sad:
Weird thing is that I have another label for Channel selection next to it which works fine.

EDIT: Fixed it, it was because the back color was some kind of grey, so thesame as the mosue cursor when you move it on a textbox, back to the SellAll problem.
Link to comment
Share on other sites

@Erwin:

> I have a Sell all [item name] button to sell all the items which have the same number, so that it sells all the Meat for example.
>
> But the problem is that the code isn't working and I don't know how to fix it.
> Here is the code:
> ```
> Private Sub mnuSellAll_Click()
> Dim InvNum, i As Long
>
> InvNum = IsInvItem(LastItemX, LastItemY)
>
> For i = 1 To MAX_INV
>     If PlayerInv(i).num = InvNum Then
>         SellItem PlayerInv(i).num
>     End If
> Next
>
> SellItem InvNum
> End Sub
> ```

hm…This sounds like a great feature...I will look into fixing this :D
Is this Client Side?
Link to comment
Share on other sites

In my opinion you're trying to something clientside that should be handled serverside. Below sub is what I would use. Now all you have to do is send a packet when the client clicks on your SellAll thing and then call this sub serverside when receiving the packet. Search both client-side and server-side for "CSellItem" for an example, and set up an CSellAllItems packet yourself. Enjoy.

```
Sub HandleSellAllItems(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim invSlot As Long
    Dim itemnum As Long
    Dim price As Long
    Dim multiplier As Double
    Dim amount As Long
    Dim i As Long
    Dim y As Long
    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()

    invSlot = Buffer.ReadLong

    ' if invalid, exit out
    If invSlot < 1 Or invSlot > MAX_INV Then Exit Sub

    ' has item?
    If GetPlayerInvItemNum(Index, invSlot) < 1 Or GetPlayerInvItemNum(Index, invSlot) > MAX_ITEMS Then Exit Sub

    ' seems to be valid
    itemnum = GetPlayerInvItemNum(Index, invSlot)

    ' work out price
    multiplier = Shop(TempPlayer(Index).InShop).BuyRate / 100
    price = Item(itemnum).price * multiplier

    ' item has cost?
    If price <= 0 Then
        PlayerMsg Index, "The shop doesn't want that item.", BrightRed
        ResetShopAction Index
        Exit Sub
    End If

    'this is the only changed part, first of all it goes through the entire inventory
    For i = 0 To MAX_INV
        If GetPlayerInvItemNum(Index, i) = itemnum Then        'to check if the item number matches the item we want to sell
            ' take item and give gold
            TakeInvItem Index, i, GetPlayerInvItemValue(Index, i)          'if the item number = correct, then we take as many as we can (GetPlayerInvItemValue(Index, i) )
            GiveInvItem Index, 1, price * GetPlayerInvItemValue(Index, i) 'and we give gold for the items, since we might sell a stack of 20 we multiply the gold by the amount of things sold
        End If
    Next i

    ' send confirmation message & reset their shop action
    PlayerMsg Index, "Trade successful.", BrightGreen
    ResetShopAction Index

    Set Buffer = Nothing
End Sub

```
Link to comment
Share on other sites

@Justn:

> Lol thanks erwin I am using the same grey color guess ill change it now

Your welcome. :P

@Joost:

> -snip-

Well, I thought a loop with SellItem thing would work as well, although its easier to do it server side like you said, I'll look into that, thanks for the code.
Although I'm not gonna make a different packet but just modify the SellItem packet to check if SellAll thing is on.

Thanks all, I'll lock this. :cheesy:
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...