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

What the **** did I do?


Larias
 Share

Recommended Posts

Sorry for posting twice in a day, but this has got me riled up because I can't figure out what is going on. Whenever I try to compile, I get an "Argument is not Optional" error, which, from what I understand, means that the If statement will always pick one option. But I don't know why, since I didn't touch this section.

Here is the code that is getting error'd:

```
' in party?

If TempPlayer(attacker).inParty > 0 Then

' pass through party sharing function

Party_ShareExp TempPlayer(attacker).inParty, exp, attacker

Else

' no party - keep exp for self

GivePlayerEXP attacker, exp

End If
```
Specifically, Party_ShareExp TempPlayer(attacker).inParty, exp, attacker.

I added in EXP sharing which is working just fine. However, I wanted only players in party on the map to get experience. Here's my Party_ShareExp:

```
Public Sub Party_ShareExp(ByVal partyNum As Long, ByVal exp As Long, ByVal Index As Long, ByVal mapnum As Long)

Dim expShare As Long, i As Long, tmpIndex As Long, LoseMemberCount As Byte

' check if it's worth sharing

If Not exp >= Party(partyNum).MemberCount Then

' no party - keep exp for self

GivePlayerEXP Index, exp

Exit Sub

End If

' check members in others maps

For i = 1 To MAX_PARTY_MEMBERS

tmpIndex = Party(partyNum).Member(i)

If tmpIndex > 0 Then

If IsConnected(tmpIndex) And IsPlaying(tmpIndex) Then

If GetPlayerMap(tmpIndex) <> mapnum Then

LoseMemberCount = LoseMemberCount + 1

End If

End If

End If

Next i

' find out the equal share

If (Party(partyNum).MemberCount - LoseMemberCount) = 1 Then

expShare = expShare

End If

If (Party(partyNum).MemberCount - LoseMemberCount) = 2 Then

expShare = Round(exp * 0.8)

End If

If (Party(partyNum).MemberCount - LoseMemberCount) = 3 Then

expShare = Round(exp * 0.65)

End If

If (Party(partyNum).MemberCount - LoseMemberCount) > 3 And Party(partyNum).MemberCount < 8 Then

expShare = Round(exp * 0.5)

End If

If (Party(partyNum).MemberCount - LoseMemberCount) > 7 And Party(partyNum).MemberCount < 11 Then

expShare = Round(exp * 0.25)

End If

If (Party(partyNum).MemberCount - LoseMemberCount) > 10 Then

expShare = Round(exp * 0.2)

End If

' loop through and give everyone exp

For i = 1 To MAX_PARTY_MEMBERS

tmpIndex = Party(partyNum).Member(i)

' existing member?Kn

If tmpIndex > 0 Then

' playing?

If IsConnected(tmpIndex) And IsPlaying(tmpIndex) And GetPlayerMap(tmpIndex) = mapnum Then

' give them their share

GivePlayerEXP tmpIndex, expShare

End If

End If

Next

End Sub
```

wtf!??!?!
Link to comment
Share on other sites

Argument not optional means you're ignoring a parameter required by the sub/function to run.

You're calling it like this:

```
Party_ShareExp TempPlayer(attacker).inParty, exp, attacker
```

When Party_ShareExp takes the parameters:

```
ByVal partyNum As Long, ByVal exp As Long, ByVal Index As Long, ByVal mapnum As Long
```

So you're missing the MapNum.
Link to comment
Share on other sites

Argument not optional simply means you aren't passing enough values into a procedure, as well, you don't have an optional "fallback", if you like.

"Party_ShareExp TempPlayer(attacker).inParty, exp, attacker"

"Public Sub Party_ShareExp(ByVal partyNum As Long, ByVal exp As Long, ByVal Index As Long, ByVal mapnum As Long)"

As you can see from Party_ShareExp, you need to pass PartyNum, Exp, Index, and the MapNum. Guess which one you're missing. ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)
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...