Skip to content

Instantly share code, notes, and snippets.

@Reedzev
Created May 4, 2017
Embed
What would you like to do?
CommandLock - prosty skrypt na blokadę komend.
#CommandLock
#Licencja: Creative Commons (BY, SA) (3.0) https://creativecommons.org/licenses/by-sa/3.0/pl/legalcode
#===========================
#Copyright (c) 2016 Reedzev_
#All Rights Reserved.
options:
path: CommandLock/lockedcommands.yml
function endsWith(t: text, s: text) :: boolean:
if subtext of {_t} from characters length of {_t} - length of {_s} - 1 to length of {_t} is {_s}:
return true
stop
return false
function isWhitelistedPlayer(t: text) :: boolean:
loop {commandLock::wlPlayers::*}:
if loop-value is {_t}:
return true
return false
on script load:
if yaml value "commands.specialvar" from file "{@path}" is not set:
set yaml value "commands" from file "{@path}" to ""
add "examplecommand" to yaml list "commands.list" from file "{@path}"
add "exampleplayer" to yaml list "commands.whitelist" from file "{@path}"
set yaml value "commands.enabled" from file "{@path}" to "true"
set yaml value "commands.lockedmessage" from file "{@path}" to "&cKomenda jest zablokowana. Skontaktuj się z administratorem serwera jeśli jest to według Ciebie błąd."
set yaml value "commands.specialvar" from file "{@path}" to "niedotykajtejwartosci"
set {commandLock::commandList::*} to yaml list "commands.list" from file "{@path}"
set {commandLock::wlPlayers::*} to yaml list "commands.whitelist" from file "{@path}"
set {commandLock::enabledBoolean} to yaml value "commands.enabled" from file "{@path}"
set {commandLock::lockedMsg} to yaml value "commands.lockedmessage" from file "{@path}"
on command:
set {_specialchar} to ":"
if sender is console:
stop
isWhitelistedPlayer("%sender%") is true:
stop
{commandLock::enabledBoolean} is "false":
stop
loop {commandLock::commandList::*}:
if command is "%loop-value%":
cancel event
send {commandLock::lockedMsg} to sender
stop
if endsWith("%command%", "%{_specialchar}%%loop-value%") is true:
if "%command%" is "%{_specialchar}%%loop-value%":
stop
cancel event
send {commandLock::lockedMsg} to sender
command /commandlock:commandlock [<text="help">]:
permission: commandlock.manage
executable by: players and console
aliases: /commandlock:cl, /commandlock, /cl
permission message: &cNie masz uprawnień aby tego dokonać.
trigger:
if arg 1 is "help":
send "== &eCommandLock &7- pomoc =="
send "&breload &7 - przeładowywuje skrypt"
send "&bcopyright &7 - pokazuje informacje o autorze i licencji skryptu"
send "&blockedcmds &7 - pokazuje zablokowane komendy"
send "&bwhplayers &7 - pokazuje graczy z białej listy"
stop
if arg 1 is "reload":
execute console command "/skript:sk reload %script%"
send "&eCommandLock: &aPomyślnie przeładowano skrypt."
stop
if arg 1 is "copyright":
send "&eCommandLock."
send "&aLicencja: Creative Commons (BY, SA) (3.0) &1&nhttps://creativecommons.org/licenses/by-sa/3.0/pl/legalcode"
send "&7==========================="
send "&eCopyright (c) 2016 Reedzev_."
send "&eAll Rights Reserved."
stop
if arg 1 is "lockedcmds":
set {_c} to size of {commandLock::commandList::*}
send "== &eCommandLock &7- zablokowane komendy (%{_c}%) =="
if {_c} is 0:
send "&cNie ma zablokowanych komend."
loop {commandLock::commandList::*}:
send "&c - /*:%loop-value%"
stop
if arg 1 is "whplayers":
set {_c} to size of {commandLock::wlPlayers::*}
send "== &eCommandLock &7- biała lista graczy (%{_c}%) =="
if {_c} is 0:
send "&cNie ma graczy na białej liście."
stop
loop {commandLock::wlPlayers::*}:
send "&c - %loop-value%"
stop
send "&cNieprawidłowy argument. Dozwolone argumenty: help, reload, copyright, lockedcmds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment