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

Reading ini's with VB


zade_o
 Share

Recommended Posts

Ok sooo This is what I'm trying to do. Instead of using the level up from killing stuff and using points on your stats, you get xp based on your damage and depending on how you're fighting (like RS) so I need a way for the player to see how much xp he has and how much the next level in that stat is. I have an ini file with all the levels and their xp values. What I want is for the player to click the icon for that skill and then the EXP bar that's under the HP bar will change to show that skills experience data. But I don't know how to change the label in the VB project to display information from an ini file
Link to comment
Share on other sites

Why do you want it at a bar?

Well:
```
XPBar.Visible = False
lblGhost.Visible = True
Call SendData("loadlblghost" & END_CHAR)

```
Server Side:
```
Case "loadlblghost"
Dim attacklvl As Integer
attacklvl = ReadINI("attack", "lvl", App.Path & "\Accounts\" & PlayerName (look this up) & "\stats.ini", vbNullString)
Call SendDataTo(Index, "getlblghost" & SEP_CHAR & attacklvl & END_CHAR)

```These AIN'T the actual names.
Also, I didn't test it, but I think it will work.
Link to comment
Share on other sites

yes, you should take an example to the original XP system…

to read an ini use this little tut:

**ReadINI("TITLE", "LINE", PATH)**

**ok now the explaining:**

Title part:

The TITLE is the word written between brackets
so for example in your ini stats xp table there is

[STRENGHT]

Exp1=50
Exp2=120

etc…

so you need to fill in STRENGHT

what we got so far: **ReadINI("STRENGHT", "LINE", PATH)**

Line part:

The line part is the name of the line in the ini file UNDER the title of course you want to read.

so again same example,

[STRENGHT]

Exp1=50
Exp2=120

etc…

You want to read Exp2 so you fill in Exp2\. (fill in the name of the line not the number as that should be 2)

what we got so far: **ReadINI("STRENGHT", "Exp2", PATH)**

Path part:

here we are going to tell vb6.0 where the ini file we want to read is located on the PC
for exaple C:\Admin etc… but that aint good as when other peoples play they won't be putting the game folder in the same location as you did (FE: they use the E drive)

now what you do is you add App.Path (then it sarts reading from the folder where the EXE is located :) then add & and then the location. FE when you have put it in the map FOLDER and the file is called strenghtxp.ini then add this line

App.Path & "\FOLDER\strenghtxp.ini"

when you put the file in the same folder as the exe, put this

App.Path & "\strenghtxp.ini"

what we got so far: **ReadINI("STRENGHT", "Exp2", App.Path & "\strenghtxp.ini")**

End Result:

**ReadINI("STRENGHT", "Exp2", App.Path & "\strenghtxp.ini")**

TADAAAA you read your ini :) good job!
enjoy :)

anyhow to blit the label its pretty easy… i guess yo u could find it yourself, if not feel free to PM me :)
- Tyr

PS: wow this was like a real tut oO, when i add images i could probably post it ^^
Link to comment
Share on other sites

only problem is this, (i think i didn't read through your thing fully) but warconn and i realized that using the app.path thing in the client code will put the ini in the client folder instead of the server so we realized we have to use packets…I'm not messing with that just yet =)

Actually I can probably do some work around so that the new ini just gets the info from the other ini in the server but whenever you read the ini for real data you would use the one from the server, but for display purposes, read the onee from the client.
Link to comment
Share on other sites

well i explained above how to READ a ini (with the ode explained above), so as you say you read the ini in the server folder then you want to send the info to the client add:

senddatato(Index, "strenghtxp" & SEP_CHAR & the info you want to send & END_CHAR)

take for teh example under here that the info is the amount of strenghtxp the player has

i'm not gonna explain this like above i guess its easy enough to understand oO

then you add a packet in the client, modHandleData at the bottom a new packet (but before End Sub of course!)

FE:

    ' :::::::::::::::::::::::::::::::::::::
    ' :: Recieving Strenght exp ::
    ' :::::::::::::::::::::::::::::::::::::

If casestring = "strenghtxp" Then
        SetSrenght(Index) = val(Parse(1)) NOTE: THIS FUNCTION DOES NOT EXISTS, YOU HAVE TO CREATE IT
        ….
        ...
        ..
        .
end if

at the points you just type the code that happens when the data is recieved.
the val(Parse(1)) is the value of the information you sended.

if its a word f.e the don't type val but just parse(1)

well well, this is what u needed right?
Link to comment
Share on other sites

hey i am trying to learn this packet stuff as well, and i am having a hard time lol.

Server side, in ModHandleData i have
```
Sub SendSkill(ByVal Index As Long)
Dim FileData

FileData = ReadINI("Woodcutting", "level", App.Path & "\Scripts\charextras\" & GetPlayerName(Index) & ".ini")

Call SendDataTo(Index, "skills" & SEP_CHAR & FileData & END_CHAR)
End Sub

```
when i compile it, i get an error on the READINI, it says "Argument Not Optional"

Client Side i have in the modhandle data

```
    If (casestring = "skills") Then
        FileData = parse(1)

        frmMirage.lblskilllvl.Caption = FileData
        Exit Sub
    End If

```
i dont get any error with this.

Sorry, i am really stuck with this one though lol
Thanks
Link to comment
Share on other sites

First of all, don't use SendSkill but loadskill (no caps).
Also, you'll need a Case in the Server.
Client presses a button:
```
Call SendData("loadskill" & END_CHAR)

```
Server-Side (modHandleData, first sub):
```
Case "loadskill"
test = ReadINI(see explanation above)
Call SendDataTo(Index, "getskill" & SEP_CHAR & test & END_CHAR)
Exit Sub

```
Client-sided, modHandleData:
```
If parse(0) = "getskill" Then
frmTest.Show
frmTest.lbl1.Caption = Parse$(1) or Val#(parse(1))
End If

```
Hope it helped, if not, PM me :P
Link to comment
Share on other sites

@Warconn:

> hey i am trying to learn this packet stuff as well, and i am having a hard time lol.
>
> Server side, in ModHandleData i have
> ```
> Sub SendSkill(ByVal Index As Long)
> Dim FileData
>
> FileData = ReadINI("Woodcutting", "level", App.Path & "\Scripts\charextras\" & GetPlayerName(Index) & ".ini")
>
> Call SendDataTo(Index, "skills" & SEP_CHAR & FileData & END_CHAR)
> End Sub
>
> ```
> when i compile it, i get an error on the READINI, it says "Argument Not Optional"
>
> Client Side i have in the modhandle data
>
> ```
>     If (casestring = "skills") Then
>         FileData = parse(1)
>        
>         frmMirage.lblskilllvl.Caption = FileData
>         Exit Sub
>     End If
>
> ```
> i dont get any error with this.
>
> Sorry, i am really stuck with this one though lol
> Thanks

as yo usay the problem lies in reading the ini, the path doesn't really look wrong to me but ya you should prty to put it in a variable

Sub SendSkill(ByVal Index As Long)
Dim FileData
Dim Path

Path =  "App.Path & "\Scripts\charextras\" & GetPlayerName(Index) & ".ini""
FileData = ReadINI("Woodcutting", "level", Path)

don't know if it should work… but its worth a try
Link to comment
Share on other sites

@anasky:

> First of all, don't use SendSkill but loadskill (no caps).
> Also, you'll need a Case in the Server.
> Client presses a button:
> ```
> Call SendData("loadskill" & END_CHAR)
>
> ```
> Server-Side (modHandleData, first sub):
> ```
> Case "loadskill"
> test = ReadINI(see explanation above)
> Call SendDataTo(Index, "getskill" & SEP_CHAR & test & END_CHAR)
> Exit Sub
>
> ```
> Client-sided, modHandleData:
> ```
> If parse(0) = "getskill" Then
> frmTest.Show
> frmTest.lbl1.Caption = Parse$(1) or Val#(parse(1))
> End If
>
> ```
> Hope it helped, if not, PM me :P

thanks, i PMed you

@Tyr:

> as yo usay the problem lies in reading the ini, the path doesn't really look wrong to me but ya you should prty to put it in a variable
>
> Sub SendSkill(ByVal Index As Long)
> Dim FileData
> Dim Path
>
> Path =  "App.Path & "\Scripts\charextras\" & GetPlayerName(Index) & ".ini""
> FileData = ReadINI("Woodcutting", "level", Path)
>
> don't know if it should work… but its worth a try

yea i tryed that, and i am still getting the same thing…  i changed it to

```
path = App.Path & "\Scripts\charextras\" & GetPlayerName(index) & ".ini"
FileData = ReadINI("Woodcutting", "level", path, "0")

```and atleast my compiler let me through, so i dont know
Link to comment
Share on other sites

@anasky:

> Could you tell us what was wrong? For other players.

yea, i found that you need to val the readini for it to work serverside, here is mine
Case "loadskill"
Dim Filedata
Filedata = Val(ReadINI("Woodcutting", "level", App.Path & "\Scripts\charextras\" & GetPlayerName(index) & ".ini", "0"))
Call SendDataTo(index, "getskill" & SEP_CHAR & Filedata & END_CHAR)
Exit Sub
dunno what this does, but it works lol
that does into the server modhandledata underneath all of the other cases at the beginning.

client side is in the modhandledata

    If (casestring = "getskill") Then
        Dim skill
        skill = parse(1)
        frmMirage.lblskilllvl.Caption = Val(skill)
    End If
i figured out that because you val'ed the REadini you have to val the parse, thats the easiest way i found to do it.

and the button you use to get all of this to work is

    Call SendData("loadskill" & END_CHAR)

pretty simple once you get the hang of it.

@Tyr:

> heh packets is quite easy :D normally ppl figuere it out in about 30min :s

lol took me about a month to get it all to work lol, now i got to concentrate on  how to send data from the client to the server, should be easy now that i got the basic idea

Thanks Again guys
Link to comment
Share on other sites

Alright well the help was good and all but this is confusing the Duck out of me.

Ok. This is what I'm trying to get working at the moment. I have 2 labels, lblA and lblB.
I have a ini file for my character saved in the SERVER that looks like this

"[Style]
s = 0"

Now. If I click lblB i want it to change to s = 1 and back to s = 0 if I click lblA.

Soooo…. in the server, sub handleData I have this
```
        Case "loadstyle"
            Dim FileData
            FileData = Val(ReadINI("Style", "s", App.Path & "\Scripts\db\" & GetPlayerName(Index) & ".ini", "0"))
            Exit Sub
```

and in the client, I have this

```
    If casestring = "getstyle" Then
        Dim style
        style = parse(1)
        If (style = 0) Then
            frmMirage.Image4.Picture = LoadPicture(App.Path & "\GUI\CUSTOM\strstyle.gif")
        Else
            frmMirage.Image4.Picture = LoadPicture(App.Path & "\GUI\CUSTOM\defstyle.gif")
        End If
    End If
```
So a) is that right so far? and b) What do I need to do in the sub for clicking the 2 labels?
Link to comment
Share on other sites

Case "loadstyle"
Dim FileData
FileData = ReadINI("Style",  "s", (App.Path & "\Scripts\db\" & GetPlayerName(Index) & "\.ini"), vbNullString)
Exit Sub

What was wrong: I won't use Val(ReadINI), I'm not sure how it works, and if it even works properly.
"0" doesn't works as good as vbNullString (well, it doesn't in my code).

    If casestring = "getstyle" Then
        Dim style
        style = Val#(parse(1))
        If style = 0 Then
            frmMirage.Image4.Picture = LoadPicture(App.Path & "\GUI\CUSTOM\strstyle.**bmp**")
        Else
            frmMirage.Image4.Picture = LoadPicture(App.Path & "\GUI\CUSTOM\defstyle.**bmp**")
        End If
    End If

Sub for 2 lbl's:
Sub lblA_Click()
Call SendDataTo("loadstrdeflbl" & SEP_CHAR & 1 & END_CHAR)
End Sub

Sub lblB_Click()
Call SendDataTo("loadstrdeflbl" & SEP_CHAR & 0 & END_CHAR)
End Sub

ModHandleData.mod:
Case "loadstrdeflbl"
Call WriteINI("Style", "s", Val#(Parse(1)), (App.Path & "\Scripts\db\" & GetPlayerName(Index) & "\.ini))
Exit Sub
Link to comment
Share on other sites

@anasky:

> Case "loadstyle"
> Dim FileData
> FileData = ReadINI("Style",  "s", (App.Path & "\Scripts\db\" & GetPlayerName(Index) & "\.ini"), vbNullString)
> Exit Sub
>
> What was wrong: I won't use Val(ReadINI), I'm not sure how it works, and if it even works properly.
> "0" doesn't works as good as vbNullString (well, it doesn't in my code).
>
>     If casestring = "getstyle" Then
>         Dim style
>         style = Val#(parse(1))
>         If style = 0 Then
>             frmMirage.Image4.Picture = LoadPicture(App.Path & "\GUI\CUSTOM\strstyle.**bmp**")
>         Else
>             frmMirage.Image4.Picture = LoadPicture(App.Path & "\GUI\CUSTOM\defstyle.**bmp**")
>         End If
>     End If
>
> Sub for 2 lbl's:
> Sub lblA_Click()
> Call SendDataTo("loadstrdeflbl" & SEP_CHAR & 1 & END_CHAR)
> End Sub
>
> Sub lblB_Click()
> Call SendDataTo("loadstrdeflbl" & SEP_CHAR & 0 & END_CHAR)
> End Sub
>
> ModHandleData.mod:
> Case "loadstrdeflbl"
> Call WriteINI("Style", "s", Val#(Parse(1)), (App.Path & "\Scripts\db\" & GetPlayerName(Index) & "\.ini))
> Exit Sub


vbnulstring definatly works alot better i found out, thanks
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...