From 491b784661d24d0f31ac23c8621386d48884ce4c Mon Sep 17 00:00:00 2001 From: Ayase Minori Date: Mon, 19 Aug 2024 12:39:35 +0800 Subject: [PATCH] Upload Init hooks --- prejoin_hooks/README.md | 5 ++ prejoin_hooks/init.lua | 2 + prejoin_hooks/modules/pickup_hook.lua | 31 ++++++++++ prejoin_hooks/modules/use_hook.lua | 42 +++++++++++++ prejoin_hooks/util/tbl_utils.lua | 11 ++++ prejoin_hooks/util/use_hook_randomiser.lua | 72 ++++++++++++++++++++++ 6 files changed, 163 insertions(+) create mode 100644 prejoin_hooks/README.md create mode 100644 prejoin_hooks/init.lua create mode 100644 prejoin_hooks/modules/pickup_hook.lua create mode 100644 prejoin_hooks/modules/use_hook.lua create mode 100644 prejoin_hooks/util/tbl_utils.lua create mode 100644 prejoin_hooks/util/use_hook_randomiser.lua diff --git a/prejoin_hooks/README.md b/prejoin_hooks/README.md new file mode 100644 index 0000000..e428155 --- /dev/null +++ b/prejoin_hooks/README.md @@ -0,0 +1,5 @@ +# How to use? + +Drop this folder to your `lua/` folder and then set `lua_load_specific_files` to `prejoin_hooks/init.lua`. + +This only works on Metastruct servers. \ No newline at end of file diff --git a/prejoin_hooks/init.lua b/prejoin_hooks/init.lua new file mode 100644 index 0000000..e1c3b8a --- /dev/null +++ b/prejoin_hooks/init.lua @@ -0,0 +1,2 @@ +include("metastruct_specific/modules/pickup_hook.lua") +include("metastruct_specific/modules/use_hook.lua") diff --git a/prejoin_hooks/modules/pickup_hook.lua b/prejoin_hooks/modules/pickup_hook.lua new file mode 100644 index 0000000..8781914 --- /dev/null +++ b/prejoin_hooks/modules/pickup_hook.lua @@ -0,0 +1,31 @@ +-- original code by Aoki (@aoki.me) + +local prefixes = { + '/', + '!', + '.', +} + +hook.Add( 'OnPlayerChat', 'pickuper', function( ply, message ) + local usedPrefix = nil + + for _, prefix in ipairs( prefixes ) do + if string.StartWith( message, prefix ) then + usedPrefix = prefix + break + end + end + + if !usedPrefix then return end + local args = string.Explode( '%s+', string.sub( message, #usedPrefix + 1 ):lower(), true ) + + if args[1] == 'pickup' then + local target = easylua.FindEntity( args[2] ) + + if target != LocalPlayer() then return end + if !LocalPlayer():IsFriend( ply ) then return end + + RunConsoleCommand( 'aowl', 'goto', ply:SteamID64() ) + RunConsoleCommand( 'aowl', 'siton', ply:SteamID64() ) + end +end) \ No newline at end of file diff --git a/prejoin_hooks/modules/use_hook.lua b/prejoin_hooks/modules/use_hook.lua new file mode 100644 index 0000000..015d186 --- /dev/null +++ b/prejoin_hooks/modules/use_hook.lua @@ -0,0 +1,42 @@ +include("metastruct_specific/util/use_hook_randomiser.lua") +include("metastruct_specific/util/tbl_utils.lua") + +local lastTime = 0 +local pokeCount = 0 +local SPECIAL_UIDS = { 195868133, 48693720 } +local INPUT_COOLDOWN = false + +hook.Add("PlayerUsedByPlayer", "touched", function(target, aimer) + if lastTime + 0.1 > CurTime() or INPUT_COOLDOWN then return end + lastTime= CurTime() + + if pokeCount == 40 then + pokeCount = 0 + INPUT_COOLDOWN = true + print(string.format("%s triggered the limit!", aimer)) + + -- check if player is in the UID list + if tbl_utils.contains(SPECIAL_UIDS, aimer:AccountID()) then + interactions.interact(aimer, true) + + timer.Simple(4, function() + INPUT_COOLDOWN = false + end) + else + interactions.interact(aimer, false) + + timer.Simple(4, function() + INPUT_COOLDOWN = false + end) + end + else + pokeCount = pokeCount + 1 + RunConsoleCommand("actx", "poke") + + if tbl_utils.contains(SPECIAL_UIDS, aimer:AccountID()) then + RunConsoleCommand("saysound", "hi honey++29") + else + RunConsoleCommand("saysound", "hi honey#1--25 hi honey#1++75:pitch(-1)") + end + end +end) \ No newline at end of file diff --git a/prejoin_hooks/util/tbl_utils.lua b/prejoin_hooks/util/tbl_utils.lua new file mode 100644 index 0000000..4700c25 --- /dev/null +++ b/prejoin_hooks/util/tbl_utils.lua @@ -0,0 +1,11 @@ +tbl_utils = {} + + +tbl_utils.contains = function (table, element) + for _, value in pairs(table) do + if value == element then + return true + end + end + return false +end \ No newline at end of file diff --git a/prejoin_hooks/util/use_hook_randomiser.lua b/prejoin_hooks/util/use_hook_randomiser.lua new file mode 100644 index 0000000..e35df05 --- /dev/null +++ b/prejoin_hooks/util/use_hook_randomiser.lua @@ -0,0 +1,72 @@ +interactions = { + [1] = function(tp) + hook.Add("StartCommand", "impending_doom", function(ply, cmd) + local tgtAng = (tp:GetShootPos() - ply:GetShootPos()):GetNormalized():Angle() + + cmd:SetViewAngles(tgtAng) + end) + + timer.Simple(1.5, function() + RunConsoleCommand("actx", "shove") + RunConsoleCommand("hax", "nosound") + RunConsoleCommand("saysound", "you are hentai++40^999") + + hook.Remove("StartCommand", "impending_doom") + end) + end, + + [2] = function() + RunConsoleCommand("saysound", "i love you#5") + RunConsoleCommand("taunt", "IHeartYou") + end, + + [3] = function() + RunConsoleCommand("actx", "disagree") + RunConsoleCommand("saysound", "you are horny") + end, + + [4] = function(tp) + local amt = math.random(1, 10000) + SayLocal(":heart:") + SayLocal(string.format("!givecoins %s, %s", tp:GetName(), amt)) + end, + + [5] = function() + RunConsoleCommand("aowl", "killx", "1") + RunConsoleCommand("saysound", "kani:echo()^500") + + timer.Simple(4, function() + RunConsoleCommand("aowl", "revive") + RunConsoleCommand("saysound", "oh my gah#2") + end) + end, + + [6] = function(tp) + hook.Add("StartCommand", "impending_doom", function(ply, cmd) + local tgtAng = (tp:GetShootPos() - ply:GetShootPos()):GetNormalized():Angle() + + cmd:SetViewAngles(tgtAng) + end) + + RunConsoleCommand("taunt", "blow_kiss") + RunConsoleCommand("saysound", "elmo kiss") + + timer.Simple(3, function() + hook.Remove("StartCommand", "impending_doom") + end) + end +} + +interactions.interact = function(tp, isPlySpecial) + local rnd = math.random(#interactions) + local res = interactions[rnd] + + if isPlySpecial then + while rnd % 2 ~= 0 do + rnd = math.random(#interactions) + res = interactions[rnd] + end + end + + res(tp) +end \ No newline at end of file