Forum

> > CS2D > Scripts > if Player Stop then Die?
Forums overviewCS2D overview Scripts overviewLog in to reply

English if Player Stop then Die?

10 replies
To the start Previous 1 Next To the start

old if Player Stop then Die?

Rygna
User Off Offline

Quote
Hello!
here furty

> How to make if player stop then die/dead.
i mean.. If you stop ( No walking / running ) you got die/dead by server.

if you know plase.. give me example / file
btw.. thanks.
× Sorry for my English Error!!

old Re: if Player Stop then Die?

J192
User Off Offline

Quote
Check the player's position every frame. If the player's position in the next frame is the same as the previous frame, then kill that player.

Just translate what I said into code.

old Re: if Player Stop then Die?

Ridho
User Off Offline

Quote
Idk it works or no, actually players will die on each spawn

1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("second","test_")
function test_(id)
   locx=player(id,"x")
   locy=player(id,"y")
   sec=sec+1
   if sec==1 then
      local x=player(id,"x")
      local y=player(id,"y")
      if x=player(id,"x") and y=player(id,"y") then
         parse("killplayer "..id)
      end
   sec=0
   end
end

old Re: if Player Stop then Die?

Apache uwu
User Off Offline

Quote
You could check everyone's location every microsecond/second, and if their position is unchanged -- kill them.

I think the second hook would be more lenient towards people with higher ping. If someone has lag spikes, their position would be frozen for a few moments -- and then they'd get killed by the script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
addhook("second", "_second")
addhook("spawn", "_spawn")
addhook("move", "_move")

local positions = {}
local active    = {}

function _spawn(id)
    active[id] = false
end

function _move(id, x, y, walk)
    active[id] = true
end

function _second()
    for _, v in pairs(player(0,"tableliving")) do
        if active[v]       == true           and
           positions[v]    ~= nil            and
           positions[v][1] == player(v, "x") and
           positions[v][2] == player(v, "y") then
               parse("killplayer " .. v)
        end
        positions[v] = {player(v, "x"), player(v, "y")}
    end
end
edited 1×, last 07.06.15 06:26:55 am

old Re: if Player Stop then Die?

J192
User Off Offline

Quote
@user Apache uwu: Seems like checking every second is a lot better choice than what I said.

However, I think the 5-second delay every spawn would be a bit inconsistent since players can move and stop for several seconds. Instead, the stop=kill thingy should be triggered when the player starts moving or attacking, if possible.

old Thanks!

Rygna
User Off Offline

Quote
@user Apache uwu:
WoW! , that work :D!
but why if i stop walking/running must wait 1 - 3 Sec and die/dead ?
> i want if player stop walking/running.. they instant die/dead. <
but. , anyway Thanks for your scripts that work!

old Re: if Player Stop then Die?

Apache uwu
User Off Offline

Quote
@user Rygna: Try the new script, it only kills them after they start initially moving (as user J192 suggested).

Also the reason behind killing players per second (as opposed to killing them per frame or ms100) is because players on live servers will generally have pings ranging from 100-300. During these time gaps, their position on the server is unchanged. If you used a faster hook, you'll find that players will start dying, even if they think they're moving constantly.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview