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

Call sub to show text on label.


Toxikr3
 Share

Recommended Posts

Hi guys, I have a new question :D

I would like to be able to call a sub like so from the main:

ShowOnLabel(Index, valueOfItemInInventory)

And I would like a label in source edit to show the valueOfItemInInventory.

The second value could be any value really, I simply want to call it from main, and show the value on a new label in a source edit.

Thanks,
-Toxikr3
Link to comment
Share on other sites

What type of value would you like to display I wonder?

But none the less.

Add this to the server code
```
Sub ShowOnLabel(Index As Long, ByVal valueOfItemInventory As Long)
    Call SendDataTo(Index, "showonlabel" & SEP_CHAR & valueOfItemInventory & END_CHAR)
End Sub

```
In client source modHandleData, add a new case

```
Case "showonlabel"
    frmMirage.LABELNAME.Caption = Val(Parse(1))
    Exit Sub

```
Replace "LABELNAME" with the name of the label you want to show. Also, if you want it to send text instead change the ByVal valueOfItemInventory As Long, to: ByVal valueOfItemInventory As String.

And change Val(Parse(1)) to Trim(Parse(1)).

Now you can call the sub from sadscript by typing Call ShowOnLabel(Index, VALUE), where value is the thing the label will display.

Hop this helps you
Link to comment
Share on other sites

Hi, thanks for the help but I am getting a Type Mismatch error on the server.

I copied the first code to the bottom of frmServer

and I copied the second code and placed it after the last case, after Case "npcattack" in modHandleData.

I am calling it from OnArrowHit like so:

Call ShowOnLabel(Index, 5)

What am I doing wrong?
-Toxikr3
Link to comment
Share on other sites

Mismatch is often an error you get when trying to assign a value to a variable that cannot hold that type of value. If you've set the variable as long you should have no problem with assigning 5 to it. But if you've set it as string try doing this: Call OnShowLabel(Index, "5"). that should do it :)
Link to comment
Share on other sites

So let me get this straight.  Your trying to create a subroutine in the server that you can call from the server that will show value on a label in the client?

Wait a second….. are you trying to make a sub you can call from sadscript?

If so:
Open up clsCommands in the server project and scroll down to the bottom.  Add this sub:
```
Public Sub ShowOnLabel(ByVal index As Long, ByVal Caption As String)
    Call SendDataTo(index,"showonlabel" & SEP_CHAR & Caption & End_Char)
End Sub
```
Now go to modHandleData in your CLIENT project

Somewhere in your Sub HandleData if statements put this:
```
If casestring = "showonlabel" Then
    frmMirage.lblshowon.Caption = parse(1)
    Exit Sub
    End If
```

now go to frmMirage and add a label called 'lblshowon'  and place it in the correct place

To show the caption:
```
Call ShowOnLabel(Index,"Label Text")
```
If thats what you wanted there you go.

oh… and this parses strings..., if you want to show a number:
```
Call ShowOnLabel(Index,Number + 0)
```
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...