SphereCommunity
Removing Summoned NPC - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Removing Summoned NPC (/Thread-Removing-Summoned-NPC)



Removing Summoned NPC - Leonidas - 02-03-2015 06:41 PM

I'm having trouble figuring this out. I have everything else working fine but I just cant seem to have the animal that is summoned be removed when the timer hits 0.


[FUNCTION frostelf_avatarofice]
IF ((<src.tag.frost_elf>)=0)
SRC.SYSMESSAGE You are not of that race
RETURN 1
ELSEIF (<SRC.FINDID.i_avatarofice_timer>==0)
src.newitem=i_avatarofice_timer
SRC.new.TIMER=1
src.act.equip
SRC.ACT.CONT=<SRC.UID>
serv.newnpc c_horse_tan
new.MakeMyPet
return 1
else
src.sysmessage You must gather your strength...
endif
endif

[function MakeMyPet]
serv.newitem=i_memory
new.color=memory_ipet
new.link=<src>
new.cont=<uid>


I've tried setting a timer on i_memory and using on=@timer to remove it but it gives me nothing so im sure I'm missing something here.


RE: Removing Summoned NPC - XuN - 02-03-2015 11:38 PM

In the timer you must use CONT.Remove, where CONT is who/what holds the item (in this case the pet with the memory, if you use it in one item inside your backpack then CONT will be the backpack ...).

IF ((<src.tag.frost_elf>)=0) <-- you are using so much () and missing one = and tag0:
-It makes no sense to use ((<src.tag.frost_elf)==0), I bet you remember maths in school using them to group numbers, ie: 3 + (4/2), there's no reason to do (3) + (4/2), right?
-NAME=MyName, one = means set. <str>==100, two = means comparison.
-<src.tag.frost_elf> returns '' if it does not exist, which means NULL or nothing ... no value at all and it throws error at console because sphere will read this: if ( == 0)'. So this is where the magic of tag0 which adds automatically one 0 if there is no value.

So this line should be like this: IF (<src.tag0.frost_elf>==0)


RE: Removing Summoned NPC - Leonidas - 02-04-2015 09:06 AM

Okay thanks man, I'm trying to remember all of this, it's been a while since I've actually scripted anything. I appreciate your help! Thank you