Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Name: "sh_typing.lua".
- Author: "Chessnut".
- ]]--
- if ( SERVER ) then
- --A console command for when the player starts typing.
- concommand.Add("player_type_start", function(player, command, arguments)
- if ( player:IsValid() ) then
- player:SetNetworkedBool("shTyping", true);
- end;
- end;
- --A console command for when the player has stopped typing.
- concommand.Add("player_type_stop", function(player, command, arguments)
- if ( playerIsValid() ) then
- player:SetNetworkedBool("shTyping", false);
- end;
- end;
- else
- --A hook for when the player starts typing.
- hook.Add("StartChat", "chatStart", function()
- RunConsoleCommand("player_type_start");
- end);
- --A hook for when the player is done typing.
- hook.Add("FinishChat", "chatStop", function()
- RunConsoleCommand("player_type_stop");
- end);
- --A function to draw the typing display.
- hook.Add("HUDPaint", function(player)
- if ( LocalPlayer():Alive() and LocalPlayer():Alive() ) then
- local fadeDistance = 128;
- -- Check if the player is alive.
- if ( player:Alive() ) then
- if ( player != LocalPlayer() ) then
- if (!player._KnockedOut) then
- if ( player:GetNetworkedBool("isTyping") ) then
- local alpha = math.Clamp(255 - ( (255 / fadeDistance) * player:GetShootPos():Distance( LocalPlayer():GetShootPos() ) ), 0, 255);
- -- Define the x and y position.
- local x = player:GetShootPos():ToScreen().x;
- local y = player:GetShootPos():ToScreen().y - 64;
- -- Check if the position is visible.
- if (player:GetShootPos():ToScreen().visible) then
- y = y + (32 * (LocalPlayer():GetShootPos():Distance( player:GetShootPos() ) / fadeDistance)) * 0.5;
- -- Draw the information.
- draw.SimpleTextOutlined("TEST", "ChatFont", x, y + math.sin( CurTime() ) * 8, Color(0, 0, 0, alpha), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 5, Color(255, 255, 255, alpha);
- end;
- end;
- end;
- end;
- end;
- end;
- end);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement