Forum

> > CS2D > Scripts > NPC's Parametres
Forums overviewCS2D overview Scripts overviewLog in to reply

English NPC's Parametres

8 replies
To the start Previous 1 Next To the start

old NPC's Parametres

tos12345678
User Off Offline

Quote
I have question.
Whether there is a script which:
Will drop others money from each other npc's (after kill npc) e.g.
Zombies:
1
parse("spawnitem 66 "..object(id,"tilex").." "..object(id,"tiley"))
Soliders:
1
parse("spawnitem 68 "..object(id,"tilex").." "..object(id,"tiley"))
Please help me with this script if it's possible. Thanks!

old Re: NPC's Parametres

Quattro
GAME BANNED Off Offline

Quote
there is lua hook for kill and death.
get npc's coordinates of the victim using function for one of these hooks and spawn gold with the parse line you wrote

old Re: NPC's Parametres

Avo
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook('objectkill', 'onObjectKill')
function onObjectKill(oid, pid)
	if object(oid, 'player') == 1 then -- zombie
		parse("spawnitem 66 "..object(oid,"tilex").." "..object(oid,"tiley"))
	elseif object(oid, 'player') == 5 then -- soldier
		parse("spawnitem 68 "..object(oid,"tilex").." "..object(oid,"tiley"))
	end
end

I don't really remember if object's position is available at the moment of being destroyed, so the above might not work. In that case try this one:

1
2
3
4
5
6
7
8
9
10
addhook('objectdamage', 'onObjectDamage')
function onObjectKill(oid, dmg, src)
	if dmg >= object(oid, 'health') then
		if object(oid, 'player') == 1 then -- zombie
			parse("spawnitem 66 "..object(oid,"tilex").." "..object(oid,"tiley"))
		elseif object(oid, 'player') == 5 then -- soldier
			parse("spawnitem 68 "..object(oid,"tilex").." "..object(oid,"tiley"))
		end
	end
end

cs2d lua cmd object, cs2d lua hook objectkill, cs2d lua hook objectdamage
edited 1×, last 18.12.18 04:42:16 pm

old Re: NPC's Parametres

Quattro
GAME BANNED Off Offline

Quote
yeah it should work, I was using these commands in aim challenge script too. my image object was called HUD:

1
2
parse('sv_soundpos "/2DMasters/training/splash.ogg" '..object(HUD,'x')..' '..object(HUD,'y')..'')
    parse('sv_soundpos "/2DMasters/training/'..name..'" '..object(HUD,'x')..' '..object(HUD,'y')..'')
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview