player_stickyjump_timers = {}; player_stickyjump_rgb = {}; timer_length = 0.01; color_increment = 15; function ColorPlayer(player) local userid = player:GetUserId(); local red = player_stickyjump_rgb[userid]["r"]; local green = player_stickyjump_rgb[userid]["g"]; local blue = player_stickyjump_rgb[userid]["b"]; if ( red == 255 and blue == 0 and green < 255 ) then if ( green + color_increment > 255 ) then player_stickyjump_rgb[userid]["g"] = 255; else player_stickyjump_rgb[userid]["g"] = green + color_increment; end elseif ( red > 0 and blue == 0 and green == 255 ) then if ( red - color_increment < 0 ) then player_stickyjump_rgb[userid]["r"] = 0; else player_stickyjump_rgb[userid]["r"] = red - color_increment; end elseif ( red == 0 and green == 255 and blue < 255 ) then if ( blue + color_increment > 255 ) then player_stickyjump_rgb[userid]["b"] = 255; else player_stickyjump_rgb[userid]["b"] = blue + color_increment; end elseif ( red == 0 and green > 0 and blue == 255 ) then if ( green - color_increment < 0 ) then player_stickyjump_rgb[userid]["g"] = 0; else player_stickyjump_rgb[userid]["g"] = green - color_increment; end elseif ( red < 255 and green == 0 and blue == 255 ) then if ( red + color_increment > 255 ) then player_stickyjump_rgb[userid]["r"] = 255; else player_stickyjump_rgb[userid]["r"] = red + color_increment; end elseif ( red == 255 and green == 0 and blue > 0 ) then if ( blue - color_increment < 0 ) then player_stickyjump_rgb[userid]["b"] = 0; else player_stickyjump_rgb[userid]["b"] = blue - color_increment; end end player:AcceptInput("color", string.format("%d %d %d", red, green, blue)); end function EventStickyJump(event) local player = ents.GetPlayerByUserId(event.userid); if ( not player_stickyjump_timers[event.userid] ) then player_stickyjump_timers[event.userid] = timer.Create(timer_length, ColorPlayer, 0, player); player_stickyjump_rgb[event.userid] = {r=255, g=0, b=0}; end return ACTION_CONTINUE; end function ClearPlayerVars(userid) if ( not ents.GetPlayerByUserId(userid) ) then return end; if ( player_stickyjump_timers[userid] ) then timer.Stop(player_stickyjump_timers[userid]); player_stickyjump_timers[userid] = nil; end local player = ents.GetPlayerByUserId(userid); player:AcceptInput("color", "255 255 255"); end function EventStickyJumpLand(event) ClearPlayerVars(event.userid); return ACTION_CONTINUE; end function EventPlayerSpawn(event) ClearPlayerVars(event.userid); return ACTION_CONTINUE; end AddEventCallback("sticky_jump", EventStickyJump); AddEventCallback("sticky_jump_landed", EventStickyJumpLand); AddEventCallback("player_spawn", EventPlayerSpawn); AddEventCallback("landed", function() util.PrintToChatAll("LANDED!"); end); player_movement_keys = {}; player_te_timers = {}; for i, t in pairs({player_stickyjump_timers, player_te_timers}) do if (t) then for k, v in pairs(t) do timer.Stop(v); end t = {} end end local function IsPlayerWalking(player) local userid = player:GetUserId(); if (not player or not player_movement_keys[userid]) then return false; end local is_moving = false; for k, v in pairs(player_movement_keys[userid]) do if (v) then is_moving = true; break; end end if ( is_moving and player.movetype == MOVETYPE_WALK and player.m_fFlags & FL_ONGROUND == 1) then return true; else return false; end end local function GetTimerDelay(player) if ( not player or not player.m_iClass ) then return 0.25; end local class = player.m_iClass; if ( class == TF_CLASS_SCOUT ) then return 0.15; elseif ( class == TF_CLASS_SOLDIER ) then return 0.3; elseif ( class == TF_CLASS_PYRO ) then return 0.25; elseif ( class == TF_CLASS_DEMOMAN ) then return 0.25; elseif ( class == TF_CLASS_HEAVYWEAPONS ) then return 0.2; elseif ( class == TF_CLASS_ENGINEER ) then return 0.25; elseif ( class == TF_CLASS_MEDIC ) then return 0.25; elseif ( class == TF_CLASS_SNIPER ) then return 0.25; elseif ( class == TF_CLASS_SPY ) then return 0.25; else return 0.25; end end local function CreateTETimer(tbl, player) local userid = player:GetUserId(); if ( not tbl[userid] ) then tbl[userid] = timer.Create(GetTimerDelay(player), function() local origin = player:GetAbsOrigin(); origin.z = origin.z + 8; tempents.Send("GaussExplosion", {m_vecOrigin=origin, m_nType=2, m_vecDirection=Vector(0, 0, 10)}, nil); --util.PrintToChatAll("Spawning tempent"); end, 0) end end player_te_backup_timer = timer.Create(0.5, function() for i, p in pairs(ents.GetAllPlayers()) do local userid = p:GetUserId(); --p:IsRealPlayer() and if (not player_te_timers[userid] and IsPlayerWalking(p)) then CreateTETimer(player_te_timers, p); end end end, 0) function OnPlayerConnected(player) --if (not player:IsRealPlayer()) then return end local userid = player:GetUserId(); if ( not player_movement_keys[userid] ) then player_movement_keys[userid] = { [IN_FORWARD]=false, [IN_BACK]=false, [IN_MOVELEFT]=false, [IN_MOVERIGHT]=false }; end player:AddCallback(ON_KEY_PRESSED, function(entity, key) local origin = player:GetAbsOrigin(); local modelindex = player.m_nModelIndex; if ( key == IN_DUCK ) then -- -1500, -575, 318 tempents.Send("Show Line", {m_vecOrigin=Vector(-1500, -575, 318), m_vecEnd=Vector(-1500, -600, 318)}, nil); return end if ( table.HasValue({IN_FORWARD, IN_BACK, IN_MOVELEFT, IN_MOVERIGHT}, key) ) then player_movement_keys[userid][key] = true; end if ( IsPlayerWalking(player) ) then CreateTETimer(player_te_timers, player); end end) player:AddCallback(ON_KEY_RELEASED, function(entity, key) local origin = player:GetAbsOrigin(); if ( table.HasValue({IN_FORWARD, IN_BACK, IN_MOVELEFT, IN_MOVERIGHT}, key) ) then player_movement_keys[userid][key] = false; end if ( not IsPlayerWalking(player) and player_te_timers[userid] ) then timer.Stop(player_te_timers[userid]) player_te_timers[userid] = nil; end end) end function OnPlayerDisconnected(player) local userid = player:GetUserId(); player_movement_keys[userid] = nil; timer.Stop(player_te_timers[userid]); end