Mirage Source
http://miragesource.net/forums/

Working with .INI files....
http://miragesource.net/forums/viewtopic.php?f=201&t=2881
Page 1 of 11

Author:  Sh4d0ws [ Mon Oct 15, 2007 3:06 pm ]
Post subject:  Working with .INI files....

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!

Author:  Robin [ Mon Oct 15, 2007 3:11 pm ]
Post subject:  Re: Working with .INI files....

Actually, you can use binary.

DelChar actually just sets everything to 0 and saves it, so have a look around.

Author:  Sh4d0ws [ Mon Oct 15, 2007 3:15 pm ]
Post subject:  Re: Working with .INI files....

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...

Author:  Dr. Spoon [ Mon Oct 15, 2007 7:16 pm ]
Post subject:  Re: Working with .INI files....

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

Author:  Sh4d0ws [ Mon Oct 15, 2007 10:39 pm ]
Post subject:  Re: Working with .INI files....

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.

Author:  Lea [ Tue Oct 16, 2007 12:27 am ]
Post subject:  Re: Working with .INI files....

I recommend not basing a request on the client side with a timer.

What happens if I set that timer interval to, say, 1ms? Your server gets bogged down.

Author:  Sh4d0ws [ Tue Oct 16, 2007 3:40 pm ]
Post subject:  Re: Working with .INI files....

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...

Author:  Matt [ Tue Oct 16, 2007 3:52 pm ]
Post subject:  Re: Working with .INI files....

Why not update the leaderboard when the player accesses it?

Author:  Rezeyu [ Tue Oct 16, 2007 9:48 pm ]
Post subject:  Re: Working with .INI files....

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.

Author:  Robin [ Tue Oct 16, 2007 9:48 pm ]
Post subject:  Re: Working with .INI files....

Don't export anything on a timer.

Just export it when it's changed.

Author:  Rezeyu [ Tue Oct 16, 2007 9:51 pm ]
Post subject:  Re: Working with .INI files....

But if people are PKing often, wont that rape with lag?
Especially with INI files.

Author:  Robin [ Tue Oct 16, 2007 9:57 pm ]
Post subject:  Re: Working with .INI files....

Robin wrote:
use binary.

Author:  Spodi [ Tue Oct 16, 2007 10:23 pm ]
Post subject:  Re: Working with .INI files....

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.

Author:  Lea [ Tue Oct 16, 2007 10:24 pm ]
Post subject:  Re: Working with .INI files....

Yeah, I would just update every hour, or every day, or whatever. It doesn't need to be to-the-minute.

Author:  Matt [ Tue Oct 16, 2007 10:25 pm ]
Post subject:  Re: Working with .INI files....

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?

Author:  Lea [ Tue Oct 16, 2007 10:47 pm ]
Post subject:  Re: Working with .INI files....

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 :P 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"

Author:  Matt [ Tue Oct 16, 2007 11:13 pm ]
Post subject:  Re: Working with .INI files....

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 :P 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.

Author:  Sh4d0ws [ Wed Oct 17, 2007 7:20 pm ]
Post subject:  Re: Working with .INI files....

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?

Author:  Lea [ Wed Oct 17, 2007 11:02 pm ]
Post subject:  Re: Working with .INI files....

Packet = "packetname" & SEP_CHAR & data1 & SEP_CHAR & ... & SEP_CHAR & END_CHAR

Author:  Sh4d0ws [ Thu Oct 18, 2007 12:36 am ]
Post subject:  Re: Working with .INI files....

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?

Author:  Lea [ Thu Oct 18, 2007 12:46 am ]
Post subject:  Re: Working with .INI files....

Dim Array(0 to len) as long
Dim t as long
Dim i as long

For i = 0 to len
t = GetVar(yourCatagory, i)
Array(i) = t
Next i


Something like that?

Author:  Sh4d0ws [ Fri Oct 19, 2007 1:49 am ]
Post subject:  Re: Working with .INI files....

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...)

Author:  Lea [ Fri Oct 19, 2007 5:25 am ]
Post subject:  Re: Working with .INI files....

In order to do it in a loop, you would need each name assigned a number.

Author:  wanai [ Wed Dec 08, 2021 4:52 am ]
Post subject:  Re: Working with .INI files....

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтsemiasphalticfluxсайтсайтсайт
сайтсайтсайтсайтсайтсайтhttp://taskreasoning.ruсайтсайтсайтинфосайтсайтtuchkasсайтсайт

Author:  wanai [ Tue Feb 08, 2022 5:36 pm ]
Post subject:  Re: Working with .INI files....

hila135.9PERFPERFMarvEricCreaHeinXVIIBurtMornRickKeviLoveJohnXVIIOrieSpecmailRobeFranJackVenu
ReneAlanAretremiDaleBIOSRevelaisEmmaXVIIDomaReadLiliKarlXVIIMartHoneStewPatrOpusCherCoheCred
DailWillXXIXRexaVasiNintWestJameFallAlmoEnjoELEGGesiMcDoBlacJuliBatiFeliMichKarlLaVyEricHenn
TereMichModoKoffFallMatiCircVictWoolDeLiFredRobeNikiCoteZoneParaDistKinoDaisXVIICuddWALLAway
ZoneEGSiEkelKirkZoneZoneLawySusaZoneBranZoneZoneZoneZoneMORGCarnSummZoneWPATZoneElecZoneZone
ZoneChriLippminiDAXXWillZanuVestBakuCrisDONKBookMorgWWQiChicGiglMistWoodRefeFORDWinddomaJazz
GellleftVicthearAliaAlbeAutoWindJohnKaspClasSmilMoonPremEukaDolpWindWindEricBreaSoulBETEMarg
XVIIXVIIHeriBriaAcadGrunHermAcadStifCharBrutMikhMikhVareLeszestaDaniFredPhilAlexPansNormWind
NineTimeVickHubeKaneSynaJackNekoSeymLibeDioxcoloTotaTodaApplAnniSomeJameStepAlleLighminimini
miniNazaTchaBridliveAndrEstoFeatWillNeleEnglCambAlthtuchkasWindwwwr

Page 1 of 11 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/