English Script Request

14 replies
Goto Page
To the start Previous 1 Next To the start
24.06.12 09:07:57 pm
Up
Jarago
User
Offline Off
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
24.06.12 09:12:01 pm
Up
Apache uwu
User
Offline Off
Code:
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.
24.06.12 09:20:45 pm
Up
Jarago
User
Offline Off
thx
and is it possible to disable any other sounds when player dies? there are some sound loops in map...
24.06.12 09:30:53 pm
Up
EP
User
Offline Off
@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.
Code:
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.
24.06.12 10:10:09 pm
Up
Jarago
User
Offline Off
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...
edited 1×, last 24.06.12 10:38:31 pm
24.06.12 10:20:30 pm
Up
EP
User
Offline Off
Yeah it is possible, but you have to trigger that sound (It has to have a name) via the CS2D Script.
24.06.12 10:23:48 pm
Up
Apache uwu
User
Offline Off
Maybe try to prevent death with the cs2d lua hook hit hook and then teleport the player and have some cs2d cmd effect to emu/sim the effect of respawning.
25.06.12 01:42:51 am
Up
dns
User
Offline Off
@user Apache uwu: u r scripter?
IMG:http://img442.imageshack.us/img442/9933/46100129.png
IMG:http://img834.imageshack.us/img834/8072/mapperb.png
25.06.12 08:02:53 pm
Up
Jarago
User
Offline Off
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?
edited 1×, last 27.06.12 09:50:14 am
27.06.12 12:18:37 pm
Up
Alistaire
User
Offline Off
It is not possible. You can't make a healthbar for a generic NPC.
IMG:http://i.imgur.com/5zhwOTP.png
27.06.12 07:34:01 pm
Up
Infinite Rain
Reviewer
Offline Off
user Apache uwu has written:
Code:
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
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
27.06.12 07:35:31 pm
Up
Apache uwu
User
Offline Off
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.
27.06.12 07:44:27 pm
Up
omg
User
Offline Off
user Alistaire has written:
It is not possible. You can't make a healthbar for a generic NPC.

lol yeah u can

Code:
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
will code for food
27.06.12 07:49:26 pm
Up
Alistaire
User
Offline Off
user omg has written:
user Alistaire has written:
It is not possible. You can't make a healthbar for a generic NPC.

lol yeah u can

Code:
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.
IMG:http://i.imgur.com/5zhwOTP.png
27.06.12 09:10:49 pm
Up
omg
User
Offline Off
individual one? i dont see whats different
will code for food
To the start Previous 1 Next To the start