Forum

> > CS2D > Scripts > [Request] Pushing players
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Request] Pushing players

20 replies
Page
To the start Previous 1 2 Next To the start

old Re: [Request] Pushing players

EP
User Off Offline

Quote
This works better than the other one:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function math.pointfollow(x,y,rot,speed)
	return x-math.sin(rot-3.14)*speed,y-math.cos(rot-3.14)*speed
end
function math.dist(x1,y1,x2,y2) 
	local xx = x2-x1
	local yy = y2-y1
	return math.sqrt(xx^2+yy^2)
end
addhook("move","a")
function a(id,x,y)
	local pls = player(0,"tableliving")
	for _,i in ipairs(pls) do
		if i ~= id then
			if player(i,"exists") then
				if math.dist(player(id,"x"),player(id,"y"),player(i,"x"),player(i,"y")) <= 25 then
					local rot = math.atan2(player(id,"x") - player(i,"x"),player(id,"y") - player(i,"y"))
					local xx,yy = math.pointfollow(player(id,"x"),player(id,"y"),rot-math.rad(180),-5)
					parse("setpos "..id.." "..xx.." "..yy)
				end
			end
		end
	end
end
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview