Forum

> > CS2D > Scripts > Creating Image Over NPC
Forums overviewCS2D overview Scripts overviewLog in to reply

English Creating Image Over NPC

6 replies
To the start Previous 1 Next To the start

old Creating Image Over NPC

KaBooMa
User Off Offline

Quote
alright...i think im using threads to much...anyways my goal here! i wanna make a image over a npc and have it disappear and all kinds of cool stuff haha so heres my code

Spoiler >


and heres my problem...ok so this is scanning over all the npcs generated randomly in a map i have...it says...if its type is 30 which is zombie right? or wrong? then its going to repos. the image i have for the id to its x and y and rotation...but im getting a error and its not repositioning all the images..error is number expected, got nil...where its reposing the image...i know that nil is...nothing...and i just seen that its saying NPC[npc] is nil...can anyone tell me why its doing this? i have it so when it spawns a npc..it sets a image at the x and y and r of the npc and NPC[npc (which the generator sets as it goes too using for 1,100 or something..)] am i doing a noob mistake again? haha would love some help shared

EDIT: i see my mistake...but i cant find any work around at all any help guys...the npcs id and image id will not be the same and therefor..im out of ideas...can anyone help at all?

old Re: Creating Image Over NPC

Vectarrio
User Off Offline

Quote
1
2
3
4
5
6
7
8
function NPCImage()
	local npct=object(0,"table")
	for i = 1,#npct do
		if object(npct[i],'type') == 30 then
			imagepos(NPC[npct[i]],object(npct[i],'x'),object(npct[i],'y'),object(npct[i],'rot'))
		end
	end
end
does it work?

old Re: Creating Image Over NPC

kalis
User Off Offline

Quote
i think
type of zombie not = 30 =.= , ID have? in editor ?
! : zombie
2 : Headcrab
3 : snrak
4 : vortigant
5 : soldeir

i dont think i'm right !

old Re: Creating Image Over NPC

Cure Pikachu
User Off Offline

Quote
user kalis has written
i think
type of zombie not = 30 =.= , ID have? in editor ?
! : zombie
2 : Headcrab
3 : snrak
4 : vortigant
5 : soldeir

i dont think i'm right !

NPCs are dynamic objects, so they share the same type ID (30). Those IDs is for their looks, I assume.

old Re: Creating Image Over NPC

KaBooMa
User Off Offline

Quote
oh ok i see pika ok so i tryed vectars code and it gave me the same thing -.- is there a way maybe that i can see if its a 'zombie' not a all over dynamic object..because its saying this because there is dynamic objects in the map and they dont have a NPC[npc] set to them any idea

old Re: Creating Image Over NPC

Vectarrio
User Off Offline

Quote
can you give full error line (I mean console's one)?
and did you create the image before posing it? (by image command)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview