NPC Creation Failed:
Parameter 4 bust be a Struct or Integer (0) , got Struct
What does it means, someone knows how can i fix it ?
Here is the .createnpc script:
Code: Select all
use uo;
use cfgfile;
use basic;
///////////////////////////////////////////////////////////
// Purpose: Custom function to create NPCs from a package
// or otherwise.
// Params: Same as CreateNpcFromTemplate() core function.
// Returns: npc Ref to mobile object.
///////////////////////////////////////////////////////////
function CreateNpc(template, x, y, z, props := 0)
//template := CreateTemplateName(template);
var npc := CreateNpcFromTemplate(template, x, y, z, props);
return npc;
endfunction
///////////////////////////////////////////////////////////
// Purpose: Find the package that the NPC is in.
// Params: template Template name of npc.
// Returns: template Template name containing package.
///////////////////////////////////////////////////////////
function CreateTemplateName(template)
var cfg;
foreach pkgname in (polcore().packages)
cfg := ReadConfigFile(":" + pkgname + ":npcdesc");
if (cfg)
if (FindConfigElem(cfg, template))
return ":" + pkgname + ":" + template;
endif
endif
endforeach
// Not in a package, try config/npcdesc.cfg.
return template;
endfunction
///////////////////////////////////////////////////////////
// Purpose: Returns the template name without package prefix.
// Params: pkgtemplate Npc template name.
// Returns: template Bare template name.
///////////////////////////////////////////////////////////
function TemplateName(pkgtemplate)
var start := find(pkgtemplate, ":", 2) + 1;
if (!start)
return pkgtemplate;
endif
return pkgtemplate[start, len(pkgtemplate)];
endfunction
Code: Select all
use uo;
program textcmd_createnpc( who, template )
if( !template )
SendSysMessage( who, "Usage is .createnpc <template>" );
return;
endif
var forbidden := GetGlobalProperty( "ForbiddenTemplates" );
if( !forbidden )
forbidden := array;
endif
foreach monstername in forbidden
if(lower(monstername)== lower(template))
SendSysMessage( who, "This npc type is forbidden, you aren't allowed to create it." );
return;
endif
endforeach
var props array;
props.+facing := who.facing;
var loc := TargetCoordinates(who);
var result := CreateNpcFromTemplate( template, loc.x, loc.y, loc.z, props );
if (!result)
SendSysMessage( who, "NPC Creation Failed: " + result.errortext );
endif
endprogram