options: #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 (oddzielonych przecinkami), z którego będzie generowany kod, wielkość liter ma znaczenie code: q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,1,2,3,4,5,6,7,8,9,0 #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 activateCode(): set {currentCode} and {_functionCode} to getCode("{@code}", {@length}) 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()