I want to get modder for uploading mods and more. my first mod I'm going to add is this mod
-- name: TP by X button
-- description: if you use the X button you tp to the closest player | by l-Sr64Rayman-l
local TELEPORT_BUTTON = X_BUTTON -- the button to tp the player if you can't see
local function nearest_player(m)
local best, bestDist = nil, nil
for i = 0, MAX_PLAYERS - 1 do
if i ~= m.playerIndex and gNetworkPlayers.connected then
local o = gMarioStates
local dx = o.pos.x - m.pos.x
local dy = o.pos.y - m.pos.y
local dz = o.pos.z - m.pos.z
local d = dx*dx + dy*dy + dz*dz
if bestDist == nil or d < bestDist then
best, bestDist = i, d
end
end
end
return best
end
local function update()
local m = gMarioStates[0] -- 0 you
if m.playerIndex ~= 0 then return end
local pressed = m.controller.buttonPressed
if (pressed & TELEPORT_BUTTON) ~= 0 then
local target = nearest_player(m)
if target ~= nil then
local o = gMarioStates[target]
m.pos.x = o.pos.x
m.pos.y = o.pos.y + 20 -- a bit above by the +
m.pos.z = o.pos.z
m.vel.x, m.vel.y, m.vel.z = 0, 0, 0
end
end
end
hook_event(HOOK_UPDATE, update)
btw looks good on mine and i post its buged
-- name: TP by X button
-- description: if you use the X button you tp to the closest player | by l-Sr64Rayman-l
local TELEPORT_BUTTON = X_BUTTON -- the button to tp the player if you can't see
local function nearest_player(m)
local best, bestDist = nil, nil
for i = 0, MAX_PLAYERS - 1 do
if i ~= m.playerIndex and gNetworkPlayers.connected then
local o = gMarioStates
local dx = o.pos.x - m.pos.x
local dy = o.pos.y - m.pos.y
local dz = o.pos.z - m.pos.z
local d = dx*dx + dy*dy + dz*dz
if bestDist == nil or d < bestDist then
best, bestDist = i, d
end
end
end
return best
end
local function update()
local m = gMarioStates[0] -- 0 you
if m.playerIndex ~= 0 then return end
local pressed = m.controller.buttonPressed
if (pressed & TELEPORT_BUTTON) ~= 0 then
local target = nearest_player(m)
if target ~= nil then
local o = gMarioStates[target]
m.pos.x = o.pos.x
m.pos.y = o.pos.y + 20 -- a bit above by the +
m.pos.z = o.pos.z
m.vel.x, m.vel.y, m.vel.z = 0, 0, 0
end
end
end
hook_event(HOOK_UPDATE, update)
btw looks good on mine and i post its buged