Toxikr3 Posted March 15, 2010 Author Share Posted March 15, 2010 Hi guys, I have a new question :DI 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 More sharing options...
Elenfir Posted March 15, 2010 Share Posted March 15, 2010 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 More sharing options...
Toxikr3 Posted March 15, 2010 Author Share Posted March 15, 2010 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 frmServerand 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 More sharing options...
Elenfir Posted March 16, 2010 Share Posted March 16, 2010 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 More sharing options...
Toxikr3 Posted March 17, 2010 Author Share Posted March 17, 2010 That doesn't work either :SIts something really minor that I am missing -_--Toxikr3 Link to comment Share on other sites More sharing options...
Elenfir Posted March 18, 2010 Share Posted March 18, 2010 Are you using Trim(parse(1)) or Val(Parse(1)) and try switching them :) Link to comment Share on other sites More sharing options...
Toxikr3 Posted March 18, 2010 Author Share Posted March 18, 2010 I tried everything :SI did Byval - as string and as long,tried Tirm, and Val, and just Parse:S:S:S:S:SSomething is very wrong ^_^-Toxikr3 Link to comment Share on other sites More sharing options...
westin444 Posted March 18, 2010 Share Posted March 18, 2010 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 projectSomewhere 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 placeTo 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 More sharing options...
Toxikr3 Posted March 18, 2010 Author Share Posted March 18, 2010 Hey thanks! It works!!For the number however, I don't quite get it? Do I simply put the (int/long)variable where the string is supposed to go?-Toxikr3 Link to comment Share on other sites More sharing options...
westin444 Posted March 18, 2010 Share Posted March 18, 2010 No… where the string should be you put: Number + 0Number is your integer/long Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now