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

[EE] Custom Menu Array Fix (Sort of)


balliztik1
 Share

Recommended Posts

This fix applies to all releases of EE that contain custom menus.

This isn't really a fix so much as a way around an annoyance with the current Custom Menu arrays. As it is, when calling a custom label, button, or picture onto your menu, the client checks the index number versus the upper bounds of the array. While this works if you specifically call the elements in order, the client will crash if you do not. Here's how I worked around that.

Somewhere in the client source (I chose modGeneral), add this function:

```
Public Function IsInArray(CtrlArray As Variant, Index As Integer) As Boolean
    On Error Resume Next
    Dim x As String
    x = CtrlArray(Index).name
    If Err.Number = 0 Then IsInArray = True
End Function
```
This is a function I found [here](http://www.vbforums.com/showthread.php?t=180280), and Edneeis should be credited for it, not me. It checks if the control array exists by means of trapping errors. This way, you can pinpoint if the element you are trying to create exists rather than assuming so based on the UBound.

Now, simply replace the following lines (from the client's modHandleData) with the new function:

```
        If CustomIndex > frmCustom1.picCustom.UBound Then
            Load frmCustom1.picCustom(CustomIndex)
        End If
```
Becomes:

```
        If Not IsInArray(frmCustom1.picCustom, CInt(CustomIndex)) Then
            Load frmCustom1.picCustom(CustomIndex)
        End If
```
Do this for text boxes, labels, and pictures.

Now, you can create your elements in whatever order you desire without fear of client crashing.
Link to comment
Share on other sites

AWESOME!!!!!! Custom menu's with no error!!! Thanks a billion :)

Although I did have to put spaces here and there. Code psoted above is kinda all together.
RX: OnErrorResumeNext
Should be: On Error Resume Next

Right? Just saying if someone with no VB knowledge wants to add this edit.

Anyways, thanks once again. You just saved my life. ;)
Link to comment
Share on other sites

@Zamin:

> AWESOME!!!!!! Custom menu's with no error!!! Thanks a billion :)
>
> Although I did have to put spaces here and there. Code psoted above is kinda all together.
> RX: OnErrorResumeNext
> Should be: On Error Resume Next
>
> Right? Just saying if someone with no VB knowledge wants to add this edit.
>
> Anyways, thanks once again. You just saved my life. ;)

Hmmm…it looks all together to me. I copied and pasted it and it was fine.
Link to comment
Share on other sites

  • 3 months later...
  • 4 weeks later...
EDIT: HM….. I posted in wrong post -_-

Please move this to the Quest Log + Quest Script post please
.... weird...

Hi, I have tried this with 2.8 and for some reason it will not work.
I did the array fix and followed the tutorial but it won't work.

I try to press PG Down and nothing pops up. I have checked the hot script and I have this

```
' Executes when a hotkey is pressed client-side.
Sub HotScript(Index, KeyID)
Select Case KeyID
' Executes when any player presses the PageUp key.
Case 1

' Executes when any player presses the Delete key.
Case 2

' Executes when players press the End key.
Case 3

' Executes when players press the PageDown key.
Case 4
'***********************Begin Quest Log***********************
Dim QuestCount
Dim QuestYCoord
Dim IndexCount
Dim Quest

QuestCount = 1
QuestYCoord = 50
IndexCount = 1

Call CustomMenuClose(Index)
Call CustomMenuShow(Index, "QuestLog", "\GUI\CUSTOM\QuestExtra\QuestLog.gif", 1)
Call CustomMenuLabel(Index, 0, "Close!", 150, 280, 8, 4, 0, 40, 15)           
Do While QuestCount <= Int(GetVar("\Scripts\Quests\QuestSystem.ini", "QUESTS", "Amount"))            
    Quest = GetVar("Scripts\Quests\QuestDatabase\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest" & QuestCount)
    If Quest = 1 Then
          Call CustomMenuPicture(Index, IndexCount, "\GUI\CUSTOM\QuestExtra\Quest" & QuestCount & "Accepted.gif", 3, QuestYCoord)
          QuestYCoord = QuestYCoord + 25
    ElseIf Quest = 2 Then
          Call CustomMenuPicture(Index, IndexCount+1, "\GUI\CUSTOM\QuestExtra\Quest" & QuestCount & "Completed.gif", 3, QuestYCoord)
          QuestYCoord = QuestYCoord + 25
    End If
    IndexCount = IndexCount + 2
    QuestCount = QuestCount + 1 
Loop
Exit Sub
'***********************End Quest Log***********************
End Select
End Sub
```
This shouldn't even be connect to other stuff right? Just the popng up of the menu?
Also when I type /questreset name number
It says this command doesn't exists
```
' Executed whenever a slash command is sent to the server.
Sub Commands(Index)
Dim TextSay
Dim PlayerID
Dim MapNum

' Get the command and arguments from the cache.
TextSay = Trim(GetVar("Scripts\Command.ini", "TEMP", "Text" & Index))

' Split the command into an array. All arguments are seperated by spaces.
TextSay = Split(TextSay)

Select Case TextSay(0)
Case "/testscripts"
Call TestMain(Index)
Exit Sub

Case "/help"
Call PlayerMsg(Index, "Social Commands:", WHITE)
Call PlayerMsg(Index, "'msghere = Broadcast Message", WHITE)
Call PlayerMsg(Index, "-msghere = Emote Message", WHITE)
Call PlayerMsg(Index, "!namehere msghere = Player Message", WHITE)
Call PlayerMsg(Index, "Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /party, /join, /leave, /refresh", WHITE)
Exit Sub

Case "/calladmins"
If GetPlayerAccess(Index) = 0 Then
Call AdminMsg(GetPlayerName(Index) & " needs your help!", BRIGHTGREEN)
Else
Call PlayerMsg(Index, "You are an admin! You cannot call for help!", BRIGHTGREEN)
End If
Exit Sub

Case "/admin"
If GetPlayerAccess(Index) > 0 Then
Call PlayerMsg(Index, "Social Commands:", WHITE)
Call PlayerMsg(Index, """msghere = Global Admin Message", WHITE)
Call PlayerMsg(Index, "=msghere = Private Admin Message", WHITE)
Call PlayerMsg(Index, "Available Commands: /admin, /loc, /mapeditor, /warpmeto, /warptome, /warpto, /setsprite, /mapreport, /kick, /ban, /edititem, /respawn, /editnpc, /motd, /editshop, /ban, /editspell", WHITE)
End If
Exit Sub

Case "/warpmeto"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(Index, GetPlayerMap(PlayerID), GetPlayerX(PlayerID), GetPlayerY(PlayerID))
Call PlayerMsg(Index, "You have been warped to " & GetPlayerName(PlayerID) & ".", BROWN)
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
End If
Exit Sub

Case "/warptome"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(PlayerID, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(PlayerID, "You have been warped to " & GetPlayerName(Index) & ".", BROWN)
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
End If
Exit Sub

Case "/warpto"
If GetPlayerAccess(Index) > 0 Then
MapNum = TextSay(1)

If MapNum > 0 And MapNum <= MAX_MAPS Then
Call PlayerWarp(Index, MapNum, GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(Index, "You have been warped to map #" & MapNum & ".", BRIGHTBLUE)
Else
Call PlayerMsg(Index, "Invalid map number.", BRIGHTRED)
End If
End If
Exit Sub
'***********************Begin Quest***********************
Case "/questreset"
    If GetPlayerAccess(Index) >= 5 Then
          Dim QuestCount
          Dim PlayerName
          Dim QuestName
          Dim CheckName

          QuestCount = 1
          PlayerName = TextSay(1)
          QuestName = Lcase(TextSay(2))

          CheckName = QuestReset(index, PlayerName)
          If CheckName = "EndOfFile" Then
              Call PlayerMsg(Index, "The player '" & PlayerName & "' does not exit!", RED)
              Exit Sub
          ElseIf QuestName = "all" Then
              Do While QuestCount <= Int(GetVar("\Scripts\Quests\QuestSystem.ini", "QUESTS", "Amount"))
                    Call PutVar("\Scripts\Quests\QuestDatabase\" & PlayerName & ".ini", "QUESTS", "Quest" & QuestCount, 0)
                    QuestCount = QuestCount + 1
              Loop
              Call PlayerMsg(Index, "All quests for player " & PlayerName & " has been reset.", BLACK)
          ElseIf Int(QuestName) > Int(GetVar("\Scripts\Quests\QuestSystem.ini", "QUESTS", "Amount")) OR Int(QuestName) = 0 Then
              Call PlayerMsg(Index, "Quest" & QuestName & " does not exist. Perhaps check the 'Amount' of your total quests set in QuestSystem.ini", RED)
          Else
              Call PutVar("\Scripts\Quests\QuestDatabase\" & PlayerName & ".ini", "QUESTS", "Quest" & QuestName, 0)
              Call PlayerMsg(Index, "Quest" & QuestName & " for player " & PlayerName & " has been reset.", BLACK)
          End If
    Else
          Call PlayerMsg(Index, "You do not have enough access to use this command.", BRIGHTGREEN)
    End If
Exit Sub
'***********************End Quest***********************

End Select

Call PlayerMsg(Index, "That is not a valid command.", BRIGHTRED)
End Sub
```
I think I have done everything right… :(
Help please

-Toxikr3
Link to comment
Share on other sites

  • 6 months later...

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...