skriptMC/0functions.sk

52 lines
1.8 KiB
Text
Raw Normal View History

2021-11-14 03:13:58 +01:00
# named with a 0 at the begining to be sure he is loaded first
# the goal of this file is to load all the function who are used
# by a lot of my other files
2021-06-28 21:50:46 +02:00
on load:
ScriptList("add", script)
on unload:
ScriptList("remove", script)
2021-11-14 03:13:58 +01:00
# avoids having to type the same message several times (e.g. the error message)
2021-06-28 12:04:45 +02:00
function option(option: text) :: text: # options
if {_option} is "serverName":
set {_resultat} to "Serveur d'Anri"
if {_option} is "errorMessage":
set {_resultat} to "&4Tu n'as pas la permission d'utiliser cette commande."
return {_resultat}
2021-06-28 12:04:45 +02:00
2021-11-14 03:13:58 +01:00
# sends message to operators (excludes the player if he's OP too)
function sendToOperators(player: player, message: text):
2021-06-28 12:04:45 +02:00
loop all players:
if loop-player is a op:
if loop-player is not {_player}:
send {_message} to loop-player
2021-06-28 21:50:46 +02:00
2021-11-14 03:13:58 +01:00
# allows to add or remove a file to the list of scripts files
# all files add their names to the list when they are loaded
# and remove them when they are unloaded
2021-06-28 21:50:46 +02:00
function ScriptList(addRemove: text, list: text):
if {_addRemove} is "add":
add {_list} to {scripts::*}
if {_addRemove} is "remove":
remove {_list} from {scripts::*}
2021-06-29 21:07:16 +02:00
2021-11-14 03:13:58 +01:00
# returns the name taking into account his possible nickname
2021-06-29 21:07:16 +02:00
function userOrNick(player: player) :: text:
set {_uuid} to uuid of {_player}
if {nick.%{_uuid}%} is set:
2021-06-29 22:09:02 +02:00
set {_res} to "%{nick.%{_uuid}%}%&7 (%{_player}%)"
2021-06-29 21:07:16 +02:00
else:
2021-06-29 22:09:02 +02:00
set {_res} to "%{_player}%"
2021-06-29 21:07:16 +02:00
return {_res}
2021-11-14 03:13:58 +01:00
# returns an "s" if arg "number" is higher than 1
function pluriel(int: number) :: text:
set {_pluriel} to ""
set {_pluriel} to "s" if {_int} > 1
return {_pluriel}
2021-07-02 03:01:13 +02:00
2021-11-14 03:13:58 +01:00
# reset the thimble game
2021-07-02 03:14:48 +02:00
function resetThimble(player: player):
set {_uuid} to uuid of {_player}
delete {thimble.dead.%{_uuid}%}