From 97e59ebfc6e33b328c22b3ba1a60ade846a4d01f Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Fri, 4 Mar 2022 21:02:42 +0100 Subject: added variable to change all timeouts at once --- plugins/shop.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/plugins/shop.py b/plugins/shop.py index 5e3bf24..8c234fe 100755 --- a/plugins/shop.py +++ b/plugins/shop.py @@ -31,6 +31,10 @@ PLUGIN = { shoplog = logging.getLogger('ManaChat.Shop') trade_timeout = 60 +time_sleep = 1 +# default = 10 +# Use at your own risk if you think the default value is too slow. +# 0 works too. shop_admins = None ignored_players = preloadArray("config/ignored.txt") @@ -88,7 +92,7 @@ def selllist(nick, message, is_whisper, match): # ~ if lastNickGreeted != nick: # ~ if nick in nobuy: # ~ mapserv.cmsg_chat_message("Special prize for you, " + nick + "!") - # ~ time.sleep(10) + # ~ time.sleep(time_sleep) # ~ else: # ~ answer = random.choice(sell_greetings) # ~ mapserv.cmsg_chat_message(answer.format(nick)) @@ -109,7 +113,7 @@ def selllist(nick, message, is_whisper, match): data += encode_str(id_, 2) data += encode_str(price, 4) data += encode_str(amount, 3) - time.sleep(10) + time.sleep(time_sleep) whisper(nick, data) @@ -123,7 +127,7 @@ def buylist(nick, message, is_whisper, match): # ~ mapserv.cmsg_chat_message(answer.format(nick)) # ~ lastNickGreeted = nick - + # Support for 4144's shop (Sell list) data = '\302\202S1' @@ -147,7 +151,7 @@ def buylist(nick, message, is_whisper, match): data += encode_str(price, 4) data += encode_str(amount, 3) - time.sleep(10) + time.sleep(time_sleep) whisper(nick, data) def sellitem(nick, message, is_whisper, match): @@ -156,7 +160,7 @@ def sellitem(nick, message, is_whisper, match): if nick in ignored_players: return - time.sleep(10) + time.sleep(time_sleep) item_id = amount = 0 # FIXME: check if amount=0 or id=0 @@ -176,7 +180,7 @@ def sellitem(nick, message, is_whisper, match): else: whisper(nick, "I am currently trading with someone") return - + player_id = mapserv.beings_cache.findId(nick) if player_id < 0: whisper(nick, "I don't see you nearby") @@ -220,8 +224,8 @@ def buyitem(nick, message, is_whisper, match): return item_id = amount = 0 - time.sleep(10) - + time.sleep(time_sleep) + # FIXME: check if amount=0 or id=0 try: item_id = int(match.group(1)) @@ -286,7 +290,7 @@ def retrieve(nick, message, is_whisper, match): if not shop_admins.check_player(nick): return - time.sleep(10) + time.sleep(time_sleep) item_id = amount = 0 @@ -341,7 +345,7 @@ def invlist(nick, message, is_whisper, match): if not shop_admins.check_player(nick): return - time.sleep(10) + time.sleep(time_sleep) ls = status.invlists(50) for l in ls: @@ -377,7 +381,7 @@ def trade_response(data): return code = data.code - time.sleep(10) + time.sleep(time_sleep) if code == 0: shoplog.info("%s is too far", s.player) @@ -416,7 +420,7 @@ def trade_item_add(data): cleanup() return - time.sleep(10) + time.sleep(time_sleep) item_id, amount = data.id, data.amount @@ -452,7 +456,7 @@ def trade_item_add_response(data): cleanup() return - time.sleep(10) + time.sleep(time_sleep) code = data.code amount = data.amount @@ -494,7 +498,7 @@ def trade_ok(data): who = data.who - time.sleep(10) + time.sleep(time_sleep) if who == 0: return @@ -541,7 +545,7 @@ def trade_complete(data): cleanup() return - time.sleep(10) + time.sleep(time_sleep) if s.mode == 'sell': shoplog.info("Trade with %s completed. I sold %d %s for %d GP", -- cgit v1.2.3-70-g09d2 From 97055867550f0beca2a2cb396ccd95f6e58320de Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Fri, 4 Mar 2022 21:05:23 +0100 Subject: setting variable to default value --- plugins/shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/shop.py b/plugins/shop.py index 8c234fe..828c7ea 100755 --- a/plugins/shop.py +++ b/plugins/shop.py @@ -31,7 +31,7 @@ PLUGIN = { shoplog = logging.getLogger('ManaChat.Shop') trade_timeout = 60 -time_sleep = 1 +time_sleep = 10 # default = 10 # Use at your own risk if you think the default value is too slow. # 0 works too. -- cgit v1.2.3-70-g09d2