Forum

> > CS2D > Scripts > It Shows Everyone!
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch It Shows Everyone!

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt It Shows Everyone!

_Vipersiax
User Off Offline

Zitieren
my lua shows everyone!
Spoiler >

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

alt Re: It Shows Everyone!

Scott
BANNED Off Offline

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

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

alt Re: It Shows Everyone!

Scott
BANNED Off Offline

Zitieren
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----

alt Re: It Shows Everyone!

GeoB99
Moderator Off Offline

Zitieren
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.

alt Re: It Shows Everyone!

Ajmin
User Off Offline

Zitieren
@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.

alt Re: It Shows Everyone!

baRD
User Off Offline

Zitieren
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...

alt Re: It Shows Everyone!

Yates
Reviewer Off Offline

Zitieren
@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")
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht