spindash script

redhot69

amongus
smh i cant make a spindash that works if c1 is pressed
"eof" expected near end

addHook("PlayerThink", function(p)
if (p.mo.skin == "sonic")
and (p.cmd.buttons & BT_CUSTOM1)
and P_IsObjectOnGround(player.mo)
and not (p.mo.eflags & MFE_UNDERWATER)
and not (p.mo.state == S_PLAY_PAIN)
and not (p.mo.state == S_PLAY_DEAD)
and not (p.mo.state == S_PLAY_DRWN)
p.charging = true
p.mo.state = S_PLAY_SPINDASH
S_StartSound(p.mo, sfx_spndsh)
end
end)

if P_IsObjectOnGround(player.mo)
and (p.mo.state == S_PLAY_SPINDASH)
and (p.mo.skin == "sonic")
and not (p.cmd.buttons & BT_CUSTOM1)
and not (p.mo.eflags & MFE_UNDERWATER)
p.charging = false
p.release = true
p.mo.state = S_PLAY_ROLL
P_Thrust(p.mo, p.mo.angle, 20*FRACUNIT)
S_StartSound(p.mo, sfx_zoom)
end
end)

addHook("PlayerThink", function(p)
if (p.mo.skin == "sonic")
and (p.cmd.buttons & BT_CUSTOM1)
and P_IsObjectOnGround(player.mo)
and (p.mo.eflags & MFE_UNDERWATER)
and not (p.mo.state == S_PLAY_PAIN)
and not (p.mo.state == S_PLAY_DEAD)
and not (p.mo.state == S_PLAY_DRWN)
p.charging = true
p.mo.state = S_PLAY_SPINDASH
S_StartSound(p.mo, sfx_spndsh)
end
end
if P_IsObjectOnGround(player.mo)
and (p.mo.state == S_PLAY_SPINDASH)
and (p.mo.skin == "sonic")
and (p.mo.eflags & MFE_UNDERWATER)
and not (p.mo.state == S_PLAY_PAIN)
and not (p.mo.state == S_PLAY_DEAD)
and not (p.mo.state == S_PLAY_DRWN)
p.charging = false
p.release = true
p.mo.state = S_PLAY_ROLL
P_Thrust(p.mo, p.mo.angle, 10*FRACUNIT)
S_StartSound(p.mo, sfx_zoom)
end
end)
Lua:
addHook("PlayerThink", function(p)
if (p.mo.skin == "sonic")
and (p.cmd.buttons & BT_CUSTOM1)
and P_IsObjectOnGround(player.mo)
and not (p.mo.eflags & MFE_UNDERWATER)
and not (p.mo.state == S_PLAY_PAIN)
and not (p.mo.state == S_PLAY_DEAD)
and not (p.mo.state == S_PLAY_DRWN)
p.charging = true
p.mo.state = S_PLAY_SPINDASH
S_StartSound(p.mo, sfx_spndsh)
end
end)

if P_IsObjectOnGround(player.mo)
and (p.mo.state == S_PLAY_SPINDASH)
and (p.mo.skin == "sonic")
and not (p.cmd.buttons & BT_CUSTOM1)
and not (p.mo.eflags & MFE_UNDERWATER)
p.charging = false
p.release = true
p.mo.state = S_PLAY_ROLL
P_Thrust(p.mo, p.mo.angle, 20*FRACUNIT)
S_StartSound(p.mo, sfx_zoom)
end
end)

addHook("PlayerThink", function(p)
if (p.mo.skin == "sonic")
and (p.cmd.buttons & BT_CUSTOM1)
and P_IsObjectOnGround(player.mo)
and (p.mo.eflags & MFE_UNDERWATER)
and not (p.mo.state == S_PLAY_PAIN)
and not (p.mo.state == S_PLAY_DEAD)
and not (p.mo.state == S_PLAY_DRWN)
p.charging = true
p.mo.state = S_PLAY_SPINDASH
S_StartSound(p.mo, sfx_spndsh)
end
end
if P_IsObjectOnGround(player.mo)
and (p.mo.state == S_PLAY_SPINDASH)
and (p.mo.skin == "sonic")
and (p.mo.eflags & MFE_UNDERWATER)
and not (p.mo.state == S_PLAY_PAIN)
and not (p.mo.state == S_PLAY_DEAD)
and not (p.mo.state == S_PLAY_DRWN)
p.charging = false
p.release = true
p.mo.state = S_PLAY_ROLL
P_Thrust(p.mo, p.mo.angle, 10*FRACUNIT)
S_StartSound(p.mo, sfx_zoom)
end
end)
 
Last edited:
"eof expected near end" usually means you're missing an "end" to close an "if". Sadly I can't make out anything from the code you've pasted.

See that "</>" near the middle-top of the reply area? Press that, and paste your code inside it, it'll handle the indentations.

Though I'm guessing the second...uh....paragraph... is outside of the first addHook block, and that's causing problems. Try deleting the ) at the end of the first paragraph.
 
While not strictly necessary to have your code work, I implore you, please ident your code, it'll make it easier for you to work through errors and help people tenfold when they're trying to help you with your code snippets.

What I caught here was two cases of certain sections of your code being outside of the addHook function; that aside, there was also a few cases where you were referencing to a variable called players (that is nil), when the variable you're using for players inside the hook is p so I also took the liberty of changing that as well.

Fix?:
addHook("PlayerThink", function(p)
    if (p.mo.skin == "sonic")
    and (p.cmd.buttons & BT_CUSTOM1)
    and P_IsObjectOnGround(p.mo)
    and not (p.mo.eflags & MFE_UNDERWATER)
    and not (p.mo.state == S_PLAY_PAIN)
    and not (p.mo.state == S_PLAY_DEAD)
    and not (p.mo.state == S_PLAY_DRWN) then
        p.charging = true
        p.mo.state = S_PLAY_SPINDASH
        S_StartSound(p.mo, sfx_spndsh)
    end
   
    if P_IsObjectOnGround(p.mo)
    and (p.mo.state == S_PLAY_SPINDASH)
    and (p.mo.skin == "sonic")
    and not (p.cmd.buttons & BT_CUSTOM1)
    and not (p.mo.eflags & MFE_UNDERWATER) then
        p.charging = false
        p.release = true
        p.mo.state = S_PLAY_ROLL
        P_Thrust(p.mo, p.mo.angle, 20*FRACUNIT)
        S_StartSound(p.mo, sfx_zoom)
    end
end)
   
addHook("PlayerThink", function(p)
    if (p.mo.skin == "sonic")
    and (p.cmd.buttons & BT_CUSTOM1)
    and P_IsObjectOnGround(p.mo)
    and (p.mo.eflags & MFE_UNDERWATER)
    and not (p.mo.state == S_PLAY_PAIN)
    and not (p.mo.state == S_PLAY_DEAD)
    and not (p.mo.state == S_PLAY_DRWN) then
        p.charging = true
        p.mo.state = S_PLAY_SPINDASH
        S_StartSound(p.mo, sfx_spndsh)
    end

    if P_IsObjectOnGround(p.mo)
    and (p.mo.state == S_PLAY_SPINDASH)
    and (p.mo.skin == "sonic")
    and (p.mo.eflags & MFE_UNDERWATER)
    and not (p.mo.state == S_PLAY_PAIN)
    and not (p.mo.state == S_PLAY_DEAD)
    and not (p.mo.state == S_PLAY_DRWN) then
        p.charging = false
        p.release = true
        p.mo.state = S_PLAY_ROLL
        P_Thrust(p.mo, p.mo.angle, 10*FRACUNIT)
        S_StartSound(p.mo, sfx_zoom)
    end
end)

It's not spewing any errors in the console but I'm also unsure if the results is what you were expecting.
 
its great
While not strictly necessary to have your code work, I implore you, please ident your code, it'll make it easier for you to work through errors and help people tenfold when they're trying to help you with your code snippets.

What I caught here was two cases of certain sections of your code being outside of the addHook function; that aside, there was also a few cases where you were referencing to a variable called players (that is nil), when the variable you're using for players inside the hook is p so I also took the liberty of changing that as well.

Fix?:
addHook("PlayerThink", function(p)
    if (p.mo.skin == "sonic")
    and (p.cmd.buttons & BT_CUSTOM1)
    and P_IsObjectOnGround(p.mo)
    and not (p.mo.eflags & MFE_UNDERWATER)
    and not (p.mo.state == S_PLAY_PAIN)
    and not (p.mo.state == S_PLAY_DEAD)
    and not (p.mo.state == S_PLAY_DRWN) then
        p.charging = true
        p.mo.state = S_PLAY_SPINDASH
        S_StartSound(p.mo, sfx_spndsh)
    end
  
    if P_IsObjectOnGround(p.mo)
    and (p.mo.state == S_PLAY_SPINDASH)
    and (p.mo.skin == "sonic")
    and not (p.cmd.buttons & BT_CUSTOM1)
    and not (p.mo.eflags & MFE_UNDERWATER) then
        p.charging = false
        p.release = true
        p.mo.state = S_PLAY_ROLL
        P_Thrust(p.mo, p.mo.angle, 20*FRACUNIT)
        S_StartSound(p.mo, sfx_zoom)
    end
end)
  
addHook("PlayerThink", function(p)
    if (p.mo.skin == "sonic")
    and (p.cmd.buttons & BT_CUSTOM1)
    and P_IsObjectOnGround(p.mo)
    and (p.mo.eflags & MFE_UNDERWATER)
    and not (p.mo.state == S_PLAY_PAIN)
    and not (p.mo.state == S_PLAY_DEAD)
    and not (p.mo.state == S_PLAY_DRWN) then
        p.charging = true
        p.mo.state = S_PLAY_SPINDASH
        S_StartSound(p.mo, sfx_spndsh)
    end

    if P_IsObjectOnGround(p.mo)
    and (p.mo.state == S_PLAY_SPINDASH)
    and (p.mo.skin == "sonic")
    and (p.mo.eflags & MFE_UNDERWATER)
    and not (p.mo.state == S_PLAY_PAIN)
    and not (p.mo.state == S_PLAY_DEAD)
    and not (p.mo.state == S_PLAY_DRWN) then
        p.charging = false
        p.release = true
        p.mo.state = S_PLAY_ROLL
        P_Thrust(p.mo, p.mo.angle, 10*FRACUNIT)
        S_StartSound(p.mo, sfx_zoom)
    end
end)

It's not spewing any errors in the console but I'm also unsure if the results is what you were expecting.
i think i can fix the rest
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top