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

Player level and drops


Snoozey
 Share

Recommended Posts

Looking to modify spawn item sub. I would like it to check the players level. If the player is 5 levels over the monster level, it will not drop an item. I am assuming this is the code I will need to change

```
Sub SpawnItem(ByVal itemnum As Long, ByVal ItemVal As Long, ByVal mapNum As Long, ByVal x As Long, ByVal y As Long, Optional ByVal playerName As String = vbNullString)
    Dim i As Long

    ' Check for subscript out of range
    If itemnum < 1 Or itemnum > MAX_ITEMS Or mapNum <= 0 Or mapNum > MAX_MAPS Then
        Exit Sub
    End If

    ' Find open map item slot
    i = FindOpenMapItemSlot(mapNum)
    Call SpawnItemSlot(i, itemnum, ItemVal, mapNum, x, y, playerName)
End Sub
```
I think this is the code I need to add for it to check, but I get an error " expected then or goto" and then it highlights NPC

```
if player(index).Level =< 5 npc(index).Level then
"Spawn code"
else
exit sub
endif

```
Any ideas? Still learning how to do this.
Link to comment
Share on other sites

Don't modify that code. (That's unrelated to the if statement syntax error which you got.)

This piece of code is called in many places for various reasons. It's called for spawning map items and player drops. Don't assume any system can be changed without changing others. Here's the NPC drop code:
```
            Call SpawnItem(Npc(npcNum).DropItem, Npc(npcNum).DropItemValue, mapNum, MapNpc(mapNum).Npc(mapNpcNum).x, MapNpc(mapNum).Npc(mapNpcNum).y

```
So you could write:
```
If Abs(Player(attacker).Level - Npc(npcNum).Level) <= 5 Then
    ' above code
End If

```
But please do not use Exit Sub here! You will royally mess up your server.
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...