﻿ Unreal Software - Thread: Longshot Script

# Forum

CS2D Scripts Longshot Script

# Longshot Script

8 replies
Goto Page
1
31.03.12 06:42:40 am
XSmoker
User
Offline
Can anyone make a script that by killing a player without seeing, in the center of the screen appears a message saying, Player Killed distance!

Sorry for error!
31.03.12 06:52:18 am
archmage
User
Offline
I guess by "without seeing" you mean offscreen so...

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
local longshot_distsq = 640^2 + 480^2 + 32

function longshot_kill(k,v)
local x, y, x2, y2
x = player(k, "x"); y = player(k, "y")
x2 = player(v, "x"); y2 = player(v, "y")

local distsq = (x2 - x)^2 + (y2 - y)^2
if ( distsq >= longshot_distsq ) then
msg2(k, "Longshot!");
end
end
We must secure the existence of our people and a future for white children. 14/88
31.03.12 09:25:39 am
asdbanana
User
Offline
archmage has written:
I guess by "without seeing" you mean offscreen so...

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
local longshot_distsq = 640^2 + 480^2 + 32

function longshot_kill(k,v)
local x, y, x2, y2
x = player(k, "x"); y = player(k, "y")
x2 = player(v, "x"); y2 = player(v, "y")

local distsq = (x2 - x)^2 + (y2 - y)^2
if ( distsq >= longshot_distsq ) then
msg2(k, "Longshot!");
end
end

Hey! I Wanna have this one aswell but idk how do make it work!? Help please?, Message me!
31.03.12 10:10:48 am
DannyDeth
User
Offline
@TheArchMage:
Your script is really quite crappy. Distance function is wrong, will be like half way across some maps and the shot will still not count as a distance shot.
Code:
1
2
3
4
5
6
7
8
function longshot(victim,killer,wpn,hpdmg)
if(hpdmg >= player(victim,"health")) then
if( ( player(victim,"x")-player(killer,"x") > 680 or player(victim,"x")-player(killer,"x") < -680 ) ) or ( player(victim,"x")-player(killer,"y") > 520 or player(victim,"y")-player(killer,"y") < -520 ) ) then
end
end
end
31.03.12 07:45:28 pm
archmage
User
Offline
@Danny
I thought I could leave out the sqrt and save an insignificant amount of time. If I checked like this: dist^2 >= lshot_dist^2

Fixed code:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
local longshot_distsq = (320^2 + 240^2 + 32)^0.5

function longshot_kill(k,v)
local x, y, x2, y2
x = player(k, "x"); y = player(k, "y")
x2 = player(v, "x"); y2 = player(v, "y")

local distsq = ((x2 - x)^2 + (y2 - y)^2)^0.5
if ( distsq >= longshot_distsq ) then
msg2(k, "Longshot!");
end
end
We must secure the existence of our people and a future for white children. 14/88
31.03.12 08:01:02 pm
DC
Offline
@ archmage: you can't use this method because the screen is a rectangle (assumed that we are really talking about seeing/not seeing the victim). it would work if your screen is a circle but it isn't. it's very imprecise that way.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
31.03.12 08:10:54 pm
Apache uwu
User
Offline
So would this work?

Code:
1
2
3
4
5
6
7

function _kill(killer,victim,weapon,x,y)
if math.abs(player(killer,"x")-x)>320 or math.abs(player(killer,"y")-y)>240 then
msg2(killer,"Longshot!")
end
end
31.03.12 08:24:03 pm
Chex
User
Offline
Apache uwu has written:
So would this work?

Code:
1
2
3
4
5
6
7

function _kill(killer,victim,weapon,x,y)
if math.abs(player(killer,"x")-x)>320 or math.abs(player(killer,"y")-y)>240 then
msg2(killer,"Longshot!")
end
end

Who needs a sig?
01.04.12 01:25:57 am
XSmoker
User
Offline
Apache uwu has written:
So would this work?

Code:
1
2
3
4
5
6
7