Forum

> > CS2D > Scripts > Prevent spawn
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Prevent spawn

16 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Prevent spawn

KoJKa
BANNED Off Offline

Zitieren
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

alt Re: Prevent spawn

Masea
Super User Off Offline

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

alt Re: Prevent spawn

Talented Doge
User Off Offline

Zitieren
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.

alt Re: Prevent spawn

KoJKa
BANNED Off Offline

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

alt Re: Prevent spawn

Talented Doge
User Off Offline

Zitieren
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

alt Re: Prevent spawn

KoJKa
BANNED Off Offline

Zitieren
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
1× editiert, zuletzt 10.08.15 14:15:00

alt Re: Prevent spawn

Talented Doge
User Off Offline

Zitieren
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
2× editiert, zuletzt 10.08.15 14:53:33

alt Re: Prevent spawn

KoJKa
BANNED Off Offline

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

alt Re: Prevent spawn

GeoB99
Moderator Off Offline

Zitieren
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.
1× editiert, zuletzt 10.08.15 14:44:04

alt Re: Prevent spawn

DC
Admin Off Offline

Zitieren
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

alt Re: Prevent spawn

Talented Doge
User Off Offline

Zitieren
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.

alt Re: Prevent spawn

KoJKa
BANNED Off Offline

Zitieren
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

alt Re: Prevent spawn

Talented Doge
User Off Offline

Zitieren
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.

alt Re: Prevent spawn

The Gajos
BANNED Off Offline

Zitieren
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].
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht