Forum

> > CS2D > Scripts > Hostage Dead = Round End?!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Hostage Dead = Round End?!

7 replies
To the start Previous 1 Next To the start

moved Hostage Dead = Round End?!

HoOtix
User Off Offline

Quote
Is there anyway to make the round end/restart when a hostage dies depending on the amount that you want, for example... 3 hostages need to be rescued, 1 dies mission failed.. Or you can set it so a specific amount of hostages die, the round ends... For example.. 4 hostages, 2 dies mission failed, if 1 dies doesnt matter.... Anyway possible? Please tell meh! Thank you!

old Re: Hostage Dead = Round End?!

useigor
User Off Offline

Quote
This script count hostage kills via cs2d lua hook attack & cs2d lua hook attack2 and cs2d lua cmd player "hostagekills". I don't guarantee no bugs.

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
parse("restart")

addhook("startround","nakelo_obla")
function nakelo_obla(mode)
	-- if restarted (game annulled player hostage kills)
	if mode==5 then
		-- Amount of killed hostages; initial level of hostage kills; player hostage kills
		mert_tal = 0
		mert_tal_urv = 0
		igraq_tal = {}
	-- set initial level of hostage kills
	else
		mert_tal_urv = mert_tal
	end
end

addhook("attack","napad")
function napad(id)
	ubistvo_tal(id)
end

addhook("attack2","napad2")
function napad2(id)
	ubistvo_tal(id)
end

-- check hostage kills for some player
function ubistvo_tal(id)
	-- if never killed then set 0
	if not igraq_tal[id] then
		igraq_tal[id] = 0
	end
	-- if table is outdated <-- player killed hostage(s)
	if igraq_tal[id] ~= player(id,"hostagekills") then
		-- add amount of new killed hostage(s)
		mert_tal = mert_tal + player(id,"hostagekills") - igraq_tal[id]
		-- update table
		igraq_tal[id] = player(id,"hostagekills")
	end
	-- check amount of killed hostages
	if igraq_tal[id] - mert_tal_urv >= 2 then
		parse("endround 0")
	end
end

old Re: Hostage Dead = Round End?!

GeoB99
Moderator Off Offline

Quote
You must create a text file, copy the code, paste it and change the extension of the file into .lua (but it might be hard for you) so i recommend for you to use Notepad++.
After that you must do these things:
> Move the lua script file in cs2d folder/sys/lua and paste it
> Go to server.lua of the lua folder and write the dofile to activate the script (note this thing is not important if you put the script in autorun).

To write the dofile you must write like this:
1
dofile("sys/lua/yourscriptname.lua")
And to prevent the script to work (deactivating it) you must write these lines -- before the dofile like --dofile (this is just an additional help).

Then after, open CS2D, click new game and you're done.

old Re: Hostage Dead = Round End?!

Mami Tomoe
User Off Offline

Quote
user HoOtix has written
How do I use this? Lol sorry Im a scirpt noob

1. Open notepad
2. Copy and paste all of the code
3. click CTRL+S
4. Change the "Text Documents (*.txt)" to All files
5. Name it to: Hostage.lua
6. Place it in *CS2D FOLDER*/sys/lua/autorun/

[OPTIONAL] If you don't have autorun folder CREATE IT

old Re: Hostage Dead = Round End?!

HoOtix
User Off Offline

Quote
Is there anyway that I can make it different for each map? Let's say I have 2 maps, and They both have 4 hostages, and I wanna make both hostage death counts different without changing the script everytime... Is it possible?

Admin/mod comment

No need to quote the user above you /user useigor

old Re: Hostage Dead = Round End?!

Cure Pikachu
User Off Offline

Quote
It's possible.

1. Take the script that is given by user useigor (Copy & Paste) and modify values if needed for one map.
2. Save the file in your *CS2D root folder*\maps folder under the name *map name*.lua, where *map name* is the name for that particular map (without the .map extension)
3. Repeat step 1 & 2 for any remaining maps that you need this script applied on.
4. Before you start the server, make sure cs2d cmd mp_luamap is set to 1 in your server settings.

old Re: Hostage Dead = Round End?!

useigor
User Off Offline

Quote
You can also use this way (you need to paste this in the script):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- Map list with specific hostage kills
carta_tal = {cs_office = 3, cs_assault = 1}

-- Check current map
for carta,tal in pairs(carta_tal) do
	if carta==map("name") then
		c_tal = tal
	end
end

-- If current map is not listed
if not c_tal then
	c_tal = 2
end

'2' must be replaced by 'c_tal' in 41 line
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview