Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with .INI files....
#1
Currently, I am working with some code that hopefully when finished will accomplish the fallowing task. What I want is so that every time there is a player killer event, it increases your score based on the level difference (Less then, Equal, or greater then). However, I don't know how to use MySQL and I have no intention of learning it currently, so this left me with only one option... .ini files, which I have never used before. I was getting some help from someone on the basics (get var/putvar) but unfortinatly I need some more assistance. For anyone interested, I'll give you as much information as possible on what I want, and what I already have done...

- Upon Char creation it creates a new line in the .ini file ( CharName = 0 )
- Upon char deletion, it deletes that character in the .ini file
- Every time someone kills someone else, it increses the killers score in the .ini file
- Based on a timer on the client (or another good idea if anyone has one), it sends a packet to the server and requests the information from it.
----------------
Here are the segments of code that I have currently...


::Server Side::

- The packet (unfinished)
Code:
' :::::::::::::::::::::::::::::
        ' :: Player Killer LB packet ::
        ' :::::::::::::::::::::::::::::
        If LCase(Parse(0)) = CPNPKLLeader Then
            Call PlayerMsg(Index, "Packet is retreiveing new player killer information", Red)
            '***Retreive information***
        End If
    Exit Sub

- In the AddChar sub, near the bottom before it saves, I added this to create a new char on the ini file
Code:
' Saves the chars name to 0 on the player leaderboards
        Dim FileName As String
        FileName = App.Path & "\Data\PKLeaderboards.ini"
        Call PutVar(FileName, "PVP Kill Leaderboard", Trim(Player(Index).Char(CharNum).Name), "0")

- In modGameLogic, under "Has been deemed a player killer!" I placed this, and two others simler to it to act out different senerios for killing...

Code:
Dim PKLAmount As Integer, PKTotal As Integer
      Dim FileName As String
                
      ' Kill a lower level player
      If Player(Attacker).Level > Player(Victim).Level Then
          PKLAmount = 5
          FileName = App.Path & "\Data\PKLeaderboards.ini"
          PKTotal = GetVar(FileName, "PVP Kill Leaderboard", Trim(Player(Index).Char(CharNum).Name))
          Call PutVar(FileName, "PVP Kill Leaderboard", Trim(Player(Index).Char(CharNum).Name), PKTotal + PKLAmount)
      End If

::Client Sided::

- Packet Information

Code:
Sub PKLPacket(ByVal First As Integer, second As Integer, third As Integer)
Dim Packet As String

    Packet = CPNPKLLeader & SEP_CHAR & First & SEP_CHAR & second & SEP_CHAR & third & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub

This is basically all I have currently. If you can give me some segments of code or an idea on how to delete the line for the "DelChar" sub, that would be a good start for me. I also need help with displaying the information onto the frmMirage once I get the packet sending the information back and fourth.

Pleas and thank you!
Reply
#2
Actually, you can use binary.

DelChar actually just sets everything to 0 and saves it, so have a look around.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
Well yes, but to the player, you are deleting your char and cannot use it anymore (its name disappears from the list so to speak), And when that happens to them, then I want it to disappear from the .ini file for the leaderboard. The best I can see currently is setting it to zero, then perhaps I could add some more code in the client so that when the packet comes back, if the name is equal to 0 then it just dose not display.... That might actually work now that I think about it...
Reply
#4
you could also load in the entire PKlist removing any player names that = 0
I would recommend not adding the player to the list until they have their first kill
Reply
#5
Thats a possibility, and would incorperate a sort of, "This is the highest killer ever..." kind of thing.. Not sure were I would place this though.
Reply
#6
So you suggest placing it on the Server? That wouldn't be much more trouble... Every couple mins it sends a packet to update the leaderboard...
Reply
#7
Why not update the leaderboard when the player accesses it?
Reply
#8
Just export it to the website at a timed interval, the more kills and players there are, the more strain it's going to cause to create the list.
Reply
#9
Don't export anything on a timer.

Just export it when it's changed.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#10
But if people are PKing often, wont that rape with lag?
Especially with INI files.
Reply
#11
Robin Wrote:use binary.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#12
Rezeyu Wrote:But if people are PKing often, wont that rape with lag?
Especially with INI files.

Combination of both, then.

Code:
If StatusChanged Then
   If EnoughTimeElapsed Then...

Not like you'd need to update more than every hour or so, though.
Reply
#13
Why not use a separate program to do what Rez said? Make the list, export it to a website, to be included in an html or php page..?

Just have it read directly from the account files and what not.

Wouldn't cause any lag, would it?
Reply
#14
Dave Wrote:No, probably not.

The problem comes-
What happens when the server is writing a file and the list exporter is reading one? Something has to fail Tongue You would have to add extra error checking in the server, or make the exporter send a message to the server that says, "wait, i'm reading these quick"

There are ways around that.
Reply
#15
What I am going to do, every time there is a change to the .ini file, then it will send that value to the clients. I have absoultly no idea how to do this. Any ideas people?
Reply
#16
Apart from my way of comparing levels is not yet completed (more or less, what I thought would work dose not), I have just one more task because I can set up the packet. I am not sure how to get all of the information on the text file stored in an array... Like, I can get an individual one, with a specific name in mind, but not all of them into an array at once. Any ideas?
Reply
#17
Its late at night and my mind is just not functioning... If that is it, wonderful, I'll try it... If not, this is basically what I need...

Array(0) = FirstCharNameValue (Which will be like, Sh4d0ws = 0)
Array(1) = SecondCharName (etc...)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)