collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: altadmin setmain <old main> <new main>  (Read 16597 times)

0 Members and 1 Guest are viewing this topic.

Offline heljeere

  • BeBot Rookie
  • *
  • Posts: 10
  • Karma: +0/-0
altadmin setmain <old main> <new main>
« on: October 07, 2010, 01:45:08 pm »
I have no idea where to post this. None of the forums really fit.

Anyway, I've had to change people's mains a number of times and it's a tedious job (if they have many alts that is). Instead of doing it manually for the Nth time i decided to change the altadmin command to do it for me.

With these changes you can "altadmin setmain <old main> <new main>" to change someone's main. The name specified in <new main> must be registered as an alt of <old main>.

Add help:

Code: [Select]
$this -> help['command']['altadmin setmain <old main> <new main>'] = "Sets <new main> as main for <old main>. <new main> must be a registered alt of <old main>.";>( Add this after the other help commands in __construct(&$bot) )

Add command processing:
Code: [Select]
case 'setmain':
return $this -> set_main($vars[2], $vars[3]);
( Add this right above the default case in command_handler($name, $msg, $origin) )

Add the actual function:
Code: [Select]
function set_main($oldmain, $newmain)
{
$oldmain = ucfirst(strtolower($oldmain));
$newmain = ucfirst(strtolower($newmain));

//Establish the main of the caller
$oldmain = $this -> bot -> core("alts") -> main($oldmain);

// Make sure $name and $alt match legal pattern for character names (only letters or numbers)
if (!preg_match("/^[a-z0-9]+$/i", strtolower($oldmain)))
{
return "##error##Illegal character name ##highlight##$oldmain##end##!##end##";
}
if (!preg_match("/^[a-z0-9]+$/i", strtolower($newmain)))
{
return "##error##Illegal character name ##highlight##$newmain##end##!##end##";
}

//Chech that new main is indeed an alt of the caller
$result = $this -> bot -> db -> select("SELECT main FROM #___alts WHERE alt = '$newmain' AND main = '$oldmain'");
if (empty($result))
{
return "##highlight##$newmain##end## is not registered as an alt of ##highlight##$oldmain##end##.";
}
else
{
$this -> bot -> db -> query("UPDATE #___alts SET main='" . ucfirst(strtolower($newmain)) . "' WHERE main = '" . ucfirst(strtolower($oldmain)) . "'");
$this -> bot -> db -> query("UPDATE #___alts SET main='" . ucfirst(strtolower($newmain)) . "', alt='" . ucfirst(strtolower($oldmain)) . "' WHERE alt = '" . ucfirst(strtolower($newmain)) . "'");
$this -> bot -> core("alts") -> create_caches();
}

return "##highlight##$newmain##end## has been registered as new main of ##highlight##$oldmain##end##.";
}
« Last Edit: October 07, 2010, 10:48:50 pm by heljeere »

Offline heljeere

  • BeBot Rookie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: altadmin setmain <old main> <new main>
« Reply #1 on: October 07, 2010, 01:49:14 pm »
Added the complete code to pastebin too for easier reading.

http://pastebin.com/GpSKMMXL

Offline heljeere

  • BeBot Rookie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: altadmin setmain <old main> <new main>
« Reply #2 on: October 07, 2010, 10:54:48 pm »
There was a slight bug that made you lose the old main in the alt list after doing setmain. I've edited the code in the original post and added:

Code: [Select]
$this -> bot -> db -> query("UPDATE #___alts SET main='" . ucfirst(strtolower($newmain)) . "', alt='" . ucfirst(strtolower($oldmain)) . "' WHERE alt = '" . ucfirst(strtolower($newmain)) . "'");
It now properly swaps your new and old mains so you don't lose and toons :)

Offline Runemy

  • BeBot Apprentice
  • ***
  • Posts: 97
  • Karma: +0/-0
    • Exalted [Age of Conan guild - Aquilonia EU]
Re: altadmin setmain <old main> <new main>
« Reply #3 on: October 08, 2010, 03:11:01 am »
Thanks for this one mate! :)
Wood of Exalted
Age of Conan
Aquilonia - EU

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: altadmin setmain <old main> <new main>
« Reply #4 on: October 13, 2010, 04:40:00 pm »
At one point we were I was looking at restructuring the database a bit for the next BeBot release and this was one of the things addressed in the new design. Instead of the concept of mains and alts characters are just characters. The new design has every character tied to an account ID that is unique to BeBot. So a player simply registers their characters. By default the first character would be the display name (main) for the BeBot account. I designed security so that the display name could be changed to any character registered to the account by the player. I also had the option of setting a custom display name if that feature was enabled by the bot's administrator.

Unfortunately I only got the design work done before real life got insanely busy. :)

Offline Odinochka

  • BeBot Rookie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: altadmin setmain <old main> <new main>
« Reply #5 on: October 18, 2010, 07:11:38 am »
At one point we were I was looking at restructuring the database a bit for the next BeBot release and this was one of the things addressed in the new design. Instead of the concept of mains and alts characters are just characters. The new design has every character tied to an account ID that is unique to BeBot. So a player simply registers their characters. By default the first character would be the display name (main) for the BeBot account. I designed security so that the display name could be changed to any character registered to the account by the player. I also had the option of setting a custom display name if that feature was enabled by the bot's administrator.

Unfortunately I only got the design work done before real life got insanely busy. :)

I have it working, completely overhauled the alts module etc. For version 5.4(i think :P) tho, contact me on msn([email protected]) if you need the code and the database sample.
PS.
Napoleon had no horse cause he was too short to ride it. On the painting it's white but it was done only for his ego.

Offline Tsamoonia

  • BeBot User
  • **
  • Posts: 35
  • Karma: +0/-0
    • The Great Ones
Re: altadmin setmain <old main> <new main>
« Reply #6 on: December 06, 2010, 10:42:58 pm »
im getting an error i_d something or another for line 73

Offline Tsamoonia

  • BeBot User
  • **
  • Posts: 35
  • Karma: +0/-0
    • The Great Ones
Re: altadmin setmain <old main> <new main>
« Reply #7 on: December 06, 2010, 10:43:42 pm »
im getting an error i_d something or another for line 73

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 208
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal