Forum

> > CS2D > Scripts > It Shows Everyone!
Forums overviewCS2D overview Scripts overviewLog in to reply

English It Shows Everyone!

14 replies
To the start Previous 1 Next To the start

old It Shows Everyone!

_Vipersiax
User Off Offline

Quote
my lua shows everyone!
Spoiler >

how can i fix it? my first time on lua coding im learning to code

old Re: It Shows Everyone!

Scott
BANNED Off Offline

Quote
you're talking about show the message to a single player?

If so, you should use
msg2(id,"<message>")
edited 4×, last 12.07.17 10:44:04 am

old Re: It Shows Everyone!

Scott
BANNED Off Offline

Quote
Here you have
1
2
3
4
5
6
addhook("die","firstlua")
function firstlua()
msg2(id,"©255000000You Died!")
msg2(id,"©255000000Wait For Next Round.")
end
----END----

old Re: It Shows Everyone!

GeoB99
Moderator Off Offline

Quote
Actually the correct identifier with the player's ID data is
victim
as cs2d lua hook die hook doesn't pass such arguments like
id
natively, unless you manually retrieve that value by iterating over living players. Therefore id must be replaced with victim inside the two
msg2()
functions as well.

old Re: It Shows Everyone!

Ajmin
User Off Offline

Quote
@user _Vipersiax: Consider hooks as event that occurs at a specific time.
So u hooked the msg2 with the event "death".
death will always occur to a single specific person nd hence it got a single parameter. Contrary to what @user GeoB99 said,We can use any term to refer those parameters for any hooks.
1
2
3
4
addhook("die","death")
function death(asshole)
msg2(asshole,"Rest in peace")
end
But the same not happens with other hooks for example kill.
Kill event can specify many persons like killer,victim.
Moreover the specific weapon used in killing also comes with this hook.
So better to understand those things just read the lua help page in cs2d official site.

old Re: It Shows Everyone!

baRD
User Off Offline

Quote
Can you just do this?
i never tried this...
1
2
3
4
5
6
7
8
9
10
-- Start --

addhook("die","player_dieMsg")

function player_dieMsg(victim,killer)
	msg2(victim,"Get rekt noob!!!")
	msg2(victim,"You got owned by "..killer.."!!!")
end

-- End --

beware:I havent tested this yet...

old Re: It Shows Everyone!

baRD
User Off Offline

Quote
or can it be?
1
msg2(victim,"You got owned by "..killer(id,"name").."!!!")

old Re: It Shows Everyone!

Yates
Reviewer Off Offline

Quote
@user baRD: You use the cs2d lua cmd player function to retrieve player information, so it will always be
player(id, value)


In our case, the id should be that of the
killer
and the value we want to retrieve is
name
:

player(killer, "name")
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview