Forum

> > CS2D > Scripts > Very simple: Adding name in message
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Very simple: Adding name in message

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Very simple: Adding name in message

Nori-chan
User Off Offline

Zitieren
I'm sorry about this dumb question, but i'm trying to add a name when I kill an enemy.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("kill","xpkill")
function xpkill(killer,victim,weapon)
	msg2(killer,"\n©255255255Kill: enemy player +100@C")
	if player(killer,"score")== 5 then
	msg2(killer,"\n©00025500 You have 500 points")
	end
	if player(killer,"score")== 10 then
	msg2(killer,"\n©00025500 You have 1000 points")
	end
	if player(killer,"score")== 20 then
	msg2(killer,"\n©00025500 You have 2000 points")
	end
	if player(killer,"score")== 50 then
	msg2(killer,"\n©00025500 You have 5000 points")
	end
	if player(killer,"score")== 100 then
	msg2(killer,"\n©00025500 You have 10000 points")
	end
end

In-game, when I kill an enemy, appears "Kill: enemy player +100"
But I want something like: "Kill: [insert enemy name here] +100"

Thank you guys for any answer.

alt Re: Very simple: Adding name in message

Nori-chan
User Off Offline

Zitieren
Really strange.
If I add withouth "", there is the error:
LUA>ERROR: sys/lua/autorun/classes.lua:50:')' expected near 'name'

If I add with "":
LUA>ERROR: sys/lua/autorun/classes.lua:50:bad argument #1 to "player" (number expected, got nil)

EDIT: line 50 is:

msg2(killer,"\n©255255255Kill: enemy player +100@C")

But now is:

msg2(killer,"\n©255255255Kill: "..player(id,"name").." +100@C")
1× editiert, zuletzt 01.03.13 15:11:58

alt Re: Very simple: Adding name in message

Yates
Reviewer Off Offline

Zitieren
Edit: Use the code I gave you. The code Obviously [...] gave you is incorrect as your hook does not use the id parameter.
1× editiert, zuletzt 01.03.13 15:15:11
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht