i want a script
that script is when i kill a NPC then appear items such as gold , money , other things
can someone give me that code??
Thank you
Scripts
When kill NPCs....
When kill NPCs....
1

Eternal has written
Re: When kill NPCs....
Infinite Rain: The NPC ID is right, but the hook is almost correct.
Eternal: Here's the code. This one spawns a Gold around the NPC you killed.
addhook("objectkill","spwnitm")
function spwnitm(oid,pid)
	if object(oid,"type") == 30 then
		local a = math.random(1,8)
		local xx = object(oid,"tilex")
		local xx2 = xx - 1
		local xx3 = xx + 1
		local yy = object(oid,"tiley")
		local yy2 = yy + 1
		local yy3 = yy - 1
		if a == 1 then parse("spawnitem 68 "..xx2.." "..yy)
		elseif a == 2 then parse("spawnitem 68 "..xx3.." "..yy)
		elseif a == 3 then parse("spawnitem 68 "..xx.." "..yy2)
		elseif a == 4 then parse("spawnitem 68 "..xx.." "..yy3)
		elseif a == 5 then parse("spawnitem 68 "..xx2.." "..yy2)
		elseif a == 6 then parse("spawnitem 68 "..xx2.." "..yy3)
		elseif a == 7 then parse("spawnitem 68 "..xx3.." "..yy2)
		elseif a == 8 then parse("spawnitem 68 "..xx3.." "..yy3)
		end
	end
end
Cure Pikachu has written
Infinite Rain: The NPC ID is right, but the hook is almost correct.
Eternal: Here's the code. This one spawns a Gold around the NPC you killed.
addhook("objectkill","spwnitm")
function spwnitm(oid,pid)
	if object(oid,"type") == 30 then
		local a = math.random(1,8)
		local xx = object(oid,"tilex")
		local xx2 = xx - 1
		local xx3 = xx + 1
		local yy = object(oid,"tiley")
		local yy2 = yy + 1
		local yy3 = yy - 1
		if a == 1 then parse("spawnitem 68 "..xx2.." "..yy)
		elseif a == 2 then parse("spawnitem 68 "..xx3.." "..yy)
		elseif a == 3 then parse("spawnitem 68 "..xx.." "..yy2)
		elseif a == 4 then parse("spawnitem 68 "..xx.." "..yy3)
		elseif a == 5 then parse("spawnitem 68 "..xx2.." "..yy2)
		elseif a == 6 then parse("spawnitem 68 "..xx2.." "..yy3)
		elseif a == 7 then parse("spawnitem 68 "..xx3.." "..yy2)
		elseif a == 8 then parse("spawnitem 68 "..xx3.." "..yy3)
		end
	end
end
Eternal: Just repeat the spawning.addhook("objectkill","spwnitm")
function spwnitm(oid,pid)
	if object(oid,"type") == 30 then
		local a = math.random(1,8)
		local xx = object(oid,"tilex")
		local xx2 = xx - 1
		local xx3 = xx + 1
		local yy = object(oid,"tiley")
		local yy2 = yy + 1
		local yy3 = yy - 1
		if a == 1 then
			for b = 1, 3 do parse("spawnitem 68 "..xx2.." "..yy) end
		elseif a == 2 then
			for c = 1, 3 do parse("spawnitem 68 "..xx3.." "..yy) end
		elseif a == 3 then
			for d = 1, 3 do parse("spawnitem 68 "..xx.." "..yy2) end
		elseif a == 4 then
			for e = 1, 3 do parse("spawnitem 68 "..xx.." "..yy3) end
		elseif a == 5 then
			for f = 1, 3 do parse("spawnitem 68 "..xx2.." "..yy2) end
		elseif a == 6 then
			for g = 1, 3 do parse("spawnitem 68 "..xx2.." "..yy3) end
		elseif a == 7 then
			for h = 1, 3 do parse("spawnitem 68 "..xx3.." "..yy2) end
		elseif a == 8 then
			for i = 1, 3 do parse("spawnitem 68 "..xx3.." "..yy3) end
		end
	end
end
addhook("objectkill","_objkill")
function _objkill(b,id)
if object(b,"type")==30 then
parse('spawnitem '..math.random(1,88)..' '..object(b,"tilex")..' '..object(b,"tiley"))
end
end
addhook("objectkill","_objkilll")
function _objkilll(b,id)
if object(b,"type")==30 then
parse("setscore "..id.." "..(player(id,"score")+1))
end
end
BcY 's code:npc_items={64,65,66,67}
addhook("objectkill","_objkill")
function _objkill(b,id)
if object(b,"type")==30 then
local itm=npc_items[math.random(1,#npc_items)]
parse('spawnitem '..itm..' '..object(b,"tilex")..' '..object(b,"tiley"))
end
end
addhook("objectkill","_objkilll")
function _objkilll(b,id)
if object(b,"type")==30 then
parse("setscore "..id.." "..(player(id,"score")+1))
end
end
Avo: . Im a newbie scripter
BcY: You don't have to sorry
just test script at first if you aren't sure it will works .
1
