Mirage Source
Need help again. D: - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Need help again. D: (/showthread.php?tid=1559)



Need help again. D: - Daemonblade777 - 12-02-2008

Alright, well I'm trying to make a better /delete command in my game. >_> And I seem to have gotten everything but this last part to work.

I keep getting the error "Compile Error: Argument not optional" and I have no clue why. I keep getting it on the "Call DelChar(Index" part. :/ Could someone please help me out? (tell me if you need more information)

Code:
' ::::::::::::::::::::::::::
    ' :: Delete Player Packet ::
    ' ::::::::::::::::::::::::::
    If LCase(Parse(0)) = "senddelchar" Then
            If GetPlayerAccess(GetPlayerAccess(Index)) >= 5 Then
                Call DelChar(Index)
                Call AlertMsg("Character data has been saved!")
            Else
                Call PlayerMsg(Index, "Failed to delete player!", Yellow)
        End If
    Exit Sub
    End If
End Sub

Oh, and I also keep getting the same error "Compile Error: Argument not optional" on this part of my code as well...I keep getting it on the "Call SendDelChar" part...

Code:
' Delete player
        If LCase(Mid(MyText, 1, 8)) = "/delchar (PlayerName)" Then
            Call SendDelChar
            MyText = ""
            Exit Sub
        End If

I think I would do better on my code if I actually knew what that error meant lol. I searched the error on google, but I didn't find anything to help me. :/

*EDIT*

Oh, and I have yet another problem...v.v I tried adding guilds to MS, and now I'm getting "RTE 9: Subscript Out of Range". When I run it in debug mode, it highlights "Npc(n).Name = Parse(2)" for the RTE 9...The strange thing is, I never messed with the Update npc packet...lol

Code:
' :::::::::::::::::::::::
    ' :: Update npc packet ::
    ' :::::::::::::::::::::::
    If (LCase(Parse(0)) = "updatenpc") Then
        n = Val(Parse(1))
        
        ' Update the item
        Npc(n).Name = Parse(2)
        Npc(n).AttackSay = ""
        Npc(n).Sprite = Val(Parse(3))
        Npc(n).SpawnSecs = 0
        Npc(n).Behavior = 0
        Npc(n).Range = 0
        Npc(n).DropChance = 0
        Npc(n).DropItem = 0
        Npc(n).DropItemValue = 0
        Npc(n).STR = 0
        Npc(n).DEF = 0
        Npc(n).SPEED = 0
        Npc(n).MAGI = 0
        Exit Sub
    End If



Re: Need help again. D: - Ambientiger - 12-02-2008

First things first, the "Compile Error: Argument not optional" means that you are missing some of the arguments required by that particular Sub/Function. Look at the Sub/Function in question and make sure you are passing all the required arguements.

I'll give you an example with the first error you get:

This is the DelChar Sub as it appears in the server side code in MSE1
Code:
Sub DelChar(ByVal Index As Long, ByVal CharNum As Long)
Dim f1 As Long, f2 As Long
Dim s As String

    Call DeleteName(Player(Index).Char(CharNum).Name)
    Call ClearChar(Index, CharNum)
    Call SavePlayer(Index)
End Sub
In your code you have passed the required Index value, but not the CharNum value that the Sub requires.
Code:
Call DelChar(Index)
I'll leave you to sort out the second one for yourself, if you have any troubles with it post again and I'll give you a hand.

The second problem is going to take a little more investigation.
When your in debug mode and it highlights the "Npc(n).Name = Parse(2)" bit, roll your mouse over the 'Parse(2)' bit and let me know what value it holds?
Now this is just a guess, but the typerec for an npc in MSE1 says that this value should be a string no longer than NAME_LENGTH (which is set at 20 characters in modConstants), maybe the npc name is longer.