Page 1 of 1

[POL097-2006-10-25 Coregina] DestroyItem in CanInsertScript

Posted: Thu Nov 09, 2006 5:28 am
by Gnafu
This is the log:

Code: Select all

[11/09 14:06:38] Logfile opened.
POL097-2006-10-25 Coregina (VS.NET 2003) compiled on Oct 25 2006 07:50:00 running.
[11/09 14:07:50] [pkg/systems/poisonwatcher/Infezione/start.ecl]: Infezione Manager started. PID = 172
[11/09 14:07:51] Game is active.
[11/09 14:08:00] [pkg/systems/tools/orkspawn/SpawnScripts/regional.ecl]: [OrkSpawn]: Startup Initiated.
[11/09 14:08:02] [pkg/systems/spawnnet/spawnnet.ecl]:  ** Activating SpawnNet... **
[pkg/systems/spawnnet/spawnnet.ecl]: ** SpawnNet activated. **
[11/09 14:08:52] sysload=18 (49) cputime=1982852

[...]

[11/09 14:15:52] sysload=0 (0) cputime=0
[11/09 14:16:19] Client#1 connected from 127.0.0.1 (1 connections) on interface 127.0.0.1
Account admin logged in from 127.0.0.1
[11/09 14:16:20] Account admin logged in from 127.0.0.1
[11/09 14:16:21] Account admin selecting character Adminsecondo
[11/09 14:16:23] [pkg/systems/poisonwatcher/logon.ecl]: poisonwatcher script PID: 0
[11/09 14:16:52] sysload=3 (2) cputime=110158
[11/09 14:16:57] remove_item_from_world: item 0x4000c9c9 at 0,0 does not exist in world zone
[11/09 14:16:58] Unhandled Exception! Writing Minidump file. 
This file with explanation and last lines from log files should be given to the development team.
Saved dump file to 'POL097-2006-10-25 Coregina-20061109140638-0.dmp'
Last Script: pkg/foundations/hooks/shilSkill.ecl PC: 206
I used only a .create and tried to insert a scroll in a book (container)

This is the CanInsertScript:

Code: Select all

use os;
use vitals;
use attributes;
use basic;
use uo;
use cfgfile;

include "attributes";
include "math";

Const SOUND_EFFECT_INSCRIPTION := 0x50;
var spell_cfg:=ReadConfigFile("necrospells");

program addspell ( who, book, movetype, inserttype, aitem, estack)
var scroll;

if (aitem)
	scroll:=aitem;
else
	scroll:=estack;
endif
if (movetype!=MOVETYPE_PLAYER)
    return 1;
endif
if (scroll.objtype<0xA101||scroll.objtype>0xA110)
    SendSysMessage(who,"Questa scroll non e' valida!",3,33);
    return 0;
endif
//	Var config_file := ReadConfigFile( ":inscription:inscription");
        Var   elem := FindConfigElem(spell_cfg, scroll.objtype);
        if (!elem||!elem.scroll||elem.scroll!=scroll.objtype)
            SendSysMessage(who,"Non puoi inserire quello in uno spellbook!",3,33);
            return 0;
        endif
        
        var Flag;        
        if (elem.SpellGroup == 1)
        	Flag := GetObjProperty(book, "Greater");
        elseif (elem.SpellGroup == 2)
        	Flag := GetObjProperty(book, "Lesser");
        else
          SendSysMessage(who, "Errore nei CFG", 3, 33);
        endif

        	if (FlagCheck(Flag, elem.SpellType))
        		SendSysMessage (who, "Questa magia esiste gia' nel tuo libro!",3,33);
        		return 0;
        	endif
        
	Var TrueSkill :=  GetConfigInt(elem, "skill");
	Var TruePoints := GetConfigInt(elem, "points");

	Var   manacost := (TrueSkill/3);
	if (GetMana (who) < manacost)
                SendSysMessage(who, "Non hai concentrazione sufficiente per trascrivere..",3,33);
		return 0;
	endif
       	Var   skillcheck := CheckSkill(who, SKILLID_INSCRIPTION, Cint(trueskill), Cint(truepoints*5));
       	if (skillcheck)
            ConsumeVital (who, "MANA", manacost);
            PlaySoundEffect(who, SOUND_EFFECT_INSCRIPTION);
            Sleep (2);
            SendSysMessage (who, "Sei riuscito a copiare la pergamena nel libro!",3,33);
            FlagSet(Flag, elem.SpellType);
            if (elem.SpellGroup == 1)
              SetObjProperty(book,"Greater",Flag);
            elseif (elem.SpellGroup == 2)
              SetObjProperty(book,"Greater",Flag);
            endif
            
            ReleaseItem(scroll);
            Destroyitem(scroll);   // -> WARNING : It destroy a stack too...
            
            Return 1; 		//DONE
        else
            SendSysMessage (who, "Non sei in grado di copiare questa pergamena nel libro..",3,33);
            Return 0;	//FAILED
        endif
	movetype:=0;	// evita il warning
	inserttype:=0;
        
endprogram

Posted: Thu Nov 09, 2006 8:04 am
by Pierce
Perhaps the reason could be that you missed one param:
program addspell ( who, book, movetype, inserttype, aitem, estack)
It should be:

program addspell ( who, book, movetype, inserttype, aitem, estack, amount)

Posted: Thu Nov 09, 2006 12:32 pm
by Gnafu
I tested a bit..

The problem is that DestroyItem(book);

Probably i was trying to destroy an item in use...
How can I destroy an item that I triyed to put in a container? (with CanInsert?)

Posted: Thu Nov 09, 2006 1:29 pm
by MuadDib
Don't destroy stuff in the insert scripts. Bad boy.

Posted: Thu Nov 09, 2006 1:35 pm
by SMJ
MuadDib wrote:Don't destroy stuff in the insert scripts. Bad boy.
:lol:

Posted: Thu Nov 09, 2006 11:58 pm
by Gnafu
So, how can i do?

I want something like:

pg:"Mmm.. a magic container, let's try to put an apple in it..."
Container:"Stupid!! I'm a magic container don't play with me!!" (explode the apple)

Probably must i use the OnInsertScript, moving out everything unexpected?

Posted: Fri Nov 10, 2006 12:13 am
by SMJ
Well, on your "CanInsertScript", why not just fire an external script just before your CanInsert script closes?

Like:

Code: Select all

Start_Script(":pkg:explodingApple", array{container,apple,character,"Stupid!! I'm a magic container don't play with me!!"});
return 0;

Code: Select all

program ExplodingApple(params)
    var container := params[1];
    var apple := params[2];
    var chr := params[3];
    var msg := params[4];

    BlowUp(apple);
    Destroy(apple);

    SendSysMessage(chr, ""+container.name+": "+msg);
    return 1;
endprogram

Posted: Fri Nov 10, 2006 12:25 am
by Gnafu
Thanks !!

Posted: Fri Nov 10, 2006 12:34 am
by SMJ
No problem :)

Did it work?

Posted: Sun Nov 19, 2006 12:49 pm
by Shinigami
Pierce wrote:Perhaps the reason could be that you missed one param:
missings params are no problems in this case

Shinigami

Posted: Sun Nov 19, 2006 4:04 pm
by Xandros
You can actually destroy the item in an insert script without any
problem. You just have to do this in the OnInsert script instead of the
CanInsert script. Worked fine here for the last few years.

Xandros