Ok, here you go:
wNPC:
PHP Code:
//Nickname Storage
//By: Gambet
function onActionServerSide()
{
if (params[0] == "StoreNick")
{
if (params[1][1] != player.nick)
{
echo("[Hacker Detection]: " @ player.account @ " is attempting to bypass the trigger for the Nickname Storage!");
} else
{
clientr.stored_nickname = params[1];
this.temp = clientr.stored_nickname;
if (this.temp[0] == "on")
{
//This part should be changed so that it doesn't set the player's chat, rather, shows on
//the bottom of the screen
player.chat = "The stored nickname: " @ this.temp[1] @ " will automatically be set upon login! (Press shift+2 to set your nickname to it)";
} else
{
//This part should be changed so that it doesn't set the player's chat, rather, shows on
//the bottom of the screen
player.chat = "Successfully stored the nickname: " @ this.temp[1] @ " (Press shift+2 to set your nickname to it)";
}
}
} elseif (params[0] == "SetNick")
{
player.nick = clientr.stored_nickname[1];
}
}
//#CLIENTSIDE
function onPlayerChats()
{
if (player.chat == ":savenick")
{
Initialize();
init_text2.text = player.nick;
}
}
function Initialize()
{
new GuiWindowCtrl("init_window")
{
profile = GuiBlueWindowProfile;
x = (screenwidth/2-100);
y = (screenheight/2-100);
width = 250;
height = 130;
canclose = canmaximize = canminimize = canresize = "false";
text = "Nickname Storage";
new GuiButtonCtrl("init_close")
{
profile = GuiBlueButtonProfile;
x = 145;
y = 104.5;
width = 50;
height = 20;
text = "Cancel";
}
new GuiButtonCtrl("init_button")
{
profile = GuiBlueButtonProfile;
x = 55;
y = 104.5;
width = 50;
height = 20;
text = "Store";
}
new GuiTextCtrl("init_text")
{
profile = GuiBlueTextProfile;
x = 10;
y = 20;
height = 20;
text = "Would you like to store the following nickname: ";
}
new GuiTextCtrl("init_text2")
{
profile = GuiBlueTextProfile;
x = 10;
y = 40;
height = 20;
}
new GuiCheckBoxCtrl("init_checkbox")
{
profile = GuiBlueCheckBoxProfile;
x = 10;
y = 71.5;
width = 100;
height = 20;
text = "Auto-set on Login?";
}
}
}
function init_close.onAction()
{
init_window.destroy();
}
function init_button.onAction()
{
if (init_checkbox.checked)
{
this.tosave = {"on",player.nick};
} else
{
this.tosave = {"off",player.nick};
}
triggerserver("gui",name,"StoreNick",this.tosave);
}
function onKeyPressed(code,key)
{
if (code == 306)
{
if (clientr.stored_nickname != "")
{
triggerserver("gui",name,"SetNick");
}
}
}
Control-NPC:
PHP Code:
function onActionPlayerOnline()
{
if (clientr.stored_nickname[0] == "on")
{
player.nick = clientr.stored_nickname[1];
}
}
Commands:
-Say :savenick to initialize the gui.
-Press shift+2 to automatically set your nickname to the stored nickname.
NOTE: Storing your nickname will allow you to toggle it using shift+2. As an add-on, while storing your nickname, you can choose to have it automatically set upon logging in or not.
Now, I know that you can easily save a nickname for a Kingdom, leave the Kingdom, join another Kingdom, and toggle between the two Kingdom tags even though you arn't in both kingdoms via this system the way it currently is.
This can easily be fixed, but I don't know how the Kingdom systems works, thus, I couldn't add that part on to this system, but it should be an easy addition for Stefan or any of the Kingdom staff.
Screenshot:
