ID:144905
 
Code:
if (M.health <= 0)
if (M.npc=1)
del(M)
else
M.loc=locate (130,200,1)
M.health = M.maxhealth
world << "[M] has been slain by [usr]!"
usr.exp += (rand(1,5))
levelup()


Problem description:
It shows the "if (M.npc=1)" as a missing expression. Anyone know what I can do to correct it?
<code>if(M.npc==1)</code>

Though, if it is a boolean var, you should do: <code>if(M.npc)</code> (and to check if it's 0/false: <code>if(!M.npc)</code>).

And boolean vars are vars that only can be 1(TRUE) or 0(FALSE). TRUE/FALSE vars... get it?

O-matic
In response to O-matic
alright, I'm not getting the error anymore, but it's treating my NPC as a player, and it's sending it to the spawn point. Here is how I have the code for my NPC

Code:
mob
enemy
weakhollow
name= "Weak Hollow"
icon = 'Hollow.dmi'
maxhealth = 50
health = 50
npc=1
In response to GohanIdz
I corrected it by doing this:



Code:
if (/mob/enemy)
del(M)
In response to GohanIdz
That doesn't do a darn thing.
<code>if(src.type==/mob/enemy) del(src)</code>

Seeing as in a DeathCheck() src should be the dying mob.
In response to Mysame
There's a special proc for that, <code>istype()</code>. =P

O-matic
In response to O-matic
... Arr, right ... That's what happens when you get into WoW, I'll say. Still, it's a basic idea. :<

Anyone wanna test and see what's fastest?
In response to Mysame
Yeah, it didn't work. When I put in the code like that it made the players log out whenever they were killed x_x

That's definitely an undesired effect.
In response to GohanIdz
Either do if(src.npc) if it has that value OR if(!client) [click here to read about boolean if you do not know what it is]

if a client is false, that means there's (usually) no actual person playing that mob.. thus making it an NPC (but this also includes monster)

or you can also do if(istype(src,/mob/path/here))

- GhostAnime

PS: The reason if(/path/here) worked is because it is TRUE, there's nothing there to classify it as FALSE so it will always happen (TRUE/FALSE ==> Boolean)
if (M.health <= 0)
if(!M.key) //if the mob has a key, it either belongs to an active player or an inactive player\
we check if it doesn't a have a key, and then treat it as an NPC, rather than having an "npc" variable

del(M)
else
M.loc=locate (130,200,1)
M.health = M.maxhealth
world << "[M] has been slain by [usr]!"
usr.exp += (rand(1,5))
levelup()


The initial problem you had, with your missing expression, was that you had if (M.npc=1). The correct version is if (M.npc==1) but the politically correct version would be if(M.npc).

-- Data