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

Making the chest attribute work (source tutorial)


dao
 Share

Recommended Posts

First id like to say i couldnt of done this without unknown. thanks xD
if i missed something post it.
Go to map editor go on attributes and find chest one and open the properties window and make it visible.
then paste this code inside of it

> frmChest.Show vbModal

All client sided

Ctrl find this in mod game editor:

> If frmMapEditor.optChest.Value = True Then

Then make sure it looks like this:

> If frmMapEditor.optChest.Value = True Then
>                                 .Type = TILE_TYPE_CHEST
>                                 .Data1 = ChestItemNum
>                                 .Data2 = ChestItemAmount
>                                 .Data3 = 0
>                                 .String1 = vbNullString
>                                 .String2 = vbNullString
>                                 .String3 = vbNullString
>                             End If

Ctrl find this in mod game editor:

> If frmMapEditor.optChest.Value = True Then

Then make sure it looks like this:

> If frmMapEditor.optChest.Value = True Then
>                                 .Type = TILE_TYPE_CHEST
>                                 .Data1 = ChestItemNum
>                                 .Data2 = ChestItemAmount
>                                 .Data3 = 0
>                                 .String1 = vbNullString
>                                 .String2 = vbNullString
>                                 .String3 = vbNullString
>                             End If

Ctrl find this:

> ' Handle when the player presses the return key

At the bottom add this:

> If Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex) - 1).Type = TILE_TYPE_CHEST And Player(MyIndex).Dir = DIR_UP Then
>                 Call SendData("openchest" & SEP_CHAR & END_CHAR)
>                 Exit Sub
>             End If
>         End If

Now Ctrl find this:

> If Map(GetPlayerMap(MyIndex)).Tile(X, Y).Type = TILE_TYPE_BLOCKED

And highlight the whole code and replace with:

> If Map(GetPlayerMap(MyIndex)).Tile(X, Y).Type = TILE_TYPE_BLOCKED Or Map(GetPlayerMap(MyIndex)).Tile(X, Y).Type = TILE_TYPE_SIGN Or Map(GetPlayerMap(MyIndex)).Tile(X, Y).Type = TILE_TYPE_ROOFBLOCK Or Map(GetPlayerMap(MyIndex)).Tile(X, Y).Type = TILE_TYPE_CHEST Then
>         CanMove = False
>         Exit Function
>     End If

Now in mod types add:

> ' Used for chest editor
> Public ChestItemNum As Long
> Public ChestItemAmount As Long

Now download this and put it in your source and drag it in your frm's
[http://www.freemmorpgmaker.com/files/imagehost/pics/caa5d63d7ae2cfc30034c7716cc4843c.zip](http://www.freemmorpgmaker.com/files/imagehost/pics/caa5d63d7ae2cfc30034c7716cc4843c.zip)
Link to comment
Share on other sites

Ctrl find this in mod game editor:

> If frmMapEditor.optChest.Value = True Then

Then make sure it looks like this:

> If frmMapEditor.optChest.Value = True Then
>                                 .Type = TILE_TYPE_CHEST
>                                 .Data1 = ChestItemNum
>                                 .Data2 = ChestItemAmount
>                                 .Data3 = 0
>                                 .String1 = vbNullString
>                                 .String2 = vbNullString
>                                 .String3 = vbNullString
>                             End If
Link to comment
Share on other sites

in mod game logic search for this

> ' Say message
>       If Len(Trim$(MyText)) > 0 Then
>             Call SayMsg(MyText)
>         End If
>         MyText = vbNullString
>         Exit Sub
>     End If

if its not there add it then test
Link to comment
Share on other sites

>.< try adding this to the botton of handle data in the server
```
Case "openchest"
            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_CHEST Then
                If Val(ReadINI(GetPlayerName(Index), "Chest" & GetPlayerMap(Index) & "," & GetPlayerX(Index) & "," & (GetPlayerY(Index) - 1), App.Path & "\Chests.ini", 0)) = 0 Then
                    Call PlayerMsg(Index, "The chest contained " & Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data2 & " " & Trim$(Item(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1).Name), 1)
                    Call GiveItem(Index, Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1, Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data2)
                    Call WriteINI(GetPlayerName(Index), "Chest" & GetPlayerMap(Index) & "," & GetPlayerX(Index) & "," & (GetPlayerY(Index) - 1), 1, App.Path & "\Chests.ini")
                Else
                    Call PlayerMsg(Index, "You already opened this chest", BLUE)
                End If
            Else
                Call HackingAttempt(Index, "Trying to chest cheat!!")
            End If
            Exit Sub
    End Select

    Call HackingAttempt(Index, "Received invalid packet: " & Parse(0))
```
Link to comment
Share on other sites

or instead of saying at the bottom coz people WILL put it in the wrong place as the bottom is where it handles all the packets not where it gets them.

Find
```

Case "getclasses"
            Call Packet_GetClasses(Index)
            Exit Sub

```
and underneath it put…

```

Case "openchest"
            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_CHEST Then
                If Val(ReadINI(GetPlayerName(Index), "Chest" & GetPlayerMap(Index) & "," & GetPlayerX(Index) & "," & (GetPlayerY(Index) - 1), App.Path & "\Chests.ini", 0)) = 0 Then
                    Call PlayerMsg(Index, "The chest contained " & Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data2 & " " & Trim$(Item(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1).Name), 1)
                    Call GiveItem(Index, Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1, Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data2)
                    Call WriteINI(GetPlayerName(Index), "Chest" & GetPlayerMap(Index) & "," & GetPlayerX(Index) & "," & (GetPlayerY(Index) - 1), 1, App.Path & "\Chests.ini")
                Else
                    Call PlayerMsg(Index, "You already opened this chest", BLUE)
                End If
            Else
                Call HackingAttempt(Index, "Trying to chest cheat!!")
            End If
            Exit Sub

```
Link to comment
Share on other sites

not working, every time i try to compile it gives me "End If without block If" and highlights the end if of this:

' Say message
      If Len(Trim$(MyText)) > 0 Then
            Call SayMsg(MyText)
        End If
        MyText = vbNullString
        Exit Sub
    End If
Link to comment
Share on other sites

Umm.well, you can see the problem with the ifs. Maybe, try this?:

' Say message
      If Len(Trim$(MyText)) > 0 Then
            Call SayMsg(MyText)
        MyText = vbNullString
        Exit Sub
    End If

You can see its simple, just remove an end if.
Link to comment
Share on other sites

i'll shove it in the "your edit bit" =D

and i know whats causing an error in this btw for people now when they try to chat and they get a full string when they press any letter.

if you didnt put this RIGHT AT THE BOTTOM of the sub that handles when the enter key is pressed then remove one of the end if's… so it goes...
```
If Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex) - 1).Type = TILE_TYPE_CHEST And Player(MyIndex).Dir = DIR_UP Then
                Call SendData("openchest" & SEP_CHAR & END_CHAR)
                Exit Sub
            End If
        End If

```
to

```
If Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex) - 1).Type = TILE_TYPE_CHEST And Player(MyIndex).Dir = DIR_UP Then
                Call SendData("openchest" & SEP_CHAR & END_CHAR)
                Exit Sub
            End If

```
Link to comment
Share on other sites

  • 2 weeks 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...