Forum

> > CS2D > Scripts > 3 Small scripts?
Forums overviewCS2D overview Scripts overviewLog in to reply

English 3 Small scripts?

5 replies
To the start Previous 1 Next To the start

old 3 Small scripts?

zazz
User Off Offline

Quote
Hey usnrealsoftware, i'd like to ask you help on making me 3 small scripts for my map if possible
Well, i don't think if this is possible with lua but here we go:

• If any NPC crosses Tile 122x181 and 123x181 it will automatically die, it's like a team gate, but only for NPCs
• Round time limit 14 minutes.
• When there's only 1 terrorist alive, the script will trigger
some dynwalls, other things called
1
"only1"

Make it on this script if possible.

Spoiler >


Thanks

old Re: 3 Small scripts?

RIP-HereRestsPlookerbooy
BANNED Off Offline

Quote
There's not way to detect NPC movements but I'll try to help you...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
unwalkable = {{122,181},{123,181}}

LastTerrorist = false

addhook("startround_prespawn","ripdaniel_prespawn")
function ripdaniel_prespawn()
    LastTerrorist = false
end

addhook("ms100","ripdaniel_ms100")
function ripdaniel_ms100()
	for _,id in pairs(object(0,"table")) do
		for k,v in pairs(unwalkable) do
			if object(id,"tilex") == unwalkable[k][1] and object(id,"tiley") == unwalkable[k][2] then
				parse("killobject "..id)
			end
		end
	end
	if #player(0,"team1living") == 1 and LastTerrorist == false then -- 1 terrorist alive
		LastTerrorist = true
		-- Your script
	end
end

another "end" for kenpachi

Tested and worked

EDIT : First time I got ninja'd
edited 3×, last 08.02.16 10:17:27 pm

old Re: 3 Small scripts?

Cure Pikachu
User Off Offline

Quote
For Standard & Zombies! gamemode - Round time can be set using a console command: cs2d cmd mp_roundtime 14
Otherwise:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
roundtimelimit = 14
roundtime = 0

addhook("startround_prespawn","_start")
function _start()
	roundtime = 0
end

addhook("second","_sec")
-- second hook is used instead of minute to accommodate for potential freeze time and HUDs
function _sec()
	roundtime = roundtime + 1
	if roundtime >= roundtimelimit * 60 + tonumber(game("mp_freezetime")) then
		parse("endround 0")
	end
end
For the "trigger when only 1 terrorist is alive" code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hasactivated = false

addhook("startround_prespawn","_start2")
function _start2()
	hasactivated = false
end

addhook("ms100","_ms100")
function _ms100()
	if not hasactivated then
		if #player(0,"team1living") == 1 then
			parse("trigger only1")
			-- or whatever it is you are trying to trigger
			hasactivated = true
		end
	end
end
edited 1×, last 08.02.16 10:54:24 pm

old Re: 3 Small scripts?

zazz
User Off Offline

Quote
Thanks alot for your help guys.
There are some problems.

@user Cure Pikachu:
Only 1 script worked perfectly.. buut..
Roundtime limit script doesn't work, yeah i know i can do mp_roundtime 14, but it's for other server :v

× [18:25:20] LUA ERROR: maps/zAzz_Jail v1.4.lua:67: attempt to perform arithmetic on global 'roundtime' (a nil value)

@user RIP-HereRestsPlookerbooy: Thanks, but for some reason when when i put it in the codes whole script doesn't work o.o

old Re: 3 Small scripts?

zazz
User Off Offline

Quote
Everything works now, thank you guys!
edited 1×, last 08.02.16 11:27:05 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview