Results 1 to 7 of 7
  1. #1
    Keepo123's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    m͏̺͓̲̥̪is̷t̞̖͍͚̤k̥B̸̼&#81
    Posts
    84
    Reputation
    10
    Thanks
    163
    My Mood
    Yeehaw

    Player Follow script [lua]

    Just a script to follow the closest player

    pretty cool for trolling in darkrp

    Code:
    local should_follow = CreateClientConVar( "follow", "0")
    local should_draw = CreateClientConVar( "follow_draw", "1")
    local follow_team = CreateClientConVar( "follow_team", "0", true, false, "0 follow any team, 1 follow same team as localplayer, 2 follow opposite team as localplayer")
    
    
    function is_movement_keys_down()
    	return input.IsButtonDown( 33 ) or input.IsButtonDown( 65 ) or input.IsButtonDown( 11 ) or input.IsButtonDown( 29 ) or input.IsButtonDown( 14 )
    end
    
    
    function moveToPos(cmd, pos)
    	local world_forward = pos - LocalPlayer():GetPos()
    	local ang_LocalPlayer = cmd:GetViewAngles()
    
    	cmd:SetForwardMove( ( (math.sin(math.rad(ang_LocalPlayer[2]) ) * world_forward[2]) + (math.cos(math.rad(ang_LocalPlayer[2]) ) * world_forward[1]) ) * 300 )
    	cmd:SetSideMove( ( (math.cos(math.rad(ang_LocalPlayer[2]) ) * -world_forward[2]) + (math.sin(math.rad(ang_LocalPlayer[2]) ) * world_forward[1]) ) * 300 )
    end
    
    
    function closest_player(team)
    	best = 99999999
    	current_e = nil
    	for k, v in pairs(player.GetAll()) do
    		dist = v:GetPos():Distance(LocalPlayer():GetPos())
    		if LocalPlayer():Alive() and v:Alive() and v ~= LocalPlayer() and dist < best and v:Health() > 0 and v:GetObserverMode() == 0 then
    			if team == nil then
    				best = dist
    				current_e = v
    			elseif not team and LocalPlayer():Team() ~= v:Team() then
    				best = dist
    				current_e = v
    			elseif team and LocalPlayer():Team() == v:Team() then
    				best = dist
    				current_e = v
    			end
    		end
    	end
    	return current_e
    end
    
    local target = nil
    hook.Add("CreateMove", "PlayerFollow", function(cmd)
    	if should_follow:GetInt() == 1 then
    		if is_movement_keys_down() then return end
    		
    		if follow_team:GetInt() == 0 then
    			target = closest_player()
    		elseif follow_team:GetInt() == 1 then
    			target = closest_player(true)
    		elseif follow_team:GetInt() == 2 then
    			target = closest_player(false)
    		end
    		
    		if not target then return end
    		moveToPos(cmd, target:GetPos())
    	end
    end)
    
    hook.Add("HUDPaint", "PlayerFollow_Draw", function()
    	if should_follow:GetInt() == 1 and should_draw:GetInt() == 1 then
    		local pos = target:GetPos():ToScreen()
    		surface.DrawCircle( pos["x"], pos["y"], 7, 0, 255, 0)
    	end
    end)
    https://streamable.com/i04ie

    console commands
    Code:
    follow - 0 is off, 1 is on
    follow_draw,  0 is off, 1 is on
    follow_team, 0 follow any and all teams, 1 follow same team as localplayer, 2 follow opposite team as localplayer
    Last edited by Ally; 09-23-2019 at 05:05 AM.

  2. #2
    Ally's Avatar
    Join Date
    Dec 2014
    Gender
    female
    Location
       ♥
    Posts
    8,697
    Reputation
    1610
    Thanks
    8,499
    My Mood
    Angelic
    //approved

    Premium Member 22/4/16
    Steam Minion 22/12/2017
    OFPS Minion 5/2/2019
    MMO Minion 5/2/2019
    Minion+ 5/2/2019
    Mod 8/11/2020
    Retired 3/10/2022
    22 / Dec 7, 2001

  3. #3
    SemixOfficial's Avatar
    Join Date
    Aug 2018
    Gender
    male
    Location
    Czech Republic
    Posts
    4
    Reputation
    10
    Thanks
    0
    My Mood
    Lonely
    Quite interesting little script but why not just make simple blockbot instead ?

    Many people will just run behind a prop at which point you will get stuck with this since there's no actual pathfinding or obstacle avodation in the code.

    Note: You forgot dormant check

  4. #4
    Keepo123's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    m͏̺͓̲̥̪is̷t̞̖͍͚̤k̥B̸̼&#81
    Posts
    84
    Reputation
    10
    Thanks
    163
    My Mood
    Yeehaw
    Quote Originally Posted by SemixOfficial View Post
    Quite interesting little script but why not just make simple blockbot instead ?

    Many people will just run behind a prop at which point you will get stuck with this since there's no actual pathfinding or obstacle avodation in the code.

    Note: You forgot dormant check

    You can comment out
    Code:
    cmd:SetForwardMove( ( (math.sin(math.rad(ang_LocalPlayer[2]) ) * world_forward[2]) + math.cos(math.rad(ang_LocalPlayer[2]) ) * world_forward[1]) ) * 300 )
    and it'll act like a block bot.

    yeah it's to tricky to get stuck behind a prop if you're right on the player, unless it's a door or they spawn a prop to block you, but then you can just manually press W A S D or space and it'll stop the following the target while you're pressing the keys,

    and yeah oops, wish I could edit my thread w/o having to contact a mod, cba

  5. #5
    Sexiest Anime's Avatar
    Join Date
    Aug 2019
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    My Mood
    Goofy
    Can u add a blockbot because what u told us to do didnt work

  6. #6
    Alisonver's Avatar
    Join Date
    Aug 2019
    Gender
    female
    Location
    Honduras
    Posts
    16
    Reputation
    10
    Thanks
    0

    Player Follow script lua

    So, I decided to post my first lua script because it helped me a lot to play with mutiples Tibia Clients. Its a really basic script to follow other players.

    Commands:

    follow "player name"
    start
    stop

    If you are following one player and wants to follow another one, you must stop it first then use the command follow again.

    Code:

  7. #7
    MamieMit's Avatar
    Join Date
    Sep 2019
    Gender
    female
    Location
    Egypt
    Posts
    2
    Reputation
    10
    Thanks
    0

    Player Follow script lua

    How do I kill a script in lua?

    Example:

    For start script:

    dofile"name.lua"

    And for stop script?

    Sorry my bad english.

    I resolved with the following code:

    loadSettings"name settings", "All"

Similar Threads

  1. [Release] Player Gear Script
    By Blah121 in forum DayZ Mod & Standalone Hacks & Cheats
    Replies: 8
    Last Post: 02-23-2013, 03:50 AM
  2. Player Controller Script
    By Shadowyfaze in forum DayZ Discussion
    Replies: 8
    Last Post: 01-23-2013, 09:40 AM
  3. i need change colur player esp script
    By seabkai in forum DayZ Mod & Standalone Hacks & Cheats
    Replies: 2
    Last Post: 10-21-2012, 05:33 PM
  4. SERVER FOR BANNED PLAYERS AND SCRIPT TESTER!!!
    By cobra0702 in forum DayZ Mod & Standalone Hacks & Cheats
    Replies: 7
    Last Post: 10-18-2012, 12:50 PM
  5. [Request] Player camo script
    By St4rkz in forum DayZ Mod & Standalone Hacks & Cheats
    Replies: 3
    Last Post: 08-04-2012, 12:37 PM