no me funciona un codigo que hago, alguien me lo podria arreglar porfa? soy muy novato y no se nada de programacion

cachin

Newbie
Apr 3, 2026
1
0
30
local is_flying = false
local is_noclip = false

function cmd_fly(msg)
if not (network_is_server() or network_is_moderator()) then
djui_chat_message_create("Error: Permisos de administrador requeridos.")
return true
end

is_flying = not is_flying
if is_flying then
djui_chat_message_create("\\#00ff00\\MODO ADMIN ACTIVADO")
djui_chat_message_create("\\#ffff00\\[A] Subir | [Z] Bajar | [R] Noclip | Salir")
else
is_noclip = false
djui_chat_message_create("\\#ff0000\\Modo admin desactivado.")
end
return true
end

function fly_logic(m)
if m.playerIndex ~= 0 or not is_flying then return end

-- BOTÓN B: Cancelar todo inmediatamente
if (m.controller.buttonPressed & B_BUTTON) ~= 0 then
is_flying = false
is_noclip = false
set_mario_action(m, ACT_FREEFALL, 0)
djui_chat_message_create("\\#ff0000\\Vuelo cancelado.")
return
end

-- BOTÓN R: Alternar Noclip
if (m.controller.buttonPressed & R_TRIG) ~= 0 then
is_noclip = not is_noclip
djui_chat_message_create(is_noclip and "\\#00ffff\\Noclip: ON" or "\\#00ffff\\Noclip: OFF")
end

-- ROTACIÓN: Forzar que Mario mire a donde apunta el Stick
if m.controller.stickMag > 2 then
m.faceAngle.y = m.intendedYaw
end

-- VELOCIDAD Y MOVIMIENTO
local speed = m.controller.stickMag * 1.5

-- Aplicar movimiento manual ignorando el motor de colisiones si noclip está ON
if is_noclip then
set_mario_action(m, ACT_DEBUG_FREE_MOVE, 0)
m.pos.x = m.pos.x + (math.sin(m.faceAngle.y / 32768 * math.pi) * speed)
m.pos.z = m.pos.z + (math.cos(m.faceAngle.y / 32768 * math.pi) * speed)
m.vel.x, m.vel.y, m.vel.z = 0, 0, 0
else
-- Vuelo normal con colisiones
set_mario_action(m, ACT_FREEFALL, 0)
set_mario_animation(m, MARIO_ANIM_FORWARD_SPINNING)
m.forwardVel = speed
end

-- ALTURA (A y Z)
if (m.controller.buttonDown & A_BUTTON) ~= 0 then m.pos.y = m.pos.y + 35 end
if (m.controller.buttonDown & Z_TRIG) ~= 0 then m.pos.y = m.pos.y - 35 end

-- Esto evita que el juego aplique gravedad mientras volamos
if not is_noclip then m.vel.y = 0 end
end

-- Hook de físicas para interceptar el movimiento antes que las paredes
hook_event(HOOK_BEFORE_PHYSICS_STEP, fly_logic)
hook_chat_command("fly", "Vuelo de administrador", cmd_fly)

Don't double post! Use that edit button! Post automatically merged:

es un codigo para que un admin pueda volar y traspasar paredes escribiendo /fly, tambien da un mini tutorial, el boton (A) es para que ascienda al volar, el boton (Z) para que baje, el boton (B) para que se detenga todo y el boton (R) para que pueda traspasar las paredes
 

Users who are viewing this thread