ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: camotbik on September 19, 2011, 04:48:31 AM
-
I'm having here a really big problem and I'm seeking for some help. Since today I'm experiencing major client crashes - 7-10 minutes of running the script and BAM! That sucker(crash notification) pops up. It's really odd, because I have been farming points the night before and had no issues. In the morning did some edits( I've tried Freddy's Recalling sub - http://www.scriptuo.com/index.php?topic=8427.0 ) got the first 4 client crashes over 7-10 minutes and changed back to the s7 recalling sub. I have over written the old version - HOW DUMB OF ME! My first thought was that #findindex is a bit buggy, but then I've noticed that the client crashes 80% of the time at the donation vendor. So I'm a bit confused now. If you see anything that could cause a client crash - please let me know.
;=====================================================================
; Script Name: Item Buyer & Donator
; Author: CAMOTbIK
; Version: 0.2 Alfa
; Client Tested with: 7.0.14.0
; EUO version tested with: 1.92
; Shard OSI / FS: FS WWW.RWUO.COM
; Revision Date: 2011/09/19
; Public Release: 2011/09/16
; Global Variables Used: None
; Purpose: Buying stuff from vendors and donating it.
; Req - 100% LRC suite, runebooks with marked runes to vendors, a
; rune to bank and a rune to donation vendor inside %vendorbook1.
;=====================================================================
;========================== EDITABLES ================================
;=====================================================================
set %vendorbook1 UOLZSMD ; first runebook with vendors
set %vendorbook2 NBYQZMD ; second runebook with vendors
set %vendorbook3 RQXQZMD ; third runebook with vendors
set %startrune 1
set %endrune 14
set %donaterune 15 ; donation rune number in first runebook with vendors
set %bankrune 16 ; bank rune in first runebook with vendors
set %donation_vendor CAWG ; donation npc id
set %charname Darth
set %maxpoints 800000
;=====================================================================
;========================== DO NOT EDIT ==============================
;=====================================================================
set %donation_item BSF
set %vendortype IS_HS_NCB_OCB
set %start_time #scnt
set %gold_spend 0
set %items_donated 0
set %points 0
while #charname <> %charname
uoxl swap
gosub donation
menu Clear
menu Window Title C's Donator
menu Window Color ActiveBorder
menu Window Size 190 70
menu Font Transparent #true
menu Font Align Right
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Color Yellow
menu Font BGColor Black
menu List Create EUOListBox1 0 -9 250 200
menu List Add EUOListBox1 Items donated : %items_donated
menu List Add EUOListBox1 Gold spend : %gold_spend
menu List Add EUOListBox1 Points : %points
menu List Add EUOListBox1 Time : %points %Time
menu List Add EUOListBox1 Status: %1
menu Show 421 300
;=====================================================================
;========================== MAINLOOP =================================
;=====================================================================
repeat
for %i 1 3 ; 1-3 vendorbooks
{
set %current_book %vendorbook . %i
for %current_rune %startrune %endrune
{
gosub check_gold
gosub mana_check
gosub update Recalling , #spc , Vendorbook . %i , #spc , [ , #spc , %current_rune , #spc , ]
gosub s7UseRunebook %current_book %current_rune r
gosub buy
gosub donation
}
}
until #charghost = yes || %points > %maxpoints
if %points > %maxpoints
gosub update You , #spc , have , #spc , reached , #spc , %maxpoints , #spc , points.
halt
;=====================================================================
;========================== BUY BATTLE AXES ==========================
;=====================================================================
sub buy
finditem %vendortype G_8
for #FINDINDEX 1 #FINDCNT
{
if #FINDREP = 7
{
event Property #findID
if Blacksmith in #property || Weaponsmith in #property || Guildmaster in #property || guildmistress in #property
{
gosub update Buying..
set %gold #gold
exevent Popup #findid 2
wait 1s
if #gold <> %gold
{
set %current_gold %gold - #gold
set %gold_spend %gold_spend + %current_gold
}
}
else
ignoreitem #findid
}
else
ignoreitem #findid
}
return
;=====================================================================
;========================== WAIT FOR MANA ============================
;=====================================================================
sub mana_check
while #mana < 10
{
gosub update Waiting , #spc , for , #spc , mana..
wait 1s
}
return
;=====================================================================
;========================== DONATE THE BATTLE AXES ===================
;=====================================================================
sub donation
finditem %donation_item c_ , #backpackid
if #findcnt > 0
{
set %cnt #findcnt
gosub update Recalling , #spc , to , #spc , library
gosub s7UseRunebook %vendorbook1 %donaterune r
gosub update Donating
set #lobjectid %donation_vendor
event macro 17
gosub waitforgump 345_359
gosub OffsetClick 305 342
gosub waitforgump 345_359
gosub OffsetClick 305 342
gosub waitforgump 345_359
msg $
gosub OffsetClick 39 240
wait 2s
msg %cnt $
gosub waitforgump 345_359
gosub OffsetClick 284 42
set %items_donated ( %items_donated + %cnt )
set %points ( %points + %cnt * 9 )
}
return
;=====================================================================
;========================== OFFSET CLICK =============================
;=====================================================================
sub OffsetClick
set %tempx %1 + #CONTPOSX
set %tempy %2 + #CONTPOSY
click %tempx %tempy f
return
;=====================================================================
;========================== WAIT FOR GUMP ============================
;=====================================================================
sub waitforgump
set %timeout #scnt + 10
while #contsize <> %1
{
wait 1
if #scnt > %timeout
{
return #false
}
}
wait 1
return #true
;=====================================================================
;========================== CHECK FOR GOLD ===========================
;=====================================================================
sub check_gold
if #gold < 3000
{
gosub update Not , #spc , enough , #spc , gold..
gosub mana_check
gosub update Recalling , #spc , to , #spc , bank
gosub s7UseRunebook %vendorbook1 %bankrune r
event macro 1 1 sacar 4000
}
return
;=====================================================================
;========================== UPDATE MENU ==============================
;=====================================================================
sub update
menu Delete EUOListBox1
menu List Create EUOListBox1 0 -4 197 129
menu List Add EUOListBox1 Items donated : %items_donated
menu List Add EUOListBox1 Gold spend : %gold_spend
menu List Add EUOListBox1 Points : %points
gosub Calc_time
menu List Add EUOListBox1 Time : #result
menu List Add EUOListBox1 Status: %1
return
;=====================================================================
;========================== CALCULATE TIME ===========================
;=====================================================================
Sub Calc_Time
Set %TT #Scnt - %start_time
Set %hours %TT / 3600
Set %mins ( %TT / 60 ) - ( %hours * 60 )
Set %secs %TT % 60
If %hours =< 9
Set %hours 0 , %hours
If %mins =< 9
Set %mins 0 , %mins
If %secs =< 9
Set %secs 0 , %secs
Set %total_time %hours , : , %mins , : , %secs
return %total_time
;=====================================================================
;========================== HAPPY END ================================
;=====================================================================
; Script Name: sub s7UseRunebook
; Author: snicker7
; Version: 2.0
; Client Tested with: 4.0.11c
; EUO version tested with: 1.42/1.5
; Shard OSI / FS: OSI/FS
; Revision Date: 24Aug05
; Public Release: 24Aug05
; Global Variables Used: N/A
; Purpose: Failsafe sub to recall, gate, sacred journey flawlessly. Options to use scrolls, default locations, recharge books with scrolls in pack if book runs out of charges, and perfect gate travel. Not for the feint of heart!
;===================================================Speak to the hand
;======= This file includes the main sub and =======Speak to the hand
;===== several support subs that are required. =====Speak to the hand
;===================================================Speak to the hand
;===== Much love for T-Mo and BM, but I needed =====Speak to the hand
;====== to write something I could only blame ======Speak to the hand
;======= myself for if it fails. even though =======Speak to the hand
;=================== it doesn't. ===================Speak to the hand
;===================================================Speak to the hand
; ===================================================================== ;
; ///////////////////////////////////////////////////////////////////// ;
; // EXCERPTS FROM S7SUBS.EUO ///////////////////////////////////////// ;
; ///////////////////////////////////////////////////////////////////// ;
; // Any reproduction of the subroutines below is strictly pro- /////// ;
; // hibited without express written permission of the author ///////// ;
; // (snicker7). Violation of the above will result in malicious ////// ;
; // actions by the aforementioned author performed upon your person // ;
; // including but not limited to: bodily harm, slander, maternal ///// ;
; // insults, possible legal action, and callin' the five-oh. Thank /// ;
; // you. ///////////////////////////////////////////////////////////// ;
; ///////////////////////////////////////////////////////////////////// ;
; ===================================================================== ;
;=/ 1NCLUD3D SUBS: /================================Speak to the hand
; s7UseRunebook: Duh, you know why it's there.
; s7ScanJournalFor: SuperMultiParameterJournalScanning Power!
; s7MoveToPos: Legendary snicker7 brand name drag and drop sub. updated!
; s7MoveToCont: Wrapper for the above sub, updated for 1.5 exevents!
; s7WaitForAction: Mildly obsolete, begging for a rewrite object-delay sub!
; s7WaitForVars: Classic sysvar wait sub. One line shorter than Quintok's!
;===================================================Speak to the hand
;----
;* @name s7UseRunebook
;* @author snicker7
;* @ver 2.0a 24Aug05
;* @purpose do anything and everything travel related with a runebook
;* @params %1 Rune or Runebook item ID to use
;* %2 number of rune to travel to, use "default" for runes or default in runebook
;* %3 travel method:
;* r: recall
;* g: gate
;* c: sacred journey
;* s: scrolls
;* @dependencies
;* s7WaitForVars
;* s7WaitForAction
;* s7ScanJournalFor
;* s7MoveToCont for recharging runebooks
;* @returns #true on success
;* ERR_* various errors.
;* @notes none
;* @example: gosub s7UseRunebook %bookID 14 r
;* @status done
sub s7UseRunebook
if %0 < 3 || _ , %2 , _ notin _1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_default_
return ERR_IncorrectParams
namespace push
namespace local _s7URB
set !runebook %1
set !index %2
set !method %3
set !fails 0
if #contsize = 452_236
{
set !_cx #contposx + 20
set !_cy #contposy + 20
click !_cx !_cy r f dmc
wait 5
}
for !_ 1 1
{
finditem OTF_JEF_KEF G_0
if #findkind <> -1
set !_ 0
}
for !orb 1 1
{
if !fails > 2 2
namespace pop
return ERR_ , #journal
set !jStart #jindex + 1
if !index <> default
{
gosub s7WaitForAction 12
set #lobjectid !runebook
event macro 17 0
gosub s7WaitForVars contname = generic_gump contsize = 452_236 3
if ! #result 2
set !fails !fails + 1
set !orb 0
if #result
{
set !_cy #contposy + 196
set !_cx #contposx + 105 + ( ( ( !index / 2 ) + ( !index % 2 ) ) * 35 )
if !index > 8
set !_cx !_cx + 30
click !_cx !_cy f dmc
wait 5
set !_cx #contposx + 135
set !_cy #contposy + 144
if !method = G
set !_cy !_cy + 20
if !method = C
set !_cy !_cy + 36
if !method = S
set !_cy !_cy - 76
if ( !index % 2 ) = 0
set !_cx !_cx + 160
set !charpos #charposx , _ , #charposy
set !timeout #scnt2
click !_cx !_cy f dmc
}
}
if !index = default
{
set #ltargetid !runebook
set #ltargetkind 1
if !method = c
event macro 15 210
if !method = r
event macro 15 31
if !method = g
event macro 15 51
if !method = s
{
finditem WTL C_ , #backpackid
if #findkind = -1 2
namespace pop
return ERR_NoRecallScrolls
if #findkind <> -1 3
set #lobjectid #findid
gosub s7WaitForAction 12
event macro 17 0
}
for !_ 1 1
{
if #targcurs <> 1
set !_ 0
gosub s7ScanJournalFor !jStart fizzles more_reagents tithing_points insufficient_mana
if #result 3
set !_ 1
set !orb 0
wait 20
}
set !charpos #charposx , _ , #charposy
set !timeout #scnt2
event macro 22 0
}
if !orb = 1
{
for !success 1 1
{
if #charposx , _ , #charposy = !charpos && !method in _r_c_s_
set !success 0
if !method = g
{
finditem OTF_JEF_KEF G_0
if #findkind = -1
set !success 0
if #findkind <> -1
{
set #lobjectid #findid
gosub s7WaitForAction 12
event macro 17 0
for !_ 1 1
{
if #charposx , _ , #charposy = !charpos
set !_ 0
if #contname = generic_gump && #contsize = 420_280
{
set !_cx #contposx + 20
set !_cy #contposy + 260
click !_cx !_cy f dmc
}
}
}
}
gosub s7ScanJournalFor !jStart fizzles location_is_blocked not_yet_recovered no_charges_left more_reagents tithing_points insufficient_mana not_marked
if #result || !timeout + 60 < #scnt2
{
if no_charges in #journal
{
finditem WTL C_ , #backpackid
if #findkind = -1
set !fails 2
if #findkind <> -1
{
set !scrolls #findid
finditem !runebook
set #findmod 0
gosub s7WaitForAction 12
event drag !runebook
for !_ 1 1
{
if #lliftedkind <> 1 2
wait 1
set !_ 0
}
str pos #contsize _
set #strres #strres - 1
str left #contsize #strres
set !_cx #findx + #strres / 2
str pos #contsize _
str del #contsize 1 #strres
set !_cy #findy + #strres / 2
click !_cx !_cy p f dmc
gosub s7MoveToCont !scrolls !runebook #backpackid 20_10
}
}
set !fails !fails + 1
set !success 1
set !orb 0
}
}
wait 20
}
}
namespace pop
return #true
sub s7ScanJournalFor
set !SJFje #jindex + 1
for !SJFji %1 !SJFje
{
scanjournal !SJFji
for !SJFpi 2 %0
{
if % . !SJFpi in #journal
return #true
}
}
return #false
;----
;* @name s7MoveToPos
;* @author snicker7
;* @ver 1.2 24Aug05
;* @purpose Just Another Item Dragger.
;* @params %1 is the item to be dragged
;* %2 is the x-coord to drop to
;* %3 is the y-coord to drop to
;* %4 is the timeout in seconds
;* %5 is the amount to be dragged (blank for all)
;* @returns #true if drop was successful
;* #false on error (drop to backpack, insufficient params, failed to drag)
;* halt on critical error
;* @notes moves any item to a position on the screen. Will
;* attempt to drop on character if drop fails. If character
;* drop fails, halts and error message to avoid crash.
;* @dependencies
;* s7WaitForAction
;* @example: call s7Subs.euo s7MoveToPos #findid 7 9 4 77
;* @status unknown
sub s7MoveToPos
if %0 < 4
return #false
namespace Push
namespace Local _s7MvToPos
set !_ID %1
set !_x %2
set !_y %3
set !_tO %4
set !_Amt #spc
if %0 > 4
set !_Amt %5
set !_retry 0
_s7MvToPos_SD:
finditem !_ID
if #findkind = -1 2
namespace pop
return #false
gosub s7WaitForAction 13
event drag #findid
if #findstack > 1
{
set !_timeOut #scnt
for !_ 1 1
{
if #contname <> stack_gump && #contname <> drag_gump
{
wait 1
if !_timeOut + !_tO < #scnt
{
set !_retry !_retry + 1
if !_retry > 2 2
namespace pop
return #false
goto _s7MvToPos_SD
}
set !_ 0
}
}
if !_Amt > #findstack
set !_Amt #findstack
msg !_Amt , $
}
set !_retry 0
set !_timeOut #scnt
for !_ 1 1
{
if #lliftedkind <> 1
{
wait 1
if !_timeOut + !_tO < #scnt
{
set !_retry !_retry + 1
if !_retry > 2 2
namespace pop
return #false
goto _s7MvToPos_SD
}
set !_ 0
}
}
set !_retry 0
click !_x !_y p
set !_timeout #scnt
for !_ 1 1
{
if #lliftedkind = 1
{
wait 1
if !_timeout + !_t0 < #scnt
{
set !_retry !_retry + 1
if !_retry = 1
{
set !_x #clixres / 2
set !_y ( #cliyres / 2 ) - 30
click !_x !_y p
set #result #false
set !_timeout #scnt
}
if !_retry = 2 2
display ok You have failed to drop an item to the correct position.$$The script is now halting to prevent a crash.
halt
}
set !_ 0
}
}
set #result #true
namespace pop
return #result
;----
;* @name s7MoveToCont
;* @author snicker7
;* @ver 1.2 24Aug05
;* @purpose A wrapper for the sub s7MoveToPos for moving to containers.
;* @params %1 is the item to be dragged
;* %2 is the container to drag to
;* %3 is the mother container in which %2 is contained
;* %4 is the #findmod value for the container
;* %5 is the amount to be dragged (blank for all)
;* @returns none
;* @notes this is mad basic. no error checking. That is up to you.
;* @dependencies s7MoveToPos
;* @example: call s7Subs.euo s7MoveToCont #findid #backpackid #charid 140_220
;* @status tested good
sub s7MoveToCont
namespace Push
namespace Local _s7MoveToCont
set !_ID %1
set !_DCont %2
set !_MCont %3
set !_FMod %4
if 1_5 in #euover
{
set !_Amt 65535
if %0 > 4
set !_Amt abs %5
finditem !_ID
if #findkind = -1 2
namespace pop
return #false
gosub s7WaitForAction 13
exevent drag #findid !_Amt
exevent dropc !_DCont
namespace pop
return #true
}
set !_Amt #spc
if %0 > 4
set !_Amt %5
set #result #true
set !_retry 0
for !_ 1 1
{
finditem !_DCont C_ , !_MCont
if #findkind = -1
{
set #lobjectid !_MCont
gosub s7WaitForAction 13
event macro 17 0
gosub s7WaitForVars contid = !_MCont 3
if ! #result
{
set !_retry !_retry + 1
if !_retry > 2 2
namespace pop
return #false
}
set !_ 0
}
}
set !_retry 0
set #findmod !_Fmod
for !_ 1 1
{
gosub s7MoveToPos !_ID #findx #findy 4 !_Amt
if ! #result
{
set !_retry !_retry + 1
if !_retry > 2 2
namespace pop
return #false
set !_ 0
}
}
namespace Pop
return #true
;----
;* @name s7WaitForAction
;* @author snicker7
;* @ver 1.1 31Jan05
;* @purpose waits 1.3 seconds before continuing, useful for waiting to perform
;* another action
;* @params none
;* @returns none
;* @notes probably not an original idea, but I need to use it frequently and it
;* was easier to write it myself than to try to look for it as written by
;* someone else
;* @example: call s7Subs.euo s7WaitForAction 13
;* @status tested good
sub s7WaitForAction
_s7WaitForAction:
if %_s7ActionTimer + %1 > #scnt2 2
wait 1
goto _s7WaitForAction
set %_s7ActionTimer #scnt2
return
;----
;* @name s7WaitForVars
;* @author snicker7, inspired by Quintok, and of course, Smertrios
;* @ver 1.2 24Aug05
;* @purpose Multiple input sysvar waiter.
;* @params %1*n is the gump sysvar being checked
;* %2*n is the comparative operator (>, <, <>, =, etc)
;* %3*n is the desired value of the sysvar
;* %nfinal is the timeout in seconds
;* @returns #false if it times out
;* #true if success
;* @notes %1 does not require the preceding number sign
;* one line shorter than Q's, no disrespect son
;* originally written by Smertrios, included in Lexia
;* Multiple inputs by Quintok, Obfuscation and name-
;* spacing by snicker7!
;* @example: call s7Subs.euo s7WaitForVars contID = #backpackID contSize = 7_9 3
;* @status tested good
sub s7WaitForVars
namespace Push
namespace Local _s7WFVs
set !C %0 / 3
set !T #scnt + 5
if ( %0 % 3 ) = 1
set !T #scnt + % . %0
for !i 1 !C
{
set !o 3 * !i - 2
set !p !o + 1
set !q !o + 2
if ! ( # . % . !o % . !p % . !q )
set !i 0
if #scnt > !T 2
namespace pop
return #false
}
namespace Pop
return #true
-
Crashes are usually caused at lag spikes, when you have defined wait times to do a set of actions...
Most scripts that use recalling, end up having some crashing issues at some point, if the user experiences lag...
What I do to debug this on my scripts, is pause the script everytime I get a crash, and see exactly which lines are being executed at the time of the crash to try and make that part more "condition based", instead of "time based"... That usually helps a bit...
-
umm i never crash on recalls... I'll release my subs if people want them
What i do find causes crashes more than anything is not enough time when doing drag drop options. I always error on extra time for these actions to make sure no crashes. 2nd crash issue ghosted items.. theirfor periodic reopening of your backpack is called for...
I note in your/snickers sub drag drop code is as below
gosub s7WaitForAction 13
exevent drag #findid !_Amt
exevent dropc !_DCont
personally i think the wait is needed after the action not prior, or as a split wait... as in
exevent drag #findid !_Amt
exevent dropc !_DCont
wait 20
or
exevent drag #findid !_Amt
wait 10
exevent dropc !_DCont
wait 10
to guarantee no drag drop crashes i've found a wait 20 is the perfect number no matter what server ping you have.
-
That's true, I would get a lot of crashes because of lag issues... Even amount of waits up until 2 seconds would occasionaly crash on me...
I wrote a sub to move stuff, to try and avoid those crashes... I posted it in the snippet sessions...
If you want to give it a go, and find it useful, you're free to use it on your scripts camotbik...
http://www.scriptuo.com/index.php?topic=8547.0
neo
-
Thank you guys for your response, but this will sound funny. It was a shard issue, they had some kind of error/bug and that coused client to crash. This has been fixed now and the script works as it should.
frneo: Thanks for advice, but it's really hard to catch the moment of the crash to press pause.
Endless Night: The only reason why the drag/drop sub was there, was because snickers had stated that all the subs of the script had to be included in a script if using his s7recall sub. Myself I'm using the exact method you have stated - wait 10, after dropc. It would be really nice of you if you wold post that.
frneo: Good job with that sub. I could use this in my upcoming mining script.
-
Thank you guys for your response, but this will sound funny. It was a shard issue, they had some kind of error/bug and that coused client to crash. This has been fixed now and the script works as it should.
frneo: Thanks for advice, but it's really hard to catch the moment of the crash to press pause.
Endless Night: The only reason why the drag/drop sub was there, was because snickers had stated that all the subs of the script had to be included in a script if using his s7recall sub. Myself I'm using the exact method you have stated - wait 10, after dropc. It would be really nice of you if you wold post that.
frneo: Good job with that sub. I could use this in my upcoming mining script.
It really doesn't need to be the exact moment of the crash... If you write every part of the script with a condition check, before it moves on to the next part, it will keep trying to repeat that exact part which got you the crash... So even if you'd find the client crashed, 1 hour after it happened, the script should still be cycling that part...
At least, that's how I do it here hehe! :)
-
Oh, I see how you mean it.