This is a script for letting players choose a starting town after logging into your shard.
Save the following in a text file with .js extension, and assign that file scriptID 0 in jse_fileassociations.scp to make it run for all users:
// v1.0a by Xuri
//
// Allows new characters to choose a starting town after logging in.
// First it teleports them out of danger (to the jails), freezes them and make them invulnerable,
// before presenting them with a menu with towns to choose from.
// That menu will appear to the player every time they login until they've chosen a starting location.
function onCreateDFN( objMade, objType)
{
var pUser = objMade;
if( objType == 1 && !pUser.npc)
{
pUser.frozen = true;
pUser.vulnerable = false;
pUser.SetTag( "StartTownSel", "Initialized" );
pUser.SetLocation( 5282, 1186, 0, 0 );
}
}
function onLogin( pSocket, pUser )
{
if( pUser.GetTag( "StartTownSel" ) == "Initialized" )
{
pUser.SysMessage( "Welcome to <My Shard Name>." );
pUser.SysMessage( "Please choose a starting town." );
var ret = SelectStartTown( pUser, pSocket );
}
}
//----------------------------------------------------------------
//----------------------------------------------------------------
function SelectStartTown( pUser, pSock)
{
var myGump = new Gump;
myGump.NoClose();
myGump.NoMove();
myGump.AddBackground(0, 0, 300, 230, 0xa3c);
myGump.AddText( 14, 9, 5, "Which town do you want to start in?" );
myGump.AddText( 30, 35, 5, "- Britain");
myGump.AddButton( 14, 40, 0x837, 1, 0, 1 );
myGump.AddText( 30, 55, 5, "- Jhelom");
myGump.AddButton( 14, 60, 0x837, 1, 0, 2);
myGump.AddText ( 30, 75, 5, "- Magincia");
myGump.AddButton ( 14, 80, 0x837, 1, 0, 3);
myGump.AddText( 30, 95, 5, "- Minoc");
myGump.AddButton( 14, 100, 0x837, 1, 0, 4);
myGump.AddText( 30, 115, 5, "- Moonglow");
myGump.AddButton( 14, 120, 0x837, 1, 0, 5);
myGump.AddText( 30, 135, 5, "- Skara Brae");
myGump.AddButton( 14, 140, 0x837, 1, 0, 6);
myGump.AddText( 30, 155, 5, "- Trinsic");
myGump.AddButton( 14, 160, 0x837, 1, 0, 7);
myGump.AddText( 30, 175, 5, "- Vesper");
myGump.AddButton( 14, 180, 0x837, 1, 0, 8);
myGump.AddText( 30, 195, 5, "- Yew");
myGump.AddButton( 14, 200, 0x837, 1, 0, 9);
myGump.Send( pUser.socket );
}
function onGumpPress( pSocket, myButtonID )
{
var pUser = pSocket.currentChar;
switch( myButtonID )
{
case 0: // Trying to escape the town selection?
var ret = SelectStartTown( pUser, pSocket);
pUser.SysMessage("Just pick a town...");
break;
case 1: // Britain
pUser.SysMessage("You decide to start in Britain.");
pUser.SetLocation ( 1495, 1629, 10, 0 );
break;
case 2: // Jhelom
pUser.SysMessage("You decide to start in Jhelom.");
pUser.SetLocation ( 1492, 3696, 0, 0 );
break;
case 2: // Magincia
pUser.SysMessage("You decide to start in Magincia.");
pUser.SetLocation ( 3675, 2259, 10, 0 );
break;
case 4: // Minoc
pUser.SysMessage("You decide to start in Minoc.");
pUser.SetLocation ( 2477, 411, 15, 0 );
break;
case 5: // Moonglow
pUser.SysMessage("You decide to start in Moonglow.");
pUser.SetLocation ( 4406, 1045, 0, 0 );
break;
case 6: // Skara Brae
pUser.SysMessage("You decide to start in Skara Brae.");
pUser.SetLocation ( 639, 2236, 0, 0 );
break;
case 7: // Trinsic
pUser.SysMessage("You decide to start in Trinsic.");
pUser.SetLocation ( 1832, 2779, 0, 0 );
break;
case 8: // Vesper
pUser.SysMessage("You decide to start in Vesper.");
pUser.SetLocation ( 2771, 977, 0, 0 );
break;
case 9: // Yew
pUser.SysMessage("You decide to start in Yew.");
pUser.SetLocation ( 545, 982, 0, 0 );
break;
}
pUser.frozen = false;
pUser.vulnerable = true;
pUser.SetTag( "StartTownSel", null );
}