Forum

> > CS2D > Scripts > Bad argument #1 to 'player' (number nil)
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

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

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

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

D-D3ADxPro
User Off Offline

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

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

ReVoltage
User Off Offline

Zitieren
user D-D3ADxPro hat geschrieben
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

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

ReVoltage
User Off Offline

Zitieren
user D-D3ADxPro hat geschrieben
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

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

_Yank
User Off Offline

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