#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../common/HPMi.h"
#include "../map/script.h"
#include "../map/pc.h"

#include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)

HPExport struct hplugin_info pinfo = {
	"bank_vault",	// Plugin name
	SERVER_TYPE_MAP,// Which server types this plugin works with?
	"0.1",			// Plugin version
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)
};

BUILDIN(bank_vault) {
	TBL_PC *sd;
	if ( script_hasdata(st,2) ) {
		if ( data_isstring( script_getdata(st,2) ) )
			sd = map->nick2sd( script_getstr(st,2) );
		else
			sd = map->id2sd( script_getnum(st,2) );
	} else
		sd = script->rid2sd(st);
	if ( sd )
		script_pushint( st, sd->status.bank_vault );
	else
		script_pushint(st,0);
	return true;
}

HPExport void plugin_init (void) {
	map = GET_SYMBOL("map");
	script = GET_SYMBOL("script");
	addScriptCommand( "bank_vault", "?", bank_vault );
}