sfan5 wrote:Utilisatrice wrote:Script work 100%.
But maybe you should do a command indicating that the player no longer have afk.
Exemple :
/afk => Utilisatrice is now afk.
When i type /afk again => Utilisatrice do not have afk.
Good Idea
Done:
spawn = {x = 50, y = 1, z = 92}
minetest.register_on_chat_message(function(name, message, playername, player)
local cmd = "/spawn"
if message:sub(0, #cmd) == cmd then
if message == '/spawn' then
local player = minetest.env:get_player_by_name(name)
minetest.chat_send_player(player:get_player_name(), "Teleporting to spawn...")
player:setpos(spawn)
return true --deds to sfan5
end
end
local cmd ="/afk"
if message:sub(0, #cmd) == cmd then
if message == '/afk' then
local player = minetest.env:get_player_by_name(name)
minetest.chat_send_all(name.." is AFK! ")
return true --deds to sfan5
end
end
local cmd ="/not afk"
if message:sub(0, #cmd) == cmd then
if message == '/not afk' then
local player = minetest.env:get_player_by_name(name)
minetest.chat_send_all(name.." is NOT AFK! ")
return true --added by AnFiadhChu
end
end
end)
--Deds to Kahrl
minetest.register_on_newplayer(function(player)
player:setpos(spawn)
return true
end)
--Deds to Kahrl
minetest.register_on_respawnplayer(function(player, pos)
player:setpos(spawn)
return true
end)