shadowrecon Posted January 10, 2012 Share Posted January 10, 2012 (edited) So after some time thinking on how this could be done i went into github looking around, noticed how the functions were calling/setting themselfs up and came up with this solution, i did some testing and everything works great checked memory to make sure smart wasnt dueplicating its self and leaving residue and as far as i can tell its 100% a working solution, this is only a reload smart function so you will need to also add a dection system for detecting the 'RS had been' Updated but that shouldnt be to hard, or put your main loop on a timer and call this function after 5 hours or so.. well take a look and tell me what you think.. {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ReloadSMART: Boolean; Contributors: ShadowRecon. Description: Shutsdown SMART, and then reopens it, returns true if player logged in, false if not. Date Created: 1/10/2012 By ShadowRecon. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} Function ReloadSMART:boolean; Begin Writeln('Reloading Smart'); wait(1000); SmartSetupEx(10,True); writeln('SMART has been Reloaded'); Writeln('Waiting on login screen'); SmartSetTarget; // Makes Sure the new SMART window is declared as active repeat // waits until login screen is dectected begin Wait(1000); end; until (LoginScreen = True); if not(LoginScreen = true) then exit; if (not (LoggedIn)) then begin if (Login = true) then begin result := True; WaitRR(500, 750); end; end; if (not (LoggedIn)) then begin Writeln('No Players Active..'); TerminateScript; // this can be edited out... result := False; Exit; end; end; Edited January 10, 2012 by shadowrecon Quote Link to comment Share on other sites More sharing options...
rsutton Posted January 10, 2012 Share Posted January 10, 2012 (edited) Love how everyone said this couldnt be done ....... It was in the smart client functions. Brought to you by UB team Edited January 10, 2012 by rsutton Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 10, 2012 Share Posted January 10, 2012 Sweet. Was just about to tackle this next. Knew it could be done. Quote Link to comment Share on other sites More sharing options...
FHannes Posted January 10, 2012 Share Posted January 10, 2012 I don't see what you did there... Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 10, 2012 Share Posted January 10, 2012 The example posted may not work. If you call smart setup with a different world number smart will reload. Does this free the previous smart? dunno. And to check if you need to (not tested but should do ya): if (not LoggedIn) and (Players[CurrentPlayer].Loc = 'RS updated') then begin Players[CurrentPlayer].Active := True; ReloadSmart; Login; end; Quote Link to comment Share on other sites More sharing options...
FHannes Posted January 10, 2012 Share Posted January 10, 2012 shadow, on a sidenote, did you check the memory of the running java instance or that of scar? Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 10, 2012 Author Share Posted January 10, 2012 (edited) Setting the players back to active is a good point, i have been running my scripts on timers and just calling the reloadsmart at a 5 hour interval. I did notice that after called 6 or 7 times it does kinda lag up scar and smart, found this out in initial testing when i was restarting smart over and over in a row, but if you do it once and watch memory its not crazy, my bots run around 400k ram constantly and im at about 450k which could be because of reload or ect. but 50mb isnt nothing out of 8g so why worry but i guess for people with old computers this could be an issue. I figure if i get 10-12 hours of botting and i have to restart scar after that oh well, the best fix would to have a command within the smart JVM instance instead of using scar to manipulate it. But for now i think this is a viable solution that could be easily implemented into any script. Edited January 10, 2012 by shadowrecon Quote Link to comment Share on other sites More sharing options...
mormonman Posted January 10, 2012 Share Posted January 10, 2012 If you look at this commit, there is a HardReset. Benland said that Windows doesn't free the Smart memory. It does work with Linux tho. https://github.com/BenLand100/SMART/commit/9b059361e4e28a295e910757e72702730fc01ce6 Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 10, 2012 Author Share Posted January 10, 2012 Yeah i was looking at that in the source, how do u go about accessing the hardreset function, i tried calling it within the script when i first started this process.. with no luck does i need to be within the include or a onevent or what? lol Quote Link to comment Share on other sites More sharing options...
rsutton Posted January 10, 2012 Share Posted January 10, 2012 Dont cody. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 12, 2012 Author Share Posted January 12, 2012 I dont know if anyone else has been trying this function or not, but ive had pretty good results, if the script runs over about 20 hours there is a major spike in memory usage, but it keeps running with out crashing, so aslong as your computer can take the beatin it seems to be a fix for now. heres how i have set up in my script: All im doing id putting the reloadsmart function on a timer and when the script run time = 5 hours it reloads. while keeping up with previous hours so when it reloads it just doesnt reload again as there is no way to reset script timer? asfar as i know. {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ReloadSMART: Boolean; Contributors: ShadowRecon. Description: Shutsdown SMART, and then reopens it, returns true if player logged in, false if not. Date Created: 1/10/2012 By ShadowRecon. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} Function ReloadSMART:boolean; Begin Writeln('Reloading Smart'); wait(1000); SmartSetupEx(10,True); writeln('SMART has been Reloaded'); Writeln('Waiting on login screen'); SmartSetTarget; // Makes Sure the new SMART window is declared as active repeat // waits until login screen is dectected begin Wait(1000); end; until (LoginScreen = True); if not(LoginScreen = true) then exit; if (not (LoggedIn)) then begin if (Login = true) then begin result := True; WaitRR(500, 750); end; end; if (not (LoggedIn)) then begin Writeln('No Players Active..'); TerminateScript; // this can be edited out... result := False; Exit; end; end; Procedure CheckTimeRunning; var H,M,S,PreviousH: integer; begin ConvertTime(GetTimeRunning,H,M,S); if ( (H - PreviousH) > 5) then begin PreviousH := H; if ReloadSMART = true then exit; end else exit; end; Quote Link to comment Share on other sites More sharing options...
rsutton Posted January 12, 2012 Share Posted January 12, 2012 theres a much better way ill give you code on skype to replace. Calling stuff here that isnt needed Quote Link to comment Share on other sites More sharing options...
FHannes Posted January 12, 2012 Share Posted January 12, 2012 theres a much better way ill give you code on skype to replace. Calling stuff here that isnt needed Isn't it more convenient to just post it here? Quote Link to comment Share on other sites More sharing options...
rsutton Posted January 12, 2012 Share Posted January 12, 2012 Freddy, your right. I have been kinda selfish with codes lately. Just the whole UnitedBots coming up and everything I just wanted a bit of a headstart before releasing the codes I use if you get what I mean? I really will be helping build this community with free bots and help as soon as possible. Trying to still help as much as possible. But I think I see what your saying.. if im not gonna give the code out yet then why the hell should I publicly even announce it... ego? Ya I understand but it has nothign to do with ego bro. Ill be giving out codes and new functions here soon bro. Still field testing too and getting some bots ready for public release. Quote Link to comment Share on other sites More sharing options...
FHannes Posted January 12, 2012 Share Posted January 12, 2012 [video=youtube;4JUeDQbR-ts]http://www.youtube.com/watch?v=4JUeDQbR-ts Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 12, 2012 Share Posted January 12, 2012 and on that note...sometimes we make it more complicated than it needs to be: SMART_Server := RandomWorld(Players[CurrentPlayer].Member); InitiateSMART; Login; Still not a fix. You will run out of memory after a few restarts. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 13, 2012 Author Share Posted January 13, 2012 (edited) yeah its not a permanent fix, but like i said it runs for 15-20 hours np by that time tho my guys are stuck in randoms or lookin goofy. my other solution was to call a reload of the script by using getfile() and replacing the current script with a new one and having it reload scar and start over, but there would be no way to track how many time this has been done nor which players were inactive.. ect. fail-safes are always nice =p i build all of my functions with atleast 2 sometimes alot more.. i think redundancy is the most important part to your script being successful. an extra 400 lines in failsafes is not going to effect your performance with the script but only make it more likely to succeed =) Edited January 13, 2012 by shadowrecon Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 13, 2012 Share Posted January 13, 2012 yeah its not a permanent fix, but like i said it runs for 15-20 hours np by that time tho my guys are stuck in randoms or lookin goofy. my other solution was to call a reload of the script by using getfile() and replacing the current script with a new one and having it reload scar and start over, but there would be no way to track how many time this has been done nor which players were inactive.. ect.What an awesome idea. Dump any relevant info out to a status file, reload SCAR, read in file and set things "back" and presto magic you could go forever. Okay it's a bit more complicated than that, but not by much. fail-safes are always nice =p i build all of my functions with atleast 2 sometimes alot more.. i think redundancy is the most important part to your script being successful. an extra 400 lines in failsafes is not going to effect your performance with the script but only make it more likely to succeed =)I couldn't agree with you more. I put an insane amount of checking in my scripts. Drives Wanted nuts reading my scripts: thinks it's overkill. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 13, 2012 Author Share Posted January 13, 2012 What an awesome idea. Dump any relevant info out to a status file, reload SCAR, read in file and set things "back" and presto magic you could go forever. Okay it's a bit more complicated than that, but not by much. I couldn't agree with you more. I put an insane amount of checking in my scripts. Drives Wanted nuts reading my scripts: thinks it's overkill. yeah i was talking to freddy about reading files off the internet and he said u could save what you read to the script your using and it would cause scar to reload, so i was like hmm... lol. if else if else if.. < i love if loops i wish i could get away from all of the 'over kill' with using those things but im always like well 'if' that happens then i would need to do this.. loll. so a simple script ends up being over 600+ lines, but ill tell you what they always work! =) lol. My wc bot posted in the script forms is done alot like that, but it works flawlessly, ive since updated it alot but the core is pretty much the same neither the less they both work and the colors havent been updated in ages! Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 13, 2012 Share Posted January 13, 2012 You would have to do more than simply reload the script. I recall BenLand saying because SMART runs in the same process thread (to allow communication between SCAR and SMART) the memory from SMART does not get freed entirely until you exit SCAR completely. He was talking about SIMBA but I believe the same applies to SCAR? Which means you would need a "controller" of some sort to close/restart SCAR when prompted to, which means inter-process communication of some sort. Maybe something as simple as a 2nd scar that clicks the close button on the first SCAR then re-clicks on the SCAR icon, etc, etc. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 13, 2012 Author Share Posted January 13, 2012 You would have to do more than simply reload the script. I recall BenLand saying because SMART runs in the same process thread (to allow communication between SCAR and SMART) the memory from SMART does not get freed entirely until you exit SCAR completely. He was talking about SIMBA but I believe the same applies to SCAR? Which means you would need a "controller" of some sort to close/restart SCAR when prompted to, which means inter-process communication of some sort. Maybe something as simple as a 2nd scar that clicks the close button on the first SCAR then re-clicks on the SCAR icon, etc, etc. oh wow, yeah why not just make it log-out your guy, close smart, then open new scar and have default script set to the one your using and hit play, then in the start of script have it check for another scar and if found then close it before loading osi... real pain in the butt but would work i think? Quote Link to comment Share on other sites More sharing options...
rsutton Posted January 13, 2012 Share Posted January 13, 2012 (edited) Shadow I told you about that last week, dont sound surprised lol. I think it comes still with an issue that it would be hard to make it universal, screen size, computer size, where is the application. Freddy said there is a shell plugin we could use. but then you have to make sure everyone is using it. Security risks that way. So there is 3 ways to go about this. The easiest is the hardest to make universal. The hardest is the easiest to have people not trust your scripts. Now the original method is still the best which was posted. so until a fix comes through smart itself or freddy implements a reload then so be it, Since freddy wont put in a (reload scar) function. ( do it do it ) Edited January 13, 2012 by rsutton Quote Link to comment Share on other sites More sharing options...