COM_AddCommand
.local function ChangeValue(p, field)
--all the fields are strings in a command
--need to use tonumber() if you're trying to set a numerical value
if (field ~= nil) then
p.customvalue = tonumber(field)
end
end
--"commandname" can be any name you want
COM_AddCommand("commandname", ChangeValue)
local function ChangeValue(p, field, otherfield, otherotherfield)
addHook("PlayerThink", function(player)
if player.shouldairwalk == nil then
player.shouldairwalk = false
end
if player.airwalklength == nil then
player.airwalklength = 1*TICRATE
end
if player.airwalk == nil then
player.airwalk = 0
end
if player.airwalked == nil then
player.airwalked = false
end
if player.willtakedamage == nil then
player.willtakedamage = false
end
if player.shouldntairwalk == nil then
player.shouldntairwalk = false
end
if player.falling == nil then
player.falling = false
end
if player.secondchance == nil then
player.secondchance = 0*TICRATE
end
if player.stopaction == nil then
player.stopaction = false
end
if (player.mo.eflags & MFE_UNDERWATER)
or (player.mo.eflags & MFE_SPRUNG)
or player.mo.state == S_PLAY_ROLL
or player.mo.state == S_PLAY_PAIN
or (player.pflags & PF_THOKKED)
or (player.playerstate == PST_DEAD) then
player.falling = false
player.willtakedamage = false
player.shouldntairwalk = true
end
if (P_IsObjectOnGround(player.mo) == false)
and player.shouldairwalk == true
and not (player.pflags & PF_JUMPED) then
player.airwalk = player.airwalklength
player.shouldairwalk = false
end
if (P_IsObjectOnGround(player.mo) == true) then
player.shouldairwalk = true
player.airwalk = 0*TICRATE
player.airwalked = false
player.shouldntairwalk = false
player.falling = false
player.secondchance = 0*TICRATE
player.stopaction = false
end
if (P_IsObjectOnGround(player.mo) == false)
and player.airwalk > -1 then
player.airwalk = $ - 1
end
if not P_IsObjectOnGround(player.mo)
and player.secondchance > -1 then
player.secondchance = $ - 1
end
if player.airwalk > 0
and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.mo.momz < 1
and player.shouldntairwalk == false then
player.airwalked = true
player.mo.state = S_PLAY_RUN
player.mo.momz = 0
end
if player.airwalk > 0
and player.stopaction == false
and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT < 128
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.airwalked == false
and (P_IsObjectOnGround(player.mo) == false) then
player.secondchance = 2
player.stopaction = true
end
if player.secondchance > 0
and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.shouldntairwalk == false then
player.airwalk = player.airwalklength
end
if player.airwalk < 0
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.shouldntairwalk == false
and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128
and player.falling == false then
player.mo.momz = 10*FRACUNIT
player.falling = true
player.mo.state = S_PLAY_DEAD
S_StartSound(player.mo, sfx_s3k51)
end
if player.airwalk > 0
and player.airwalk <= 7
and (player.cmd.buttons & BT_JUMP)
and player.shouldntairwalk == false then
player.shouldntairwalk = true
player.mo.momz = 10*FRACUNIT
player.pflags = $|PF_JUMPED|PF_THOKKED
player.mo.state = S_PLAY_JUMP
S_StartSound(player.mo, sfx_jump)
end
if player.falling == true
and player.mo.momz > -25*FRACUNIT then
player.mo.momz = $ - 1*FRACUNIT/2
end
if player.falling == true
and player.mo.momz < -25*FRACUNIT then
player.willtakedamage = true
end
if player.willtakedamage == true
and player.mo.momz > 0 then
player.willtakedamage = false
player.falling = false
player.shouldntairwalk = true
end
if player.willtakedamage == true
and (P_IsObjectOnGround(player.mo) == true) then
P_DamageMobj(player.mo)
S_StartSound(player.mo, sfx_doord2)
player.willtakedamage = false
player.mo.momz = -1*FRACUNIT
end
end)
local function ChangeValue(player, airwalk)
--all the fields are strings in a command
--need to use tonumber() if you're trying to set a numerical value
if (field ~= nil) then
player.airwalklength = tonumber(field)*TICRATE
end
end
--"commandname" can be any name you want
COM_AddCommand("airwalk", ChangeValue, COM_ADMIN)
and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128
and player.mo.z - player.mo.floorz > 128*FRACUNIT
local function airwalkSetup(player)
player.shouldairwalk = false
player.airwalklength = 1*TICRATE
player.airwalk = 0
player.airwalked = false
player.willtakedamage = false
player.shouldntairwalk = false
player.falling = false
player.secondchance = 0*TICRATE
player.stopaction = false
player.airwalksetup = true
end
addHook("PlayerSpawn", airwalkSetup)
addHook("PlayerThink", function(player)
if not player.airwalksetup then
airwalkSetup(player)
end
if (player.mo.eflags & MFE_UNDERWATER)
or (player.mo.eflags & MFE_SPRUNG)
or player.mo.state == S_PLAY_ROLL
or player.mo.state == S_PLAY_PAIN
or (player.pflags & PF_THOKKED)
or (player.playerstate == PST_DEAD) then
player.falling = false
player.willtakedamage = false
player.shouldntairwalk = true
end
if (P_IsObjectOnGround(player.mo) == false)
and player.shouldairwalk == true
and not (player.pflags & PF_JUMPED) then
player.airwalk = player.airwalklength
player.shouldairwalk = false
end
if (P_IsObjectOnGround(player.mo) == true) then
player.shouldairwalk = true
player.airwalk = 0*TICRATE
player.airwalked = false
player.shouldntairwalk = false
player.falling = false
player.secondchance = 0*TICRATE
player.stopaction = false
end
if (P_IsObjectOnGround(player.mo) == false)
and player.airwalk > -1 then
player.airwalk = $ - 1
end
if not P_IsObjectOnGround(player.mo)
and player.secondchance > -1 then
player.secondchance = $ - 1
end
if player.airwalk > 0
and player.mo.z - player.mo.floorz > 128*FRACUNIT
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.mo.momz < 0
and player.shouldntairwalk == false then
player.airwalked = true
player.mo.state = S_PLAY_RUN
player.mo.momz = 0
end
if player.airwalk > 0
and player.stopaction == false
and player.mo.z - player.mo.floorz < 128*FRACUNIT
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.airwalked == false
and (P_IsObjectOnGround(player.mo) == false) then
player.secondchance = 2
player.stopaction = true
end
if player.secondchance > 0
and player.mo.z - player.mo.floorz > 128*FRACUNIT
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.shouldntairwalk == false then
player.airwalk = player.airwalklength
end
if player.airwalk < 0
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_THOKKED)
and player.shouldntairwalk == false
and player.mo.z - player.mo.floorz > 128*FRACUNIT
and player.falling == false then
player.mo.momz = 10*FRACUNIT
player.falling = true
player.mo.state = S_PLAY_DEAD
S_StartSound(player.mo, sfx_s3k51)
end
if player.airwalk > 0
and player.airwalk <= 7
and (player.cmd.buttons & BT_JUMP)
and player.shouldntairwalk == false then
player.shouldntairwalk = true
player.mo.momz = 10*FRACUNIT
player.pflags = $|PF_JUMPED|PF_THOKKED
player.mo.state = S_PLAY_JUMP
S_StartSound(player.mo, sfx_jump)
end
if player.falling == true
and player.mo.momz > -25*FRACUNIT then
player.mo.momz = $ - 1*FRACUNIT/2
end
if player.falling == true
and player.mo.momz < -25*FRACUNIT then
player.willtakedamage = true
end
if player.willtakedamage == true
and player.mo.momz > 0 then
player.willtakedamage = false
player.falling = false
player.shouldntairwalk = true
end
if player.willtakedamage == true
and (P_IsObjectOnGround(player.mo) == true) then
P_DamageMobj(player.mo)
S_StartSound(player.mo, sfx_doord2)
player.willtakedamage = false
player.mo.momz = -1*FRACUNIT
end
end)
local function ChangeValue(player, field)
--all the fields are strings in a command
--need to use tonumber() if you're trying to set a numerical value
if (field ~= nil) then
player.airwalklength = tonumber(field)*TICRATE
end
end
--"commandname" can be any name you want
COM_AddCommand("airwalk", ChangeValue, COM_ADMIN)