mIRC Home    About    Download    Register    News    Help

Print Thread
#242910 20/09/13 04:47 AM
Joined: Sep 2013
Posts: 3
V
VII Offline OP
Self-satisified door
OP Offline
Self-satisified door
V
Joined: Sep 2013
Posts: 3
Hey guys. First time poster.

So the problem I'm having is mostly because I don't know if I can use a variable or identifier with a .ini file. The reason why I'm wanting this is because I plan to make an IRC role playing game that will let people register their character to a GameBot, keep track of their stats and allow them to update them as necessary.

I've read the help file several times, and I can't find if I can have the user input those figures. The .ini file would have to be something that can be recreated or multiplied an unknown amount of times. Or, more, if 30 register a character, it'll have 30 separate .ini files for each character and their stats.

Any help is appreciated

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
An ini file has the following format:
Code:
[section]
item=data
item1=data1

[section1]
item=data
item1=data1

[etc]
It can support multiple sections.
But it still all depend on how you want to store the informations, creating a lot of ini files might be undesirable. If you are saying one user can create more than one character 'per account', you might want to create one ini file that will list basics informations about accounts, like if they are logged or not, and the different characters they have, then, you'd have one more ini file per account, listing all the characters and theirs stats per account, avoiding one ini file per character per account. I still don't know what you mean but if only one character can be created per account, you only need one ini file really.

Example for multiple characters per account:

Code:
accounts.ini would be like:

[Ouims]
logged=$true
otherinformation=some informations
characters_list=monster1 monster2 monster3

[VII]
logged=$false
otherinformation=some informations
characters_list=monster74 wizard42

then you'd have a file Ouims_characters.ini:

[monster1]
attack=12
life=30
defense=5
othersstats=20

[monster2]
attack=15
etc...

and a file VII.ini with the same kind of things.


Quote:
if I can use a variable or identifier with a .ini file.
Again i'm not sure about what you mean but the following is correct:
Code:
on *:notice:!login & &:?:{
  if ($ini(accounts.ini,$2)) && ($readini(accounts.ini,n,$2,password) == $md5($3-)) {
     writeini accounts.ini $2 logged $true
     notice $nick you are now logged
  }
}
Where that code would handle the login part to your game.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Sep 2013
Posts: 3
V
VII Offline OP
Self-satisified door
OP Offline
Self-satisified door
V
Joined: Sep 2013
Posts: 3
Wims, thank you for replying. Let me try and break down what I'm trying to accomplish.

Code:
 on 1:TEXT:!new char *:?: { 
  writeini -n accounts.ini $3- |
  writeini -n accounts.ini $3- Created $fulldate | 
  .msg $nick You've now created your character's file. Next, you will decide your stats. You have a Power Level, or PL, of 5,000 to start, and 2,500 points to distribute between the following stats: |
  .msg $nick Str - Spd - Sta - Vit | 
  .msg $nick You do this by typing in the following command: !add stat <followed by either Str, Spd, Sta or Vit> | 
  
}


From above, a new user would be able to create a single character for now. I used some of your example to help, so hopefully it does. When they create it, the code should create that information, along with the stats when I get there, and hold onto it.

I think where I'm getting confused is when to use spaces and when not, or how $ini(), $readini() and /writeini can work together to allow a user to update and increase their stats, and save over the original information. But also, do I create ini files in the directory myself first, or does mIRC do it for me?

Again, thank you for pointing me in the right direction.

Last edited by VII; 20/09/13 02:31 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Pipes are used to separate commands on a single line, you don't need them at the end of every line.

Joined: Sep 2013
Posts: 3
V
VII Offline OP
Self-satisified door
OP Offline
Self-satisified door
V
Joined: Sep 2013
Posts: 3
Thanks for the info, Loki.


Link Copied to Clipboard