please help me in the script utility.inc

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
Mallary
Novice Poster
Posts: 40
Joined: Thu Aug 14, 2008 2:54 pm

please help me in the script utility.inc

Post by Mallary »

Some friend could help me with this error?

Code: Select all

use uo;
use os;
use util;
use basic;



function find_or_create_storage( areaname )

	var area := FindStorageArea( areaname );
	if (!area)
		area := CreateStorageArea( areaname );
		if (area)
			print( "Storage Area '" + areaname + "' created." );
		endif
	endif
	return area;

endfunction

function find_or_create_item( storage, name, objtype )

	var item := FindRootItemInStorageArea( storage, name );
	if (item)
		return item;
	endif

	//didn't find, so create
	item := CreateRootItemInStorageArea( storage, name, objtype );
	return item;

endfunction

function IsLocationAccessible( character, x, y, z )
    var xd, yd, zd;
   
    xd := character.x - x;
    if (xd < -1 || xd > 1)
        return 0;
    endif
   
    yd := character.y - y;
    if (yd < -1 || yd > 1)
        return 0;
    endif
   
    zd := character.z - z;
    if (zd < -10 || zd > 10)
        return 0;
    endif

    return CheckLosAt( character, x, y, z );

endfunction

function min(x, y)
	if (x<= y)
		return x;
	else
		return y;
	endif
endfunction

function max(x, y)
    if (x>= y)
        return x;
    else
        return y;
    endif
endfunction

function coordist( x1, y1, x2, y2 )

	var xd := x1 - x2;
	var yd := y1 - y2;
	if (xd < 0)
		xd := -xd;
	endif
	if (yd < 0)
		yd := -yd;
	endif
	if (xd > yd)
		return xd;
	else
		return yd;
	endif

endfunction

function AllocLockId()

	set_critical(1);
	var lockid := GetGlobalProperty( "nextlockid" );
	if (!lockid)
		lockid := 1;
	endif
	SetGlobalProperty( "nextlockid", lockid+1 );

	set_critical(0);

	return lockid;
endfunction

function GetDirection(character, x, y)

	var ns_desc := "";
	var ew_desc := "";

	if (y < character.y)
        	ns_desc := "north";
	elseif  (y > character.y)
		ns_desc := "south";
	endif

	if (x < character.x)
		ew_desc := "west";
	elseif  (x > character.x)
		ew_desc := "east";
	endif

	var total_desc := "";
	if (ns_desc == "" && ew_desc == "")
		total_desc := "nearby";
	else
		total_desc :=ns_desc + ew_desc;
	endif

	return total_desc;

endfunction

///////////////////
//  opens the bank storage area
///////////////////

function OpenWorldBank()

	var bank := FindStorageArea( "World Bank" );
	if (!bank)
		bank := CreateStorageArea( "World Bank" );
	endif

	// this should not happen. FIXME, make sure and document that fact.
	if (!bank)
		syslog( "Unable to open or create world bank!" );
	endif

	return bank;

endfunction



///////////////////
// finds the bankbox for the given character
///////////////////

function FindBankBox( character )

	var worldbank := OpenWorldBank();
	var bank_obj_name := "Bankbox of " + character.serial;
	var bankbox := FindRootItemInStorageArea( worldbank, bank_obj_name );

	if (!bankbox)
		bankbox := CreateRootItemInStorageArea( worldbank, bank_obj_name, UOBJ_BANKBOX );
	endif

	// should never happen.  FIXME make sure and document that fact
	if (!bankbox)
		syslog( "Unable to find or create bankbox for " + character.serial );
	endif

	return bankbox;

endfunction
Error in function 'FindBankBox'.
File: c:\legends\scripts\include\utility.inc, Line 165
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: please help me in the script utility.inc

Post by CWO »

Is there anything more said with that error? What version of POL are you using?
User avatar
Mallary
Novice Poster
Posts: 40
Joined: Thu Aug 14, 2008 2:54 pm

Re: please help me in the script utility.inc

Post by Mallary »

Core: POL096-2006-06-09 Vestal Virgin

Function CreateRootItemInStorageArea: Parameter objtype was not passed, and there is no default.
Error getting arguments for function CreateRootItemInStorageArea
File: c:\legends\scripts\include\utility.inc, Line 165
Error compiling statement at c:\legends\scripts\include\utility.inc, Line 165
Error in IF statement starting at File: c:\legends\scripts\include\utility.inc, Line 164
Error compiling statement at c:\legends\scripts\include\utility.inc, Line 164
Error in function 'FindBankBox', File: c:\legends\scripts\include\utility.inc, Line 165
Error in function 'FindBankBox'.
File: c:\legends\scripts\include\utility.inc, Line 165


tkz;)
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm

Re: please help me in the script utility.inc

Post by Justae »

Just looking at the error message, the first thing that comes to mind is that there is no objtype being defined. Check your utility.inc to see if you have your 'objtype.inc' file included ? There should be an entry for UOBJ_BANKBOX in the objtype.inc file.

Regards
Justae
User avatar
Mallary
Novice Poster
Posts: 40
Joined: Thu Aug 14, 2008 2:54 pm

Re: please help me in the script utility.inc

Post by Mallary »

yes he is there const UOBJ_BANKBOX: = 0x0e7c;.

but still giving error .. ^ ^
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm

Re: please help me in the script utility.inc

Post by Justae »

Mallary wrote:yes he is there const UOBJ_BANKBOX: = 0x0e7c;.

but still giving error .. ^ ^

Yes, but your utility.inc file, as it stands, makes no reference to objtype.inc
Even though the variable is defined in objtype.inc, you need to include "include/objtype" in your calling program.
User avatar
Mallary
Novice Poster
Posts: 40
Joined: Thu Aug 14, 2008 2:54 pm

Re: please help me in the script utility.inc

Post by Mallary »

Muito obrigado pela ajuda.continuo tendo problema com os npc's vendor eles só vendem não compram e os banker também não abrem sendo que pelo meu ponto de vista o script está certo.
use os;
use uo;
use npc;
use util;

include "util/bank";
include "include/randname";
include "include/eventid";
include "include/sysevent";
include "ai/setup/modsetup";

var me := Self();

///const REACT_THRESHOLD := 35;
const REACT_THRESHOLD := 4;

if( me.name["<random>"] )
SetName( me, RandomName( me ) );
EquipFromTemplate( me, "banker" );
endif

//EnableEvents( REACT_THRESHOLD );

program banker()

if( !me.title_suffix )
var names := SplitWords(me.name);
if ( names[2] == "the" )
me.name := names[1];
endif
endif
me.title_suffix := " the banker";

///EnableEvents( SYSEVENT_SPEECH, 12 );
EnableEvents( SYSEVENT_SPEECH, REACT_THRESHOLD );

var ev;
while (1)
ev := os::wait_for_event( 120 );
if( ev )
if( ev.source.z == me.z )
Bankfunctions( ev.source, ev.text );
endif
endif
endwhile

endprogram

function Bankfunctions( you, byref text )

// code to exit if used less than 5 seconds ago.
///sleepms( 100 * Distance( me, you ) + RandomInt( 100 ) );
if( CInt( GetObjProperty( you, "#bankused" ) ) > ReadGameClock() )
return;
else
SetObjProperty( you, "#bankused", ReadGameClock() + 5 );
endif

If( !IsOpposingFaction( me, you ) )
TurnToward( you );
If( text["bank"] )
OpenBank( you );
Elseif( text["balance"] )
Balance( you);
Elseif( text["statement"] )
Balance( you );
Elseif( text["count"] )
CountItems( you );
Endif
Endif

/* Disabled due to Gold duping bug.
elseif ( text["withdraw"] )
Withdraw( you);
*/
endfunction

function CountItems( you )

var items := 0;
var weight := 0;
var bankbox := FindBankBox( you );
var objects := EnumerateItemsInContainer( bankbox );

if (bankbox)
foreach item in objects
items := items + 1;
weight := weight + item.weight;
endforeach

say( "Bank container has "+ items +" items, " + weight + " stones" );
else
say( "You don't seem to have a bank box, " + you.name);
endif

endfunction

function OpenBank( you )
Post Reply