Vb6 Ressources add a required level to mine/cut something.

Hello, I would like to know how to add a required level to mine or cut something, as said in the topic title.

But the problem is that I tried to add it and I added this piece of code in the frmEditor_Resource Code


If Player.Level = RessourceLevel.text Then

scrlTool.Enabled = True


scrlTool.Enabled = False

End If

and I added a textbox named: RessourceLevel

In the frmEditor_Resource frame.

and I would like to make the textbox only numeric writeable if possible…

Sorry for repost…

Yay! Someone willing to learn! ^_^

So, to start things off, you need to add a new variable to the ResourceRec so that each resource can have its own level requirement. Look for something like ResourceRec in modTypes. In between “Private Type ResourceRec” and “End Type” put there something like this.

LevelReq as long

You need to do this in your server source and client source. Double click on the textbox, and put there this code.

' This sub will be called every time you type in the textbox.
' If the text in the textbox is NOT numeric, then change it to the last thing it was set to.
if not isnumeric(txtLevelReq.text) then txtLevelReq.text = Resource(editorindex).LevelReq
Resource(editorindex).LevelReq = txtLevelReq.text

There’s still one more thing we have to do in the client. Go to the sub called ResourceEditorInit. This sub is called every time you click on the listbox with all the resources in the Resource Editor.

If you see something like “With frmEditor_Resource”, then under it put there this

.txtLevelReq.text = Resource(EditorIndex).LevelReq

That should be it for the client. Save, and compile.

Now for the server!

Go to the sub CheckResource and look for this

                    ' inv space?
                    If Resource(Resource_index).ItemReward > 0 Then
                        If FindOpenInvSlot(index, Resource(Resource_index).ItemReward) = 0 Then
                            PlayerMsg index, "You have no inventory space.", BrightRed
                            Exit Sub
                        End If
                    End If

Under or above that, put there this.

                    ' Check to see if we have the needed level
                    If Resource(Resource_index).LevelReq > Player(index).Level Then
                        Call PlayerMsg(index, "You need a level of " + Resource(Resource_index).LevelReq + " to use this resource!", BrightRed)
                        Exit Sub
                    End If

There’s one last thing you need to do before you’re done. You need to delete all of your resources in your data files. The only way you can avoid this is by making a converter. If you don’t, you’ll get runtime errors. Anyways, that should be it! Let me know if you have any questions!

Lol C much?

" + Resource(Resource_index).LevelReq + "

cough vb6

" & Resource(Resource_index).LevelReq & "

Actually, VB6 lets you do both. ;D

For the sake of readability it may be slightly better to stickwith  what the rest of the engine does though. 😛 But yes both of those should work.

Thank you so much, Mod Matt, it worked perfectly 🙂

And I tried something to see the limit of it, and the limit is the max level 🙂

Thanks again 😛

Log in to reply