Jump to content

IniRead help please.


Recommended Posts

What am I doing wrong?

$Server = Iniread( "AL.ini", "Server", "", "" )
if $Server = Iniread( "AL.ini", "Server", "1", "" ) Then
    Sleep(1500)
    MouseClick("left", 512, 155, 1, 2) 
ElseIf 
    $Server = Iniread( "AL.ini", "Server", "2", "" ) Then
    Sleep(1500)
    MouseClick("left", 512, 700, 1, 2)
EndIf

It only reads number 1 I really don't know why.

Link to comment
Share on other sites

$Server = Iniread( "AL.ini", "Server", "", "" )
if $Server = Iniread( "AL.ini", "Server", "1", "" ) Then
    Sleep(1500)
    MouseClick("left", 512, 155, 1, 2) 
Else
    $Server = Iniread( "AL.ini", "Server", "2", "" )
    Sleep(1500)
    MouseClick("left", 512, 700, 1, 2)
EndIf

You mean like that? Cause with that it still selects number 1.

Link to comment
Share on other sites

I believe you have the syntax wrong. You are looking for the value of what is supposed to be 1 or 2. So if I understand what you are doing, you are looking for, let's say "Dog", and if "Dog" is 1 do this, and if "Dog" is 2 do that, so you need to do this.

$Server = Iniread( "AL.ini", "Server", "Dog", "" )
  Sleep(1500)
if $Server = 1 Then
    MouseClick("left", 512, 155, 1, 2) 
Else
    MouseClick("left", 512, 700, 1, 2)
EndIf
Edited by Champak
Link to comment
Share on other sites

That code does work for me but the problem is there are 6 servers not 2 so how can I make a different between that?

EDIT: I just saw your edit ill just go try that.

EDIT: That second code doesn't select any of them.

Edited by Resurrection
Link to comment
Share on other sites

That's what the second example is for. So you'd do:

$Server = Iniread( "AL.ini", "Server", "Dog", "" )
  Sleep(1500)
if $Server = 1 Then
    MouseClick("left", 512, 155, 1, 2) 
ElseIf $Server = 2 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 3 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 4 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 5 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 6 Then
    MouseClick("left", 512, 700, 1, 2)
EndIf

If it is just two options you would use "Else" like the first one, if you have multiple options like you do you would use "ElseIf" like the second one and this.

Edited by Champak
Link to comment
Share on other sites

[server]

Username=

Password=

Dog=2

Or in your case

You would look for it like

$Server = Iniread( "AL.ini", "Whatever Name", "Server", "" )

and your ini would look like

[Whatever Name]

Username=

Password=

Server=2

Edited by Champak
Link to comment
Share on other sites

That code also doesn't work, I think the error is my ini here it is:

Username=

Password=

Server=2

That's not correct INI syntax. It should be:

[Info]
Server=something
Password=something
Username=something

However, your ini doesn't have any sections. If you use this sample INI, you could use

$Server = IniRead("C:\Config.ini", "Info", "Server", "")

to get the server value.

EDIT: Heh, Champak beat me to it. Nothing to see here. Move along. >_>

Edited by phaze424
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...