English It Shows Everyone!

14 replies
Goto Page
To the start Previous 1 Next To the start
12.07.17 10:22:13 am
Up
_Vipersiax
User
Offline Off
my lua shows everyone!
Spoiler >

how can i fix it? my first time on lua coding im learning to code
I Fixed It.
12.07.17 10:34:06 am
Up
Scott
BANNED
Offline Off
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
12.07.17 10:36:15 am
Up
_Vipersiax
User
Offline Off
yes i do, if he died i want only show single player! (dead player)
I Fixed It.
12.07.17 10:39:15 am
Up
Scott
BANNED
Offline Off
Here you have
Code:
1
2
3
4
5
6
addhook("die","firstlua")
function firstlua()
msg2(id,"©255000000You Died!")
msg2(id,"©255000000Wait For Next Round.")
end
----END----
12.07.17 12:29:59 pm
Up
TimeQuesT
User
Offline Off
id is nil. Add the identifier to function parameter list.
Muh
12.07.17 12:47:23 pm
Up
_Vipersiax
User
Offline Off
how can i add that???
I Fixed It.
12.07.17 12:54:05 pm
Up
Mora_rus
User
Offline Off
function firstlua(id)
12.07.17 01:16:35 pm
Up
GeoB
Moderator
Offline Off
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.
12.07.17 01:19:30 pm
Up
Talented Doge
User
Offline Off
@user GeoB: You know the parameters count only the order, rather than the actual name right?
Talented Doge
12.07.17 01:53:44 pm
Up
Ajmin
User
Offline Off
@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 GeoB said,We can use any term to refer those parameters for any hooks.
Code:
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.
12.07.17 02:46:53 pm
Up
baRD
User
Offline Off
Can you just do this?
i never tried this...
Code:
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...
12.07.17 02:52:38 pm
Up
Yates
Reviewer
Offline Off
@user baRD: That looks fine, apart from
"..killer.."
will display the ID instead of the name.
12.07.17 02:55:42 pm
Up
baRD
User
Offline Off
or can it be?
Code:
1
msg2(victim,"You got owned by "..killer(id,"name").."!!!")
12.07.17 02:59:12 pm
Up
Yates
Reviewer
Offline Off
@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")
12.07.17 03:10:55 pm
Up
baRD
User
Offline Off
Oh right i forgot
To the start Previous 1 Next To the start