Forum

> > CS2D > Scripts > Prevent spawn
Forums overviewCS2D overview Scripts overviewLog in to reply

English Prevent spawn

16 replies
To the start Previous 1 Next To the start

old Prevent spawn

KoJKa
BANNED Off Offline

Quote
How to prevent spawn?
That is if pl_clos[id] then not spawn
1
2
3
4
5
6
7
8
9
10
11
12
13
pl_closed = {}

addhook("join","join_")
function join_(id)
pl_closed[id]=true
end

addhook("spawn","spawn_")
function spawn_(id)
if pl_closed[id] then
--not spawn
end
end

old Re: Prevent spawn

Masea
Super User Off Offline

Quote
Why u opened same thread for 2 times. Please delete other one.

old Re: Prevent spawn

Pseudon
User Off Offline

Quote
Maybe... standard mode + kill and remove death and then a custom spawn?

old Re: Prevent spawn

Talented Doge
User Off Offline

Quote
There is a thing called post spawn join time or something like that, players joining after that will be dead and have to wait for the next game.

old Re: Prevent spawn

KoJKa
BANNED Off Offline

Quote
Need gamemode deathmath .
and i not want wait time(max 255 i`m want unlimited)

old Re: Prevent spawn

Talented Doge
User Off Offline

Quote
Then prevent them joining the team instead of prevent them spawning.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
started = false

addhook("startround", "_st")
addhook("endround", "_end")
addhook("team", "_t")

function _st()
	started = true
end

function _end()
	started = false
end

function _t(p)
	if started then msg2(p, "You cannot join now!") return 1 end
end

old Re: Prevent spawn

KoJKa
BANNED Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pl_closed = {}

addhook("join","join_")
function join_(id)
pl_closed[id]=false
end

addhook("die","die_")
function die_(victim)
pl_closed[victim]=true
end

addhook("spawn","spawn_")
function spawn_(id)
if pl_closed[id] then
--not spawn
end
end
edited 1×, last 10.08.15 02:15:00 pm

old Re: Prevent spawn

Talented Doge
User Off Offline

Quote
If you really have to make the ones who are dead couldn't spawn, what's the point of deathmatch?

Instead, please make them spectators.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("startround", "_st")
addhook("die", "_d")
addhook("team", "_t")

function _st()
     for _, id in pairs(player(0, "table")) do
		parse("makect "..id)
	end
end

function _t(p, t)
	if player(p, "team") == 0 then return 1 end
end

function _d(k, v)
	parse("makespec "..v)
end
edited 2×, last 10.08.15 02:53:33 pm

old Re: Prevent spawn

KoJKa
BANNED Off Offline

Quote
I want create new gamemode.
I don't need what they would become spectators.

old Re: Prevent spawn

GeoB99
Moderator Off Offline

Quote
Why did you add --not spawn near if line? With "--not spawn" you don't do anything with it, you can delete it because is useless.
Moreover, you can't create a new gamemode in any way, unless you customize something a bit but the rest is almost impossible to do that.

The only solution (although is unlikely you'll accept it) is to use the cs2d lua cmd timer in order to prevent someone to spawn fast. For that you have to define how ms (milliseconds) you want for the time. So, you can define a long timer like 1500000 ms (=25 minutes) for the timer as an example. I'm not sure though if it'll create problems settling a high ms but that's the only way to prevent, there aren't other alternatives.

By the way: Your code, also, is not tabbed which makes it less understable. Using tabs, makes your script more easy to understand, instead to suffocating yourself reading it more times.
edited 1×, last 10.08.15 02:44:04 pm

old Re: Prevent spawn

DC
Admin Off Offline

Quote
It's not directly possible to prevent players from spawning.
Making them spectators like user Talented Doge suggested is actually a good solution because spectators can't spawn at all.

If spectators are no option for you for some reason then you might do something - probably - even more ugly like:

• Make it impossible to move with cs2d cmd speedmod
• Teleport the player to an area where he can't participate in the actual game with cs2d cmd setpos
• Kill the player again instantly or shortly after respawn with cs2d cmd killplayer

old Re: Prevent spawn

Talented Doge
User Off Offline

Quote
I believe the second option user DC suggested would be best. Where the players can still move but they can't play in the real game. Just like MIA in TTT.

old Re: Prevent spawn

KoJKa
BANNED Off Offline

Quote
hmm... Good idea!
Thanks DC !!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
closed_zone = {[1]=30,
                      [2]=50}
pl_closed = {}

addhook("join","join_")
function join_(id)
pl_closed[id]=false
end

addhook("die","die_")
function die_(victim)
pl_closed[victim]=true
end

addhook("spawn","spawn_")
function spawn_(id)
if pl_closed[id] then
parse("setpos "..id.." "..closed_zone[1].." "..closed_zone[2])
end
end

P.S. This is the only example

old Re: Prevent spawn

Talented Doge
User Off Offline

Quote
The die hook should consist of at least two components, because you want the victim to be set, not the killer.

The die hook and kill hook share the same structure: killer, victim, weapon, x, y

So you should write function die_(killer, victim) instead.

old Re: Prevent spawn

The Gajos
BANNED Off Offline

Quote
You may use tilex and tiley instead of x and y:
closed_zone[?] * 32 + 16

Then if you set tile [4,5], it will be [144,176].
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview