Modification: automatic logout after x min playtime

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Modification: automatic logout after x min playtime

#1 Post by d003232 » Mon Jun 22, 2009 12:01 pm

Here a modification for automatic logout after x minutes botting.

Insert in bot.lua line 27 after '__RPL = nil; -- Return Point List'

Code: Select all

__RPL = nil; -- Return Point List

hf_bot_start = os.time();	--  start time of the bot
and at the end in bot.lua after line 306

Code: Select all

		end
		
		player:logout_check();	-- automatic logout check   <<< INSTERT THAT LINE
	end
	
end
startMacro(main);
Define your logout-key: Insert in settings.xml after line 10 and change the key="VK_C" to your logout key:

Code: Select all

		<hotkey description="LOGOUT" key="VK_C" modifier="" />
Create a ingame macro 'logout' with following code:

Code: Select all

/script Logout();
.

Assign that macro to your before defined logout key.

Insert the new function 'function CPlayer:logout_check(hf_logout)' in player.lua:

Code: Select all

-- function for automatic logout checking
-- you can also use it with logout_check(true) for logout whitout timer
function CPlayer:logout_check(hf_logout)

	if( settings.profile.options.LOGOUT_TIME == nil ) then settings.profile.options.LOGOUT_TIME = 0; end;
	if( settings.profile.options.LOGOUT_SHUTDOWN == nil ) then settings.profile.options.LOGOUT_SHUTDOWN = false; end;	

	if( self.Battling == true  or		-		-- no logout if aggro
	    settings.profile.options.LOGOUT_TIME == 0  ) then	-- no logout if timer = 0
		return;						-- go back
	end;
	
	if( (os.difftime(os.time(), hf_bot_start)/60) > settings.profile.options.LOGOUT_TIME ) then
		hf_logout = true;
	end;

	if( hf_logout == true ) then
		printf("automatic logout after %s min playtime\n", (os.difftime(os.time(), hf_bot_start)/60) );
		keyboardPress(settings.hotkeys.LOGOUT.key);
		yrest(12000);
		if( settings.profile.options.LOGOUT_SHUTDOWN == true ) then 
			printf("automatic shutdown in 30 sec\n" );
			os.execute("\"%windir%\\system32\\shutdown.exe -s -t 30\" ");	-- shutdown after 30 sec
		end;	
		stopPE();
	end;
end
And last, define two new options in your profile file ?charname?.xml

Code: Select all

	<option name="LOGOUT_TIME" value="120" />	
	<option name="LOGOUT_SHUTDOWN" value="true" />	
In 'LOGOUT_TIME' you can set the time in minutes until automatic logout. Setting '0' means no automatic logout. And with 'LOGOUT_SHUTDOWN' you can define if you want to shutdown your system after logout (true or false).

EDIT: add an option for shutdown.
Last edited by d003232 on Mon Jun 22, 2009 4:57 pm, edited 1 time in total.
The RoM Bot Online Wiki needs your help!

kumpel100
Posts: 47
Joined: Sat May 09, 2009 11:12 am

Re: Modification: automatic logout after x min playtime

#2 Post by kumpel100 » Mon Jun 22, 2009 1:24 pm

that looks very great i will test it i used same in my Bot in a other Game with the special Feature " Shut down your machine after xx hours" that is an important Part !!!
something like:

Code: Select all

   
<option name="LOGOUT_TIME" value="120" />  
<option name="SHUT_DOWN_PC" value="true" />  
<option name="SHUT_DOWN_PC_ON_DEATH" value="true" />

this will save alot of Money in Germany the Power is Expensive :)

in my Bot the Function was looking like:

Code: Select all

if (Shutdownxx = true)
{
sleep 3000
;Logoff  	0
;Shutdown 	1
;Reboot 	2
;Force 	4
;Power down 	8
; Force a Power down (Power down + force + Shutdown = 8 + 4 + 1 = 13)
Shutdown, 13  ;13
;Works for XP, Vista
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
sleep 5000
pause
}
if (Shutdownxx = false)
{
Gosub save
sleep 1000
pause  ; pause while Death !!!!
}
}
}
}
Return

kumpel100
Posts: 47
Joined: Sat May 09, 2009 11:12 am

Re: Modification: automatic logout after x min playtime

#3 Post by kumpel100 » Mon Jun 22, 2009 3:34 pm

should we insert indeet of that:
end

player:logout_check(); -- automatic logout check <<< INSTERT THAT LINE
end

end
startMacro(main);

better this:

Code: Select all

end
if( settings.profile.options.USE_LOGOUT == true ) then     
                player:logout_check();   -- automatic logout check   <<< INSTERT THAT LINE                                          
                end 
  end 
end
startMacro(main);[/quote]
and in Profil:

<option name="LOGOUT_TIME" value="120" />
<option name="USE_LOGOUT" value="false" />


so we can set a true or a false.

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: Modification: automatic logout after x min playtime

#4 Post by d003232 » Mon Jun 22, 2009 3:43 pm

kumpel100 wrote: <option name="LOGOUT_TIME" value="120" />
<option name="USE_LOGOUT" value="false" />


so we can set a true or a false.
You can allready set:

Code: Select all

<option name="LOGOUT_TIME" value="0" />
if you dont want to use automatic logout.
The RoM Bot Online Wiki needs your help!

kumpel100
Posts: 47
Joined: Sat May 09, 2009 11:12 am

Re: Modification: automatic logout after x min playtime

#5 Post by kumpel100 » Mon Jun 22, 2009 4:06 pm

AHHHH ok :)

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Modification: automatic logout after x min playtime

#6 Post by 3cmSailorfuku » Mon Jun 22, 2009 4:21 pm

How about using the winmessage shutdown to close a window instead of making a macro? :)

Anyway, Elverion posted similiar code already once but instead of making fancy XML settings, it would be fit into onleavecombat.
In my opinion that makes the code more simple, I have a great sense of Original Code <-> Modifications.

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: Modification: automatic logout after x min playtime

#7 Post by d003232 » Mon Jun 22, 2009 5:05 pm

kumpel100 wrote:... with the special Feature " Shut down your machine after xx hours" that is an important Part !!!
I added one more option for shuting down the machine after logout. See the starting post.
3cmSailorfuku wrote:How about using the winmessage shutdown to close a window instead of making a macro? :)
Not really sure what you mean? I hope to save all RoM settings by using the macro ingame.
3cmSailorfuku wrote:it would be fit into onleavecombat.
In my opinion that makes the code more simple, I have a great sense of Original Code <-> Modifications.
My onleavecombat would be to big! :-) And I had some strange behaivor with, I think, the xml parser. So I dont really like it for 'bigger' things. And you are right. I allway say to my customers 'pls pls , don't modify the system ... use the standard' :-). But thats so boring ! :lol:
The RoM Bot Online Wiki needs your help!

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Modification: automatic logout after x min playtime

#8 Post by Administrator » Mon Jun 22, 2009 9:54 pm

I am about to commit this (and other changes by d003232) to SVN. The code I used is highly based on what was posted here, but was modified for simplicity, cleanliness, and includes some extra features.

Those features are (and it's not anything too fancy, so relax):
  • Options are set by default to false (do not use)
    Use either logout-macro or forcefully close client if logout-macro isn't set
    Reports (language specific) what is happening
    Exits the script entirely rather than just pausing the protected environment
    Timer is updated in the event that you pause/resume the bot
[50] = "Automatisch Ausloggen.\n",
[51] = "Herunterfahren des Systems.\n"
Can somebody verify if these are correct? I'm quite certain 50 is fine (maybe the A needs an umlaut?), the second one I'm unsure of.


I've also rennamed the hotkey "LOGOUT" to "LOGOUT_MACRO". Again, it works fine if this is not set; it will just close the client for you.

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Modification: automatic logout after x min playtime

#9 Post by 3cmSailorfuku » Tue Jun 23, 2009 7:11 am

Administrator wrote:I am about to commit this (and other changes by d003232) to SVN. The code I used is highly based on what was posted here, but was modified for simplicity, cleanliness, and includes some extra features.

Those features are (and it's not anything too fancy, so relax):
  • Options are set by default to false (do not use)
    Use either logout-macro or forcefully close client if logout-macro isn't set
    Reports (language specific) what is happening
    Exits the script entirely rather than just pausing the protected environment
    Timer is updated in the event that you pause/resume the bot
[50] = "Automatisch Ausloggen.\n",
[51] = "Herunterfahren des Systems.\n"
Can somebody verify if these are correct? I'm quite certain 50 is fine (maybe the A needs an umlaut?), the second one I'm unsure of.


I've also rennamed the hotkey "LOGOUT" to "LOGOUT_MACRO". Again, it works fine if this is not set; it will just close the client for you.
Automatisches Ausloggen

Rest is fine.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests