//****************************************************************************
//SPHERE by : Menasoft ©1997-2007
//www.sphereserver.net
// All SPHERE script files and formats are copyright Menasoft & Partners.
// This file may be freely edited for personal use, but may not be distributed
// in whole or in part, in any format without express written permission from
// Menasoft & Partners.  All donations and contributions
// become the property of Menasoft & Partners.
//****************************************************************************
// FILE LAST UPDATED: 14-March-2007
VERSION=0.56b


// ------------------------------------------------------
[FUNCTION f_prompthandler_townname]
if ( !<ctag0.town_prompthandler_townuid> || <isempty <args>> )
  return 1
endif

local.townname=<args>
local.townLENGTH=<eval StrLen(<local.townname>)>
local.town=<ctag0.town_prompthandler_townuid>
ctag.town_prompthandler_townuid=

if ( <local.town>==0)
  return 1
endif
if ( <uid.<local.town>.type> != T_STONE_TOWN )
  return 1
endif

local.oldobj=<obj.uid>
obj=<local.town>
If (<obj.masteruid>!=<uid>)&&(!<isgm>)
  obj=<local.oldobj>
  return 1
endif

If ((<local.townLENGTH> < <def0.TOWNSCONFIG_NAME_MINLENGTH>) || (<local.townLENGTH> > <def0.TOWNSCONFIG_NAME_MAXLENGTH>))
elif ( <obj.tag0.changename_time> >= <serv.time> )
elif ( strregex([^A-Za-z0-9\s]+,<local.townname>) == 1)
elif ( <f_townsys_isnameused <local.town>,<local.townname>> )
else
  // Change the name
  f_townsys_sendsmsg <obj.uid>,The town's name has changed to <local.townname>
  obj.name=<local.townname>
  obj.tag.changename_time=<serv.time> + <def0.TOWNSCONFIG_MINTIME_NAME>
  obj.update
  update
endif

trysrc <uid> obj.sdialog d_Town_Master,0,
obj=<local.oldobj>
return 1


// ------------------------------------------------------
[FUNCTION f_prompthandler_townabbrev]
if ( !<ctag0.town_prompthandler_townuid> || <isempty <args>> )
  return 1
endif

local.townabbrev=<args>
local.townLENGTH=<eval StrLen(<local.townabbrev>)>
local.town=<ctag0.town_prompthandler_townuid>
ctag.town_prompthandler_townuid =

if ( <local.town> == 0 )
  return 1
endif
if ( <uid.<local.town>.type> != T_STONE_town )
  return 1
endif

local.oldobj=<obj.uid>
obj=<local.town>
if ( (<obj.masteruid> != <uid>) && (!<isgm>) )
  obj=<local.oldobj>
  return 1
endif

if ((<local.townLENGTH> < <def0.townsCONFIG_ABBREV_MINLENGTH>) || (<local.townLENGTH> > <def0.townsCONFIG_ABBREV_MAXLENGTH>))
elif ( <obj.tag0.changeabbrev_time> >= <serv.time> )
elif ( strregex([^A-Za-z0-9]+,<local.townabbrev>) == 1 )
elif ( <f_townsys_isabbrevused <local.town>,<local.townabbrev>> )
else
  // Change the abbrev
  f_townsys_sendsmsg <obj.uid>,The town abbreviation has changed to <local.townabbrev>
  obj.abbrev=<local.townabbrev>
  obj.tag.changeabbrev_time=<serv.time> + <def0.townsCONFIG_MINTIME_ABBREV>
  obj.update
  update
endif

trysrc <uid> obj.sdialog d_Town_Master,0
obj=<local.oldobj>
return 1


// ------------------------------------------------------
[FUNCTION f_prompthandler_towntitle]
if ( !<ctag0.town_prompthandler_townuid> || !<ctag0.town_prompthandler_thisuid> || <isempty <args>> )
  return 1
endif

local.title=<args>
local.titlelength=<eval StrLen(<local.title>)>
local.town=<ctag0.town_prompthandler_townuid>
local.thisuid=<ctag0.town_prompthandler_thisuid>
ctag.town_prompthandler_townuid=
ctag.town_prompthandler_thisuid=

If (<local.town>==0)
  return 1
elif (<uid.<local.town>.type> != T_STONE_town)
  return 1
endif

local.oldobj=<obj.uid>
obj=<local.town>
if (<obj.masteruid>!=<uid>)&&(!<isgm>)
  obj=<local.oldobj>
  return 1
endif

If ( <local.titlelength> > <def0.townsCONFIG_TITLE_MAXLENGTH> )
elif ( <obj.memberfromuid.<local.thisuid>.uid> != <local.thisuid> )
elif ( strregex([^A-Za-z0-9\s]+,<local.title>) == 1 )
else
  // Change the title
  sysmessage Title for <uid.<local.thisuid>.name> changed to: <local.title>
  try obj.memberfromuid.<local.thisuid>.guildtitle=<local.title>
endif

trysrc <uid> obj.sdialog d_Town_Master,0
obj=<local.oldobj>
return 1


// ------------------------------------------------------
[FUNCTION f_prompthandler_towndclarewar]
If ( !<ctag0.town_prompthandler_townuid> || <isempty <args>> )
  return 1
endif

local.towntext=<args>
local.townLENGTH=<eval StrLen(<local.towntext>)>
local.town=<ctag0.town_prompthandler_townuid>
ctag.town_prompthandler_townuid=

If (<local.town>== 0)
  return 1
elif (<uid.<local.town>.type>!=T_STONE_TOWN )
  return 1
endif

local.oldobj=<obj.uid>
obj=<local.town>
if ( (<obj.masteruid> != <uid>) && (!<isgm>) )
  obj=<local.oldobj>
  return 1
endif

If ((<local.townLENGTH> < <def0.townsCONFIG_NSEARCH_MINLENGTH>) || (<local.townLENGTH> > <def0.townsCONFIG_NAME_MAXLENGTH>))
elif ( strregex([^A-Za-z0-9\s]+,<local.towntext>) == 1 )
else
  // Go for dialog
  trysrc <uid> obj.sdialog d_Town_Master_Warfare_DeclareWar,0,<local.towntext>
  obj=<local.oldobj>
  return 1
endif

  trysrc <uid> obj.sdialog d_Town_Master_Warfare,0
  obj=<local.oldobj>
return 1


[EOF]