PDA

View Full Version : [LogOut] How to make your character log out!



dinmamma
06-11-2013, 01:55 PM
So I will get into business straight away!

BE AWARE, THIS ONLY WORKS WITH 1 ACTIVE CLIENT THAT IS INFRONT OF EVERYTHING ON YOUR SCREEN
Since this works as a simple macro :)

Primary Goal:
Be able to logout your character depending on few conditions.

Way to do it:
Using AutoIt and .Lua that will communicate through .XML.

Description:
Firstly you would need AutoIt (google), you will need it to compile your .exe file (I will not link to any .exe's here). You could run all AutoIt scripts through their own program but if you run Tibia as admin it is just simplier with an .exe which you run as admin aswell.

Wtf what is AutoIt?
It is a quite great program that can serve as an advanced macro, sending keystrokes(ctrl+q in this case) depending on whatever you want.
In this case it will check for PZ sign, battle sign and for a value inside a .XML document.

So what does .LUA in this case?
It will edit the value in that .XML document, which will later be checked by AutoIt and see whether you want to logout or not, you will be able to change that value through your .LUA scripts.

Short case example:
I want to logout when my stamina reaches 40 hours, I simply add a checkpoint in my script/walker where it checks for my stamina, if stamina < 40 then the char will walk inside a PZ zone (not necessary, but good) where AutoIt will check for PZ icon in your conditions and check if the value inside .XML is 1, whereafter it will logout.

What do I have to do for it to work?
After you have downloaded AutoIt you will need some files that I designed to work as this alternative logout function.
They are .au3 sources and I will later show you how to compile, it is like 1 click away when you are done configuring the settings etc, aswell as small .LUA library with 2 functions (Credits to Darkhaos for releasing these functions that will read and edit .XML files)

So now you will need the files:
_XMLDomWrapper.au3 (holds functions to read/edit .XML)
ImageSearch.au3 (holds functions to search for an image on your screen by comparing pixels(?))
ImageSearchDLL.dll (library that ImageSearch.au3 uses)
LogoutStorage.lua (holds the functions that will read and edit the value inside .XML)
logout.xml (just premade so you won't have to worry about it)
logout.au3 (the file you can edit to fit your needs, the file we will be making into an .exe later)
!2 images that you must create yourself:
battle.bmp
pz.bmp
Simply take a screenshot while having 1 of those in your conditions and cut them out in paint, you don't need them to be perfect, rather have them a bit incomplete than having too much on the image! I will include the ones I used, but I think depending on the screen resolution they might not work for everyone, which is why you must make your own. SAVE AS .BMP!

http://speedy.sh/rtMWz/Logout.rar

So now that you have all the files, create a new folder inside C:/Users/-username-/Documents/XenoBot, it will be called "Storages". Put all files in this folder EXCEPT for LogoutStorage.lua, the .LUA must be inside your Scripts folder.

Now that everything is in place, you may wan't to change the paths for the .XML in logout.au3 and LogoutStorage.lua(just change the username so the path is complete).

How to compile:
Simply open it in AutoIt editor and check this image:
http://i.imgur.com/Mmq4L54.png?1

So now I can show you how to change that .XML value with a .LUA script, so it actually will logout when you want:

local logOut = "yes" -- Simple setting that may be changed
dofile("LogoutStorage.lua") -- MUST BE INSIDE EVERY SCRIPT WHERE YOU WANT THIS TO WORK
while true do
if (logOut == "yes" and Self.Stamina() < 2400) then -- if you declared you want to log out and if your stamina is lower than 40h then you want to logout
doSetStorage("1")
wait(1000)
end
end

I made it to check for pz before logging, here is the line:
http://i.imgur.com/u8EnpmC.png?1
To NOT check for pz (only check if no battle = logout), it must look like this:
http://i.imgur.com/7GcqCZu.png?1
I just removed
And $result2=1

Don't forget to run the .exe as administrator if you run Tibia the same way and that your Tibia window must be active on your screen to make it work :)

Enjoy and feel free to report/ask questions etc!

P.S.
I'm not a coder so this shit looks like shit and could probably be done easier and better, but it works :D

dinmamma
06-11-2013, 01:55 PM
~reserved maybe~