Forum

> > CS2D > Scripts > Very simple: Adding name in message
Forums overviewCS2D overview Scripts overviewLog in to reply

English Very simple: Adding name in message

7 replies
To the start Previous 1 Next To the start

old Very simple: Adding name in message

Nori-chan
User Off Offline

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

old Re: Very simple: Adding name in message

Nori-chan
User Off Offline

Quote
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")
edited 1×, last 01.03.13 03:11:58 pm

old Re: Very simple: Adding name in message

Yates
Reviewer Off Offline

Quote
Edit: Use the code I gave you. The code Obviously [...] gave you is incorrect as your hook does not use the id parameter.
edited 1×, last 01.03.13 03:15:11 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview