options: #Wersja 1.0 #czy kod może być wpisywany przez chat chatCode: true #czy wielkość znaków w kodzie powinna być brana pod uwagę caseSensitive: true #długość generowanego kodu length: 12 #ciąg znaków, z którego będzie generowany kod, wielkość liter ma znaczenie code: qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890 #czy automatyczny kod ma być aktywny autoCodeStatus: true #co jaki czas automatyczny kod ma się aktywować (w sekundach) autoCodeInterval: 600 #ile razy wiadomość z kodem ma pojawić się na chacie w przypadku niewpisania przez graczy poprawnego kodu #0 - opcja wyłączona autoCodeReplay: 5 #komenda, która wykona się po wpisaniu poprawnego kodu, np. #awardCommand: give [player] diamond 1 #awardCommand: pex user [player] group set vip awardCommand: eco give [player] 1000 messageMain: &6Losowy kod, kto pierwszy go przepisze: &e&l[code] messageCorrect: &2Gracz &a&l[player]&2 przepisał kod jako pierwszy. messageWrong: &4Kod niepoprawny. messageNone: &4Brak aktywnego kodu. function checkCode(msg: string) :: boolean: if !{@caseSensitive}: if {_msg} contains {currentCode}: delete {currentCode} return true return false if {_msg} contains {currentCode}: set {_firstIndex} to first index of {currentCode} in {_msg} set {_lastIndex} to (length of {currentCode}) + {_firstIndex} set {_playerCode} to subtext of {currentCode} from character {_firstIndex} to character {_lastIndex} if {_playerCode}.equals({currentCode}): delete {currentCode} return true return false function getMessage(msg: string, player: string="") :: string: replace "[player]" with {_player} in {_msg} replace "[code]" with {currentCode} in {_msg} return {_msg} function generateCode(t: string) :: string: replace " " with "" in {_t} set {_codes::*} to {_t} split at "" loop {@length} times: add random element out of {_codes::*} to {_list::*} return join {_list::*} with "" function activateCode(): set {currentCode} and {_functionCode} to generateCode("{@code}") send getMessage("{@messageMain}") to all players if {@autoCodeReplay} > 0: set {_delay} to ("%rounded down ({@autoCodeInterval} / ({@autoCodeReplay} + 1))% seconds" parsed as timespan) loop {@autoCodeReplay} times: wait {_delay} if {currentCode} is {_functionCode}: send getMessage("{@messageMain}") to all players else: stop loop on load: activateCode() on chat: if {@chatCode}: if checkCode(message): send getMessage("{@messageCorrect}", name of player) to all players make console execute command getMessage("{@awardCommand}", name of player) command /kod []: trigger: if {currentCode} is set: if checkCode(arg 1): send getMessage("{@messageCorrect}", name of player) to all players make console execute command getMessage("{@awardCommand}", name of player) else: send getMessage("{@messageWrong}") to player else: send getMessage("{@messageNone}") to player every {@autoCodeInterval} seconds: if {@autoCodeStatus}: activateCode()