ID:155779
 
    xpgain()
if (hp <= 0)
usr.xp += rand(20,100)


I have a problem with the XP situation. I used the above code to gain exp and I see the limitations as I cannot embed a value. eg. usr << "You have gained [gainedxp] XP!".

Please could someone help me with this. I am still learning so please bare with me :P
You can't expect us to understand what xpgain() is for with just this information alone. I'm going to assume xpgain() is called each time you want to detect something's death. A much better alternative would be define who the attacker is:

mob/verb
Attack(mob/M in view(1, src)) // select mobs in a 1 tile-wide radius
M.hp -= 5
M.xpgain(src) // src is the attacker


mob/proc
xpgain(mob/attacker)
if(hp <= 0)
var/expgained = rand(20,100)
attacker.xp += expgained
attacker << "You have gained [expgained] xp!"