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

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

Author Topic: Need help with a new function  (Read 2738 times)

0 Members and 1 Guest are viewing this topic.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Need help with a new function
« on: November 10, 2005, 11:34:35 am »
I've been working on a function to display players listed on the Guests table with Name  Date/Time they were added as a guest along with a Click Link to Remove them as a Guest.
However, since Relay_GUILD.php only records a player ID, I first decided to have it record 2 extra items in the Table(I hand altered the Table using the MySQL Administrator).

That worked great for recording new Guests added to the table and the original code for add and remove is pretty much untouched.

My problem is the g-damn get_uname() function in aochat.php If you look over the code below you can see were I'm testing if there was a value in the name column, then if not get it using the id column value and update that record.

Well all it returns is a big fat -1 when I use:
$this -> bot -> aoc -> get_uname($val[0])
Code: [Select]
/*
Makes a list of current Guests
*/
function guest_list($name)
{
$inside = "<font color=CCInfoHeadline>:::: <botname>'s Guest List ::::\n\n";
     
$result = $this -> bot -> db -> select("SELECT id, name, timeadd FROM guests ORDER BY id DESC");
if (!empty($result))
foreach ($result as $val)
{
if(empty($val[1]))
{
$gname = $this -> bot -> aoc -> get_uname($val[0]);
$this -> bot -> db -> query("UPDATE guests SET name = '".$gname."' WHERE id = '".$val[0]."'");
}
else
{
$inside .= "<font color=CCInfoHeader>• " . $val[1] . "</font> <a href='chatcmd:///tell <botname> <pre>guest del " . $val[1] . "'>[Remove]</a>\n";
$inside .= "<font color=CCCCTextColor>Date added:</font> <font color=CCInfoHeader>" . gmdate("dS M, H:i", $val[2]) . " GMT\n\n";
}
}
return "Guests of <botname> :: " . $this -> bot -> make_blob("click to view", $inside);
}
Any one have any idea why it's returning -1? I rather not look up 40+ guest records by Player ID and update the table by hand. Every thing works with the Function except it doesn't show old entries names.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Need help with a new function
« Reply #1 on: November 12, 2005, 07:15:48 pm »
Here is the mostly finished Updated Relay_GUILD.php
Reason I am posting this here is I hope someone can figure out the problem I listed in the previous post.

- Added a guestlist command / function
- The first time guestlist is used on an exsisting bot it will update the guests table to include columns for Guest Name, Date/Time Added, and Who added them.
- After adding the columns it will update the guest records to include that info if it doesn't exsist.
- And finally it will return a clicky link to view the guest list.

Note: For some wierd reason on my Bot it returns the name as -1 so be warned. If it doesn't return a -1 for you that do try it out on a LIVE bot could you reply with what version of AOChat.php you are using? I myself use v1.17

If you use this on a new installation of a bot it will work just fine.

ftp://xen.afraid.org/bebot_files/Relay_GUILD.php
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Need help with a new function
« Reply #2 on: November 13, 2005, 12:35:23 pm »
Hi Xenixa,

Bot comes up with:

 (You have an error in your SQL syntax; check the manual that correspon
r MySQL server version for the right syntax to use near '' at line 5)

so changed lines to:-

  $db -> query("CREATE TABLE IF NOT EXISTS guests
        (id INT NOT NULL PRIMARY KEY,
         name VARCHAR(25),
         timeadd INT NOT NULL,
         addby VARCHAR(25))");

And it works fine now.

I manually created the tables in the database and commented out the three lines as was written in the file.  Guestlist function itself works fine, adding is recording in !guestlist and removing works and updates guestlist.

Perfect :-)

Cheers,

-jj-

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Need help with a new function
« Reply #3 on: November 13, 2005, 04:26:42 pm »
Missed a ) in that copy did I?  Ooops

Copy on my file server updated. :)
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Need help with a new function
« Reply #4 on: November 17, 2005, 07:28:08 pm »
I'm currently in the process of updating and testing the Relay_GUILD module to auto-update exsisting guests tables using a different method to store their name.

Keep an eye on the Custom/Unofficial Modules forum for more info and the update later today. Then again it may already be there buy the time you read this.  :D
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Need help with a new function
« Reply #5 on: February 05, 2006, 11:33:13 pm »
Any ideas of why some people can be removed from the !guestlist and others can't?

Name1 *is* on the !guestlist.
To [botname]: !guest del Name1
[botname]: Name1 is not on the guestlist.

Same here, Name2 is on the !guestlist.
To [botname]: !guest del Name2
[botname]: Name2 has been removed from guestlist.

There's no errors on the terminal, nor in any logs. If there's no obvious solution, I'll just have to put in error checking, and make it print each variable as a member is added/removed :)
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Need help with a new function
« Reply #6 on: February 06, 2006, 07:51:55 am »
I've seen this happen also, and as far as I can tell when the bot with the current Relay_GUILD.php that I have posted checks the user ID using get_uid($guest) and it returns that they aren't on the list(when they clearly are) it seems to be chat server related. Meaning the get_uid call is timing out. Could probably add an extra layer with the UID check when removing and have it also check the $guest name variable against the Database as an OR condition.

BTW, In the past if that happens I just a wait a bit and try again. :)
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

 

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


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


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


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 711
  • 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