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

[EO - Event System] Heal Player From Admin Panel


00GuthixLord
 Share

Recommended Posts

Ok this is my second code I've Done with VB6 and eclipse so I hope it helps. :)

* * *

Outcome:

>! ![](http://i45.tinypic.com/2ngr0ab.png)

* * *

Client:

Ok for to start off we need a button:

* Open client
* Then frmMain
* Expand frmMain To The Right
* Rearrange the admin panel so you can fit in another button
* After you add in your button double click and it will take you to some code

The code should look something like this:

```
Private Sub HealPlayer_Click()

End Sub

```
The first thing we should add is the debug so its a simple code that looks like this:

```
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Exit Sub
errorhandler:
    HandleError "HealPlayer_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub

```
Now to prevent hackers add:
```
    If GetPlayerAccess(MyIndex) < ADMIN_MAPPER Then

        Exit Sub
    End If
```That checks if you the owner/admin. Now we need it to do some thing so make a variable name, I chose HealThem so I would add this:
```
    HealThem Trim$(txtAName.text)
```That tells the code to read from some where else, Now open modClientTCP.
In there find a empty spot that is not in a sub and make your own sub. It should look something like this(With The Debug):
```
Public Sub HealThem(ByVal Name As String)
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler
    Exit Sub
errorhandler:
    HandleError "HealThem", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```Ok now that we have are sub we need to tell it what to do so add this:

```
' This goes under your sub name
Dim Buffer As clsBuffer

    'This Goes After The Goto Errorhandler
    Set Buffer = New clsBuffer
    Buffer.WriteLong CHealer
    Buffer.WriteString Name
    SendData Buffer.ToArray()
    Set Buffer = Nothing

```That tells the code to send the name to the server with CHealer you can change that but make sure it has a C in front.
Ok to make it so the server receives that you need to open modEnumerations and find this:
```
' Packets sent by client to server
Public Enum ClientPackets

```There is a big long list after it, you need to add CHealer after the last 'C' thing But Before    CMSG_COUNT .
Example:

>! ```
    CDeclineTradeRequest
    CPartyRequest
    CAcceptParty
    CDeclineParty
    CPartyLeave
    CEventChatReply
    CEvent
    CSwitchesAndVariables
    CRequestSwitchesAndVariables
    CHealer ' Its After The Last C thing
>! ```

* * *

Server:

Ok your in the server now so open modEnumerations first and add the last part of Client in the same spot.
Ok after that you need to open modHandleData, and find a nice open spot and add this:
```
Sub HandleHealThem(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long, ByVal Vital As Vitals)
    Dim n As Long
    Dim buffer As clsBuffer
    Set buffer = New clsBuffer
    buffer.WriteBytes Data()

    ' Prevent hacking
    If GetPlayerAccess(index) < ADMIN_MAPPER Then
        Exit Sub
    End If

    ' The player
    n = FindPlayer(buffer.ReadString) 'Parse(1))
    Set buffer = Nothing
    If n <> index Then
        If n > 0 Then
        Else
        End If
    Else
    End If
End Sub

```Explanation:

>! ```
Sub HandleHealThem(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long, ByVal Vital As Vitals)
>! ```That starts the sub with all your values you need.
The HandleHealThem change that to the Variable you created for the Trim$ part in the client.
>! ```
    Dim n As Long
    Dim buffer As clsBuffer
    Set buffer = New clsBuffer
    buffer.WriteBytes Data()
```That creates your variable n, and Buffer then sets buffer as the clsBuffer and gets your data you sent from client.
>! ```
    ' Prevent hacking
    If GetPlayerAccess(index) < ADMIN_MAPPER Then
        Exit Sub
    End If
>!     ' The player
    n = FindPlayer(buffer.ReadString) 'Parse(1))
    Set buffer = Nothing
>! ```These kinda explain them self's, but the set buffer just stops the buffer from working because it has all the data it needs.
>! ```
    If n <> index Then
        If n > 0 Then
        Else
        End If
    Else
    End If
>! ```That checks to see if your using it on your self or another person.. The 'If n > 0 Then' checks if the player is on.
Now to add healing replace the whole 'If n <> index then' statement with this:
```
    If n <> index Then
        If n > 0 Then
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
        Else
            Call PlayerMsg(index, "Player is not online.", White)
        End If
    Else
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
    End If
```
Explanation:

>! ```
        If n > 0 Then
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
        Else
            Call PlayerMsg(index, "Player is not online.", White)
        End If
```That gets a player that wasn't a the person using the button and heals them.
```
The 'If n > 0 Then' Checks If There Online
    Else
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
    End If
```The Else Say's That its the Admin Healing Them Self And Heals Them.
>! ```
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
```That Gets The Players Max HP and MP Then:
```
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
```That Gives Them There Max HP And MP
```
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
```That Just Tells The Player He Was Healed
>! ```
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
```That Puts It Into The Server Log.
I Hope That Helped.  And I Put Enough Explanation In It. :P

Sorry If There Are Any Misspellings Or Grammar Mishaps Writing Tutorials With All The Spoilers And Code Makes Me Mess Up Alot.  :embarrassed:
Link to comment
Share on other sites

```
    If n <> index Then
        If n > 0 Then
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
        Else
            Call PlayerMsg(index, "Player is not online.", White)
        End If
    Else
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
    End If

```
This is the same thing with less lines of code
```
        If n > 0 Then
            Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
            Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
            Call SendVital(n, Vitals.HP)
            Call SendVital(n, Vitals.MP)
            Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
            Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
        Else
            Call PlayerMsg(index, "Player is not online.", White)
        End If

```
Link to comment
Share on other sites

TheChoosenOne:

>! @TheChoosenOne:
>! > Lol. You got me. I was wondering will index show the name or the index number? I personally believe it is the number so it might be
> ```
> getplayername(index)
>
> ```
>! Well The Code Is Set Up To Use The "Name" Text Box For The Player "n"
>! @TheChoosenOne:
>! > Wanted to say. This can be used by anyone who is greater than mapper. So when a log is added shouldn't it be
> ```
> call addlog(index & "healded" & hetplayername(n)& ".", Admin_log)
>
> ```saying that you can be anyone
>! Yes That Would Work I Never Thought Of That :)

* * *

Joost:

>! @Joost:
>! > ```
>     If n <> index Then
>         If n > 0 Then
>             Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
>             Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
>             Call SendVital(n, Vitals.HP)
>             Call SendVital(n, Vitals.MP)
>             Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
>             Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
>         Else
>             Call PlayerMsg(index, "Player is not online.", White)
>         End If
>     Else
>             Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
>             Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
>             Call SendVital(n, Vitals.HP)
>             Call SendVital(n, Vitals.MP)
>             Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
>             Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
>     End If
>
> ```
> This is the same thing with less lines of code
> ```
>         If n > 0 Then
>             Call SetPlayerVital(n, Vitals.HP, GetPlayerMaxVital(n, Vitals.HP))
>             Call SetPlayerVital(n, Vitals.MP, GetPlayerMaxVital(n, Vitals.MP))
>             Call SendVital(n, Vitals.HP)
>             Call SendVital(n, Vitals.MP)
>             Call PlayerMsg(n, "You Feel Refreshed.", BrightBlue)
>             Call AddLog("You Healed" & GetPlayerName(n) & ".", ADMIN_LOG)
>         Else
>             Call PlayerMsg(index, "Player is not online.", White)
>         End If
>
> ```
>! Well, I Did That So You Can Choose If You Want The Person To Be Able To Heal Them Self, If Not You Could Put Like:
```
Call PlayerMsg(index, "You Cannot Heal Yourself.", White)
```

* * *

Sigridunset:

>! @Sigridunset:
>! > Please change ES to Event System unless this **really** works in Eclipse Stable…. ES stands for Eclipse Stable and nothing else otherwise people would get confused.
>! Ok I Will Change It. I Didn't Know There Was A Eclipse Stable any more.

* * *

Thanks.  :P
Link to comment
Share on other sites

Index is simply a long value (a number).

GetPlayerName(index) gets the name of the player who would heal whomever….

Furthermore, although ES - Event System or ES - Eclipse Stable could end up confusing... a simple glance at the code would show that it is referring to a version of Eclipse newer than stable. One easy giveaway is the admin panel image. Another, the fact that it is using the Buffer class. Either way, Eclipse Stable is old/outdated/etc... and new tutorials should not be coming out for it anyways.

@00GuthixLord, overall it is a little messy but the code appears like it would work as intended so good job and keep it up! It is nice seeing so many contributions to the source tutorials section in such a small window of time.
Link to comment
Share on other sites

  • 1 month later...
> I know, but I was wondering if anyone had made it work on Eclipse Advance, as that is based on Eclipse Nightly, which is basically Eclipse Origins 3.0.

Just taking a precursory glance, I see no reason why it shouldn't work with Eclipse Nightly. I would make a back up, add it in, and report back on whether or not it works.

Basically, if the tutorial does any rendering, it won't work on Eclipse Nightly without adaptation.
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...