Forum

> > CS2D > Scripts > mp_randomspawn with lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English mp_randomspawn with lua

5 replies
To the start Previous 1 Next To the start

old mp_randomspawn with lua

Nori-chan
User Off Offline

Quote
Hello guys.
I trying to add something simple in my script:
- When the round starts, mp_randomspawn will be 0. And after 10 seconds, mp_randomspawn will be 1. And it will be 0 on every round start.

My simple code:

Spoiler >


PS: the "seccs" is the number of seconds.

thank you guys for helping me.

old Re: mp_randomspawn with lua

VADemon
User Off Offline

Quote
cs2d lua cmd timer

1
2
3
4
5
addhook("startround","spawnn_")
function spawnn_()
     parse("mp_randomspawn 0")
     timer(10000, "parse", "mp_randomspawn 1")
end

old Re: mp_randomspawn with lua

Nori-chan
User Off Offline

Quote
user VADemon has written
cs2d lua cmd timer

1
2
3
4
5
addhook("startround","spawnn_")
function spawnn_()
     parse("mp_randomspawn 0")
     timer(10000, "parse", "mp_randomspawn 1")
end


Just tested it, but it looks like it doesn't work.
Even through it doesn't give any errors.

EDIT: Nevermind, it's working
But, I don't know why, but when I create a server, only after the first round, the randonspawn code works.
edited 3×, last 01.08.13 03:12:02 am

old Re: mp_randomspawn with lua

UnkN
User Off Offline

Quote
parse("restart") paste the following
function startround. Or copy parse, timer from hook and past at script begin.

old Re: mp_randomspawn with lua

Nori-chan
User Off Offline

Quote
user UnkN has written
parse("restart") paste the following
function startround. Or copy parse, timer from hook and past at script begin.


Thank you for the answer.
I did something different here, but it gave the same results.
So yeah, thank you again for helping me.

old Re: mp_randomspawn with lua

VADemon
User Off Offline

Quote
user Nori-chan has written
But, I don't know why, but when I create a server, only after the first round, the randonspawn code works.

Because you used the normal startround hook. For this cs2d lua hook startround_prespawn hook is needed.

Completely fixed code:
1
2
3
4
5
addhook("startround_prespawn","spawnn_")
function spawnn_()
     parse("mp_randomspawn 0")
     timer(10000, "parse", "mp_randomspawn 1")
end

With standard hook the randomspawn==ONE for the first wave of spawning (except its ZERO on first round)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview