-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathSteal_StreamlabsSystem.py
More file actions
127 lines (106 loc) · 4.28 KB
/
Steal_StreamlabsSystem.py
File metadata and controls
127 lines (106 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import clr
import sys
import json
import os
import ctypes
import codecs
ScriptName = "Steal Minigame"
Website = "http://www.github.com/Bare7a/Streamlabs-Chatbot-Scripts"
Description = "Steal Minigame for Streamlabs Bot"
Creator = "Bare7a"
Version = "1.2.8"
configFile = "config.json"
settings = {}
def ScriptToggled(state):
return
def Init():
global settings
path = os.path.dirname(__file__)
try:
with codecs.open(os.path.join(path, configFile), encoding='utf-8-sig', mode='r') as file:
settings = json.load(file, encoding='utf-8-sig')
except:
settings = {
"liveOnly": True,
"command": "!steal",
"permission": "Everyone",
"cost": 5,
"winProbability":30,
"minReward": 10,
"maxReward": 20,
"useCooldown": True,
"useCooldownMessages": True,
"cooldown": 1,
"onCooldown": "$user, $command is still on cooldown for $cd minutes!",
"userCooldown": 300,
"onUserCooldown": "$user $command is still on user cooldown for $cd minutes!",
"responseWon": "$user stole $reward $currency from $victim",
"responseLost": "$user couldn't steal any $currency from $victim and lost $reward $currency",
"responseNotEnoughPoints": "$user you need $cost $currency to steal."
}
def Execute(data):
if data.IsChatMessage() and data.GetParam(0).lower() == settings["command"] and Parent.HasPermission(data.User, settings["permission"], "") and ((settings["liveOnly"] and Parent.IsLive()) or (not settings["liveOnly"])):
outputMessage = ""
userId = data.User
username = data.UserName
points = Parent.GetPoints(userId)
if points < settings["costs"]:
outputMessage = settings["responseNotEnoughPoints"]
elif settings["useCooldown"] and (Parent.IsOnCooldown(ScriptName, settings["command"]) or Parent.IsOnUserCooldown(ScriptName, settings["command"], userId)):
if settings["useCooldownMessages"]:
if Parent.GetCooldownDuration(ScriptName, settings["command"]) > Parent.GetUserCooldownDuration(ScriptName, settings["command"], userId):
cdi = Parent.GetCooldownDuration(ScriptName, settings["command"])
cd = str(cdi / 60) + ":" + str(cdi % 60).zfill(2)
outputMessage = settings["onCooldown"]
else:
cdi = Parent.GetUserCooldownDuration(ScriptName, settings["command"], userId)
cd = str(cdi / 60) + ":" + str(cdi % 60).zfill(2)
outputMessage = settings["onUserCooldown"]
outputMessage = outputMessage.replace("$cd", cd)
else:
outputMessage = ""
else:
Parent.RemovePoints(userId, username, settings["costs"])
currentChance = Parent.GetRandom(0, 100)
winProbablity = settings["winProbability"]
lossProbability = 100 - winProbablity
userList = Parent.GetViewerList()
while True:
victimId = userList[Parent.GetRandom(0, len(userList))]
if victimId != userId:
break
victim = Parent.GetDisplayName(victimId)
reward = Parent.GetRandom(settings["minReward"], settings["maxReward"] + 1)
if reward > points:
reward = points
if currentChance>lossProbability:
Parent.AddPoints(userId, username, reward)
Parent.RemovePoints(victimId, victim, reward)
outputMessage = settings["responseWon"]
else:
Parent.RemovePoints(userId, username, reward)
Parent.AddPoints(victimId, victim, reward)
outputMessage = settings["responseLost"]
outputMessage = outputMessage.replace("$victim", victim)
outputMessage = outputMessage.replace("$reward", str(reward))
if settings["useCooldown"]:
Parent.AddUserCooldown(ScriptName, settings["command"], userId, settings["userCooldown"])
Parent.AddCooldown(ScriptName, settings["command"], settings["cooldown"])
outputMessage = outputMessage.replace("$user", username)
outputMessage = outputMessage.replace("$points", str(points))
outputMessage = outputMessage.replace("$currency", Parent.GetCurrencyName())
outputMessage = outputMessage.replace("$command", settings["command"])
outputMessage = outputMessage.replace("$cost", str(settings["costs"]))
outputMessage = outputMessage.replace("$minReward", str(settings["minReward"]))
outputMessage = outputMessage.replace("$maxReward", str(settings["maxReward"]))
Parent.SendStreamMessage(outputMessage)
return
def ReloadSettings(jsonData):
Init()
return
def OpenReadMe():
location = os.path.join(os.path.dirname(__file__), "README.txt")
os.startfile(location)
return
def Tick():
return