Forum

> > CS2D > Scripts > Bad argument #1 to 'player' (number nil)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bad argument #1 to 'player' (number nil)

8 replies
To the start Previous 1 Next To the start

old Bad argument #1 to 'player' (number nil)

D-D3ADxPro
User Off Offline

Quote
Hello guys, I want to make a script, that after a player dies, money would fall on the ground.

Heres the full script:
1
2
3
4
5
6
7
8
addhook("die","ondie")
function ondie(victim,killer,x,y)
	local tx = player(victim,"tilex")
	local ty = player(victim,"tiley")
	if player(id, 'health') > 0 then -- Line 11
	spawnitem(1337, player(victim, "tilex"), player(victim, "tiley"), money)
	end
end

But in console, the error shows this:
1
LUA ERROR: maps/cs_assault.lua:11: bad argument #1 to 'player' (number expected, got nil)

Does anyone know how to fix this?

old Re: Bad argument #1 to 'player' (number nil)

ReVoltage
User Off Offline

Quote
user D-D3ADxPro has written
Hello guys, I want to make a script, that after a player dies, money would fall on the ground.

Heres the full script:
1
2
3
4
5
6
7
8
addhook("die","ondie")
function ondie(victim,killer,x,y)
	local tx = player(victim,"tilex")
	local ty = player(victim,"tiley")
	if player(id, 'health') > 0 then -- Line 11
	spawnitem(1337, player(victim, "tilex"), player(victim, "tiley"), money)
	end
end

But in console, the error shows this:
1
LUA ERROR: maps/cs_assault.lua:11: bad argument #1 to 'player' (number expected, got nil)

Does anyone know how to fix this?

Uh sir?
1
if player(id, 'health') > 0 then
there is no 'id' parameter, it must be killer or victim

old Re: Bad argument #1 to 'player' (number nil)

ReVoltage
User Off Offline

Quote
user D-D3ADxPro has written
No errors show up, but it doesnt spawn the money when a player dies.

I dont understand this line
1
spawnitem(1337, player(victim, "tilex"), player(victim, "tiley"), money)
You want to make a script that drop ALL money when player die?
If yes, i can make it for you

old Re: Bad argument #1 to 'player' (number nil)

_Yank
User Off Offline

Quote
To drop the item called money :
1
2
3
4
addhook("die","ondie")
function ondie(victim,x,y)
parse('spawnitem 67 '..player(victim,"x")..' '..player(victim,"y"))
end

There's no spawnitem lua command and what do you mean with 1337 and money ??
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview