· 10 years ago · May 30, 2016, 12:21 PM
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#If don't have your own database delete these lines
42
43#Replace 'ip' with ip of your database
44#Replace 'port' with port of your database
45#Replace 'db' with name of your database
46#Replace 'dbuser' with username of your database
47#Replace 'dbpass' with password of your database
48
49script options:
50 $ db url jdbc:mysql://ip:port/db
51 $ db username dbuser
52 $ db password dbpass
53
54options:
55 p: &5SharpAPI &f| &f #Prefix of the script
56 ver: 1.0 #Please, don't edit it because if you set this option to another one script will automatically be updated
57 NeedPlayersStart: 8 #Set this option to amount of players when game will be started
58 autodl: true #If this option is set to 'true' new version of the script will be downloaded automatically
59 type: game #Set this option to name of your minigame
60 DBSupport: false #Set this option to true if you have own database
61 BungeeSupport: true #Set this option to false if you don't have BungeeCord
62 NameOfQuitItem: &cBack to &eLobby &7(Right Click) #Set this option to name of item which backs you to Lobby (if you set option BungeeSupport to false, you can do nothing here)
63 LobbyServer: Lobby-1 #Set this option to name of Lobby (if you set option BungeeSupport to false, you can do nothing here)
64 Server: game-1 #Set this option to name of this server (if you set option BungeeSupport to false, you can do nothing here)
65 Map: world #Set this option to name of your minigame map
66 Table: Servers #Set this option to table of your database where will be status of servers
67 RestartAfter: true #Set this option to false if you don't want to restart server after each game
68
69#Use command /sharpapi:altertables to add altertables
70on load:
71 update "CREATE TABLE IF NOT EXISTS `{@Table}` (`Type` varchar(255),`Server` varchar(255),`Status` varchar(255),`Map` varchar(255))"
72
73function thisMySQLUpdateStatus(type:text,server:text,status:text,map:text):
74 set {_SetResult::*} to objects in column "Server" from result of query "SELECT * FROM {@Table} WHERE Server = '%{_server}%'" and close
75 set {_GetResult} to false
76 loop {_SetResult::*}:
77 If loop-value is {_server}:
78 set {_GetResult} to true
79 If {_GetResult} is false:
80 update "INSERT INTO `{@Table}` (`Type`,`Server`,`Status`,`Map`) VALUES ('%{_type}%', '%{_server}%', '%{_status}%', '%{_map}%')"
81 else:
82 update "UPDATE `{@Table}` SET `Type` = '%{_type}%' WHERE `{@Table}`.`Server` ='%{_server}%'"
83 update "UPDATE `{@Table}` SET `Server` = '%{_server}%' WHERE `{@Table}`.`Server` ='%{_server}%'"
84 update "UPDATE `{@Table}` SET `Status` = '%{_status}%' WHERE `{@Table}`.`Server` ='%{_server}%'"
85 update "UPDATE `{@Table}` SET `Map` = '%{_map}%' WHERE `{@Table}`.`Server` ='%{_server}%'"
86
87on script load:
88 use 2.1.2 loops
89 set {{@Server}.status} to "Waiting"
90 if {@DBSupport} is true:
91 set {_type} to "{@type}"
92 set {_server} to "{@Server}"
93 set {_status} to "Waiting"
94 set {_map} to "{@Map}"
95 thisMySQLUpdateStatus({_type},{_server},{_status},{_map})
96 stop
97 set {_skquery::*} to all enum values of displayslot
98 if size of {_skquery::*} is greater than 0:
99 set {_installed} to true
100 else:
101 set {_isntalled} to false
102 if {_installed} is false:
103 send " " to console
104 send "{@p}&cPlease, install &eSkQuery &con your server!%nl%{@p}Some functions can't work without &eskQuery&c!" to console
105 send " " to console
106 set {_ver} to text from url "http://pastebin.com/raw/Dhm6e2TU"
107 if {_ver} isn't {@ver}:
108 send " " to console
109 send " " to console
110 if {@autodl} is true:
111 send "{@p}The new version of &5SharpAPI was found!" to console
112 send "{@p}Current version of the script is &e%{@ver}%&f." to console
113 send "{@p}A new version of the script is &e%{_ver}%&f." to console
114 send "{@p}It &fwill be downloaded in &e5 seconds&f!" to console
115 wait 5 seconds
116 evaluate "download from ""http://sharpring.ru/SharpAPI.sk"" to ""plugins/Skript/scripts/SharpAPI.sk"""
117 send "{@p}The new version of &5SharpAPI &fwas downloaded successfully!" to console
118 else if {@autodl} is false:
119 send "{@p}The new version of &5SharpAPI was found!" to console
120 send "{@p}Current version of the script is &e%{@ver}%&f." to console
121 send "{@p}A new version of the script is &e%{_ver}%&f." to console
122 send "{@p}You can download it on the &ehttp://sharpring.ru/SharpAPI/&f."
123 send " " to console
124 send " " to console
125
126on script unload:
127 set {{@Server}.status} to "Offline"
128 if {@DBSupport} is true:
129 set {_type} to "{@type}"
130 set {_server} to "{@Server}"
131 set {_status} to "Offline"
132 set {_map} to "{@Map}"
133 thisMySQLUpdateStatus({_type},{_server},{_status},{_map})
134
135command /sharpapi:altertables:
136 trigger:
137 if player doesn't have permission "sharpapi.admin":
138 send "{@p}&cSorry, but you don't have enough permissions to execute this command!"
139 stop
140 if command sender isn't console:
141 send "{@p}&cSorry, but you don't have enough permissions to execute this command!"
142 stop
143 update "ALTER TABLE {@Table} ADD UNIQUE (Type, Server, Status, Map)"
144 send "{@p}&eAlter Tables &fwere successfully added to the table &e{@Table}&f."
145
146on join:
147 set {_onl} to amount of all players
148 set {_onl} to "%{_onl}%" parsed as integer
149 set {_needed} to {@NeedPlayersStart}
150 set {_needed} to "%{_needed}%" parsed as integer
151 if {_onl} is >= {_needed}:
152 set {_s} to "Starting"
153 game-status({_s})
154
155# Usage for start game:
156#
157# set {_s} to "Start"
158# game-status({_s})
159#
160# Usage for restart(stop) game:
161#
162# set {_s} to "Restart"
163# game-status({_s})
164#
165function game-status(s:text):
166 if {_s} is "start" or "Start":
167 if {{@Server}.status} is "Starting":
168 return "{@p}&cThe game is starting already!"
169 else:
170 set {{@Server}.status} to "Starting"
171 if {@DBSupport} is true:
172 if {@BungeeSupport} is true:
173 set {_server} to "{@Server}"
174 else:
175 set {_server} to "Bungee isn't installed"
176 set {_status} to "Starting"
177 set {_type} to "{@type}"
178 set {_map} to "{@Map}"
179 thisMySQLUpdateStatus({_type},{_server},{_status},{_map})
180 broadcast "{@p}&fThe game is starting in &e35 seconds&f!"
181 wait 5 seconds
182 broadcast "{@p}&fThe game is starting in &e30 seconds&f!"
183 wait 5 seconds
184 broadcast "{@p}&fThe game is starting in &e25 seconds&f!"
185 wait 5 seconds
186 broadcast "{@p}&fThe game is starting in &e20 seconds&f!"
187 wait 5 seconds
188 broadcast "{@p}&fThe game is starting in &e15 seconds&f!"
189 wait 5 seconds
190 broadcast "{@p}&fThe game is starting in &e10 seconds&f!"
191 wait 5 seconds
192 loop all players:
193 send action bar from "&fThe game is starting in &e5 seconds&f!" to loop-player
194 broadcast "{@p}&fThe game is starting in &e5 seconds&f!"
195 wait 1 second
196 send action bar from "&fThe game is starting in &e4 seconds&f!" to loop-player
197 broadcast "{@p}&fThe game is starting in &e4 seconds&f!"
198 wait 1 second
199 send action bar from "&fThe game is starting in &e3 seconds&f!" to loop-player
200 broadcast "{@p}&fThe game is starting in &e3 seconds&f!"
201 wait 1 second
202 send action bar from "&fThe game is starting in &e2 seconds&f!" to loop-player
203 broadcast "{@p}&fThe game is starting in &e2 seconds&f!"
204 wait 1 second
205 send action bar from "&fThe game is starting in &e1 second&f!" to loop-player
206 broadcast "{@p}&fThe game is starting in &e1 second&f!"
207 wait 1 second
208 send action bar from "&fThe game is starting &enow&f!" to loop-player
209 broadcast "{@p}&fThe game is starting &enow&f!"
210 set {{@Server}.status} to "InGame"
211 if {@DBSupport} is true:
212 if {@BungeeSupport} is true:
213 set {_server} to "{@Server}"
214 else:
215 set {_server} to "Bungee isn't installed"
216 set {_status} to "InGame"
217 set {_type} to "{@type}"
218 set {_map} to "{@Map}"
219 thisMySQLUpdateStatus({_type},{_server},{_status},{_map})
220 stop
221 if {_s} is "restart" or "Restart":
222 set {{@Server}.status} to "Restarting"
223 if {@DBSupport} is true:
224 if {@BungeeSupport} is true:
225 set {_server} to "{@Server}"
226 else:
227 set {_server} to "Bungee isn't installed"
228 set {_status} to "Restarting"
229 set {_type} to "{@type}"
230 set {_map} to "{@Map}"
231 thisMySQLUpdateStatus({_type},{_server},{_status},{_map})
232 broadcast "{@p}&fThe game is restarting in &e10 seconds&f!"
233 wait 5 seconds
234 loop all players:
235 send action bar from "&fThe game is restarting in &e5 seconds&f!" to loop-player
236 broadcast "{@p}&fThe game is restarting in &e5 seconds&f!"
237 wait 1 second
238 send action bar from "&fThe game is restarting in &e4 seconds&f!" to loop-player
239 broadcast "{@p}&fThe game is restarting in &e4 seconds&f!"
240 wait 1 second
241 send action bar from "&fThe game is restarting in &e3 seconds&f!" to loop-player
242 broadcast "{@p}&fThe game is restarting in &e3 seconds&f!"
243 wait 1 second
244 send action bar from "&fThe game is restarting in &e2 seconds&f!" to loop-player
245 broadcast "{@p}&fThe game is restarting in &e2 seconds&f!"
246 wait 1 second
247 send action bar from "&fThe game is restarting in &e1 second&f!" to loop-player
248 broadcast "{@p}&fThe game is restarting in &e1 second&f!"
249 wait 1 second
250 send action bar from "&fThe game is restarting &enow&f!" to loop-player
251 broadcast "{@p}&fThe game is restarting &enow&f!"
252 wait 3 tick
253 if {@BungeeSupport} is true:
254 bungeecord connect loop-player to "{@LobbyServer}"
255 set {{@Server}.status} to "Restarting"
256 if {@DBSupport} is true:
257 if {@BungeeSupport} is true:
258 set {_server} to "{@Server}"
259 else:
260 set {_server} to "Bungee isn't installed"
261 set {_status} to "Restarting"
262 set {_type} to "{@type}"
263 set {_map} to "{@Map}"
264 thisMySQLUpdateStatus({_type},{_server},{_status},{_map})
265 wait 1 second
266 if {@RestartAfter} is true:
267 stop server
268 stop