Forum

> > CS2D > Scripts > Script Request
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Script Request

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Script Request

Jarago
User Off Offline

Zitieren
hi all!
well im working on another map and i need simple script (i hope its simple)... well im not scripter and i dont like scripting so...

Script:
When player dies - Random Custom Death Sound will run (of 3)...
and also specific sound file will run.

Thx and sry for bad english

alt Re: Script Request

Apache uwu
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
sounds={
	"player/die1.wav",
	"player/die2.wav",
	"player/die3.wav"
}

addhook("die","_die")

function _die(id)
	parse("sv_sound \""..sounds[math.random(#sounds)].."\"")
	parse("sv_sound \"another_sound.wav\"")
end

You can also change cs2d cmd sv_sound to cs2d cmd sv_sound2.

alt Re: Script Request

Jarago
User Off Offline

Zitieren
thx
and is it possible to disable any other sounds when player dies? there are some sound loops in map...

alt Re: Script Request

EP
User Off Offline

Zitieren
@user Jarago: I do not think so that is possible to disable the default sounds of the game. But if it's annoying to hear lots of sounds at same time (when playing with much users) you can use this script that just allows to sound to the players that are in a specific range.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sounds={
     "player/die1.wav",
     "player/die2.wav",
     "player/die3.wav"
}

distance = 300 

addhook("die","_die")
function _die(id)
	for _,pl in ipairs(player(0,"table")) do
		local x = (player(pl,"x") - player(id,"x"))^2
		local y = (player(pl,"y") - player(id,"y"))^2
		local dist = math.sqrt(x + y)
		if dist < distance then
			parse("sv_sound2 "..pl.." "..sounds[math.random(#sounds)])
			parse("sv_sound2 "..pl.." anothersound.wav")
		end
	end
end
You can change the distance (in pixels) if you want.

alt Re: Script Request

Jarago
User Off Offline

Zitieren
i mean custom sounds added to map with env_sound...
its adventure map and while playing, env_sound song loop is running. And when player dies, this loop or any other env_sound in map will disable so player can hear only death sound + short death song...
but after death song, all env_sounds will be enabled again...

well... maybe it is not possible, ill add only death sounds then...
1× editiert, zuletzt 24.06.12 22:38:31

alt Re: Script Request

EP
User Off Offline

Zitieren
Yeah it is possible, but you have to trigger that sound (It has to have a name) via the CS2D Script.

alt Re: Script Request

Jarago
User Off Offline

Zitieren
ok, i used only death sounds for now, thx for script

Ok, i need one more script... when player enters target trigger_move, text shows up on screen "Boss" and his health. It disapears when boss is dead. Boss is currently one of NPC´s and i want to see his health when fighting him. Is it possible?
1× editiert, zuletzt 27.06.12 09:50:14

alt Re: Script Request

Infinite Rain
Reviewer Off Offline

Zitieren
user Apache uwu hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
12
sounds={
	"player/die1.wav",
	"player/die2.wav",
	"player/die3.wav"
}

addhook("die","_die")

function _die(id)
	parse("sv_sound \""..sounds[math.random(#sounds)].."\"")
	parse("sv_sound \"another_sound.wav\"")
end

You can also change cs2d cmd sv_sound to cs2d cmd sv_sound2.

You didn't seed the random function, make it otherwise it wll be NOT random at all

alt Re: Script Request

Apache uwu
User Off Offline

Zitieren
It's still random, it will just be the same on every start of the game--which no one will really care anyway, there are only 3 sound files.

alt Re: Script Request

omg
User Off Offline

Zitieren
user Alistaire hat geschrieben
It is not possible. You can't make a healthbar for a generic NPC.

lol yeah u can

1
2
3
4
object(0,"table")--table of all dynamic object id's, includes npcs
object(id,"typename")--has the value of "NPC" if its a default npc
object(id,"type")--the specific number for an npc (all zombies are type 30, etc)
object(id,"health")--the hp of the npc, of course
other:
object(id,"x"), object(id,"y"), object(id,"tilex"), and object(id,"tiley") can be used to locate the object, if u dont know its dynamic id (provided there arent other objects in range that the boss can be confused with)

then u only have to think about how to display the hp

this can be accomplished easily by using hudtxt2 with players in the boss area + with images which i dislike

alt Re: Script Request

Alistaire
User Off Offline

Zitieren
user omg hat geschrieben
user Alistaire hat geschrieben
It is not possible. You can't make a healthbar for a generic NPC.

lol yeah u can

1
2
3
4
object(0,"table")--table of all dynamic object id's, includes npcs
object(id,"typename")--has the value of "NPC" if its a default npc
object(id,"type")--the specific number for an npc (all zombies are type 30, etc)
object(id,"health")--the hp of the npc, of course
other:
object(id,"x"), object(id,"y"), object(id,"tilex"), and object(id,"tiley") can be used to locate the object, if u dont know its dynamic id (provided there arent other objects in range that the boss can be confused with)

then u only have to think about how to display the hp

this can be accomplished easily by using hudtxt2 with players in the boss area + with images which i dislike


That only works for the entity, not for an individual one.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht