#auth skript script options: $ init com.mysql.jdbc.Driver $ db url jdbc:mysql://localhost:3306/minecraft $ db username root $ db password root #core on load: clear {playerList::*} on join: add player to {playerList::*} on quit: remove player from {playerList::*} #auth variables: {auth.LoggedIn::%player%} = false on quit: if {auth.LoggedIn::%player%} is true: update "UPDATE users SET last_position_x = '%x-coordinate of player%', last_position_y = '%y-coordinate of player%', last_position_z = '%z-coordinate of player%' WHERE nickname = '%player%'" on join: set {_ar::*} to objects in column "register_date" from result of query "SELECT register_date FROM users WHERE nickname = '%player%'" and close set {_ar::%player%} to "%{_ar::*}%" if {_ar::%player%} is not "": set {auth.Registered::%player%} to true else: set {auth.Registered::%player%} to false if {auth.Remember::%player%} is true: #pobierz ip set {_ip::*} to objects in column "addres" from result of query "SELECT addres FROM users WHERE nickname = '%player%'" and close set {_ip} to "%{_ip::*}%" if "%{_ip}%" is player's ip: set {auth.LoggedIn::%player%} to true send "&8* &aZostales zalogowany automatycznie!" send "&8* &eJezeli chcesz wylaczyc automatyczne logowanie, wpisz: &8/&eremember!" stop else: set {auth.LoggedIn::%player%} to false else: set {auth.LoggedIn::%player%} to false every 10 ticks: loop {playerList::*}: if {auth.LoggedIn::%loop-value%} is false: if distance between {auth.SpawnLocation} and location of loop-value > 0.25: teleport loop-value to {auth.SpawnLocation} every 3 real seconds: loop {playerList::*}: if {auth.LoggedIn::%loop-value%} is false: if {auth.Registered::%loop-value%} is false: send "&8* &fZarejestruj sie: &8/&eregister &8<&ehaslo&8> &8<&ehaslo&8>" to loop-value else: send "&8* &fZaloguj sie: &8/&elogin &8<&ehaslo&8>" to loop-value on break: if {auth.LoggedIn::%player%} is false: cancel event on build: if {auth.LoggedIn::%player%} is false: cancel event on drop: if {auth.LoggedIn::%player%} is false: cancel event on pickup: if {auth.LoggedIn::%player%} is false: cancel event on chat: if {auth.LoggedIn::%player%} is false: cancel event on command: if executor is player: if {auth.LoggedIn::%player%} is false: if command is not "register" or "login": cancel event command /register [] []: trigger: if arg-1 is set: if arg-2 is set: if arg-2 is arg-1: #znajdz uid set {_su::*} to objects in column "count(uid)" from result of query "SELECT count(uid) FROM users" and close set {_su} to "%{_su::*}%" parsed as number set {_su} to {_su} + 1 #hash set {_hash} to hashed arg-2 #zarejestruj update "INSERT INTO users (uid, nickname, uuid, password, register_date, last_logged, last_position_x, last_position_y, last_position_z, addres) VALUES ('%{_su}%', '%player%', '%player's uuid%', '%{_hash}%', '%now%', '%now%', '', '', '', '')" send "&8* &aPomyslnie zostal zarejestrowany" set {auth.Registered::%player%} to true set {auth.LoggedIn::%player%} to true clear {_hash} stop else: send "&8* &cPodane hasla nie pasuja do siebie!" stop else: send "&8* &cPowtorz haslo!" stop else: send "&8* &cPodaj haslo!" stop command /login []: trigger: if {auth.Registered::%player%} is true: if {auth.LoggedIn::%player%} is false: set {_dp::*} to objects in column "password" from result of query "SELECT password FROM users WHERE nickname = '%player%'" and close set {_dp} to "%{_dp::*}%" if hashed arg-1 is "%{_dp}%": set {auth.LoggedIn::%player%} to true #zaktualizuj ostatnio zalogowanego update "UPDATE users SET last_logged = '%now%' WHERE nickname = '%player%'" #pobierz ostatnia lokalizacje set {_xloc::*} to objects in column "last_position_x" from result of query "SELECT last_position_x FROM users WHERE nickname = '%player%'" and close set {_yloc::*} to objects in column "last_position_y" from result of query "SELECT last_position_y FROM users WHERE nickname = '%player%'" and close set {_zloc::*} to objects in column "last_position_z" from result of query "SELECT last_position_z FROM users WHERE nickname = '%player%'" and close set {_xloc} to "%{_xloc::*}%" parsed as number set {_yloc} to "%{_yloc::*}%" parsed as number set {_zloc} to "%{_zloc::*}%" parsed as number set {_lp} to location {_xloc}, {_yloc}, {_zloc} in world "world" teleport player to {_lp} send "&8* &aZostales zalogowany!" send "&8* &eJezeli chcesz wlaczyc automatycznie logowanie, wpisz: &8/&eremember!" stop else: send "&8* &cZle haslo!" stop else: send "&8* &cJestes juz zalogowany!" stop else: send "&8* &cNie jestes zarejestrowany!" stop command /auth []: trigger: if player have permission "auth.usage": if arg-1 is "setspawn": set {auth.SpawnLocation} to location of player set {auth.XLocation} to x-coordinate of player set {auth.YLocation} to y-coordinate of player set {auth.ZLocation} to z-coordinate of player send "&8* &aPomyslnie ustawiles miejsce spawnu &8(&eauth&8)" stop else: send "&8* &cNie masz dostepu!" stop command /remember []: trigger: if {auth.LoggedIn::%player%} is true: if {auth.Remember::%player%} is false: update "UPDATE users SET addres = '%player's ip%' WHERE nickname = '%player%'" set {auth.Remember::%player%} to true send "&8* &aAutomatyczne logowanie zostalo wlaczone!" stop else: update "UPDATE users SET addres = '' WHERE nickname = '%player%'" set {auth.Remember::%player%} to false send "&8* &eAutomatyczne logowanie zostalo wylaczone!" stop