Forum

> > CS2D > Scripts > NPC Weapon Drop
Forums overviewCS2D overview Scripts overviewLog in to reply

English NPC Weapon Drop

14 replies
To the start Previous 1 Next To the start

old NPC Weapon Drop

Infinite Rain
Reviewer Off Offline

Quote
Guys i need script
I never had a work with npcs but I need help
When you kill NPC Soldier Item type 24 will appear under it
Can you please help ma?

old Re: NPC Weapon Drop

KagamineLen
User Off Offline

Quote
1
2
3
4
5
6
7
addhook npc,soldier
if player('npc.soldier') == dead'
then parse('spawnitem under npc.soldier 24')
		return 100 times!~2
end
	end
		end

lol lua script

old Re: NPC Weapon Drop

Infinite Rain
Reviewer Off Offline

Quote
user KagamineLen has written
1
2
3
4
5
6
7
addhook npc,soldier
if player('npc.soldier') == dead'
then parse('spawnitem under npc.soldier 24')
		return 100 times!~2
end
	end
		end
lol lua script

emm maybe...

Stop trolling...

old Re: NPC Weapon Drop

EnderCrypt
User Off Offline

Quote
omg wtf is that
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook npc,soldier      
em... missing "" and () and npc hook does not exist

if player('npc.soldier') == dead'
varisable not declared, and has ' meaning its a string, and also has 3 ' signs, and checks if string is dead (unexisting variable)

then parse('spawnitem under npc.soldier 24')
under is not valid in console, its suppose to have x y cord
variable npc.soldier is not declared and missing "....", why

          return 100 times!~2
on a cs2d hook, you should return eithere 0 or 1, and times!~2 is invalid

end
     end
          end

you also missing the function "name" ("variable") after hook


edit, it CAN be made, hower not for the military NPC , however theres 1 posibility...

edit2: ok, if you want me to make a working, then contact me by pm
edited 2×, last 10.08.11 09:00:48 pm

old Re: NPC Weapon Drop

EnderCrypt
User Off Offline

Quote
EHM theres a way, to make the npc soilder drop a weapon

its slightly complicated but fully possible

old Re: NPC Weapon Drop

EnderCrypt
User Off Offline

Quote
well, then all npc drops weapon, in current cs2d version its impossible to identify if its an npc, however theres (as i said,) a slightly complicated way

old Re: NPC Weapon Drop

Kiffer-Opa
User Off Offline

Quote
Okay, actually it is possible. As proof I give you a tested and working Lua script which does the task. If you kill a soldier, a UMP45 spawns on the death spot:
1
2
3
4
5
6
7
8
9
if npcdrop==nil then npcdrop={} end
function npcdrop.objectkill(object_id,player_id)
	if(object(object_id,"type")==30) then
		if(object(object_id,"player")==5) then
			parse("spawnitem 24 "..object(object_id,"tilex").." "..object(object_id,"tiley"))
		end
	end
end
addhook("objectkill","npcdrop.objectkill")
A few notes on this:
A soldier is actually a NPC. And NPCs are objects with type 30. The type of the NPC itself is saved into the player value. A soldier is NPC type 5. All the code does is checking everytime after a object has been killed. If objecttype equals 30 and then if player value of the object equals 5. If both conditions are true, the object is a soldier and the script spawns an UMP45.

Well, one question remains. Is it actually an UMP45 the soldier holds? I am not sure, the fire rate seems to be a bit different. OKAY, I checked it. It actually IS an UMP45. Damage is 15, fire rate seems to be same, sound is the same, it looks like an UMP45. So I guess it IS an UMP45.
edited 1×, last 11.08.11 03:31:47 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview