DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • December 16, 2018, 07:18:10 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2 3 4   Go Down
  Print  
Author Topic: lays system  (Read 12300 times)
0 Members and 1 Guest are viewing this topic.
Hex
Guest
« on: December 05, 2004, 11:03:08 PM »

In the spirit of LoRD, I just threw together a quick module for tracking lays. It's working fine for me on my test server, so I'm hoping no one else runs into any problems. I'm sorry if anyone else has already done this, but I couldn't find it anywhere and it's a feature I don't think any LoRD clone should be without. (Plus I'm using it in another module I'm writing and figured why not make it global)

http://dragonprime.net/users/Hex/lays.zip

I made a patch for the lovers.php module so it'll work properly with seth and violet. (you're going to need this if you want the lays module to work...)

http://dragonprime.net/users/Hex/lovers.diff

I also just finished patching the HoF to rank players by most/least lays.

http://dragonprime.net/users/Hex/hof.diff

I hope this doesn't break anything for anyone, but so far it's all working just fine for me.

Enjoy, and let me know if there are any problems.  (though you should all know to make backups before you apply the patches, just in case Wink )
« Last Edit: December 08, 2004, 10:14:53 PM by Hex » Logged
Dopple
Guest
« Reply #1 on: December 06, 2004, 01:42:27 AM »

Hrm.. what's the saying about idle hands and someone's work..?   Roll Eyes

Well, my hands weren't idle, but I almost have a modification for this that is a bit less intrusive (using module prefs instead of editing the account table, and doesn't require the patch to hof.php).  I can send the result to you if you want..

I don't see any way to get around the need for hooks in lovers.php, but maybe someone more familiar with the code could pipe in if they knew anything.

I really shouldn't be working on this at the moment, but I couldn't resist..  Wink
Logged
Hex
Guest
« Reply #2 on: December 06, 2004, 09:51:51 AM »

I originally had it using the prefs instead of the accounts table, but I also wanted to have the HoF entry (what's the use of tracking lays if ya can't brag about it, eh?) and I figured the best way for this was probably using sql

although, just so ya know.. the HoF patch isn't required. I just did that for my own use. but from what I understand of the CC license, I'm required to put out the patch for others to see/use. another thing about the HoF patch, it won't break things if the lays module isn't installed.

Code:
if(is_module_installed('lays'){
     addnav("Lays", "hof.php?op=lays&subop=$subop&page=$page");
}

I'm trying to figure out a way to include the HoF page inside the lays module itself so the hof won't require patching, but this is just what I threw together as a quick solution. because of the way hof.php is setup, I'm not really sure if I can make an internal hof page just for lays and have it show on the actual hof like it's supposed to be there. if anyone can help with this I'd really appreciate it.
Logged
Rowne
Guest
« Reply #3 on: December 06, 2004, 10:57:04 AM »

Not sure whether it's of any help but the module Show Recent Players (http://dragonprime.net/users/mProwler/recentplayers.zip) adds a nav to the Player List.  This is the only module I can think of immediately that adds a nav to one of the core subpages, so perhaps you could use that?  As I said, I'm not sure if this is any help or not but I thought I'd suggest it.

I'm very interested in this one too but I too am a bit iffy about the Accounts database being modded.  So I'll just hang on a bit and see how it develops but from what I can understand, it sounds to be awesome.
Logged
Hex
Guest
« Reply #4 on: December 06, 2004, 01:32:16 PM »

it only adds one field to the accounts table called 'lays'

when the module is uninstalled, it removes the field and only the field. I'm not sure if this is what you're "iffy" about, but I'm using it on two servers and they're both handling it fine. I've done EXTENSIVE testing of the add/drop field so as to ensure it wouldn't remove any vital info.

The reason I added a field as opposed to a whole extra table (such as in the instance of lonnys forums) is because it was just dumb to have an extra table with just one value, plus I think it would be a bit of extra work using an extra table to make sure it stores the right number of lays with the right account. Also, I prefer the additional ease of being able to use $session['user']['lays']++;

I will be looking at the recent players code here in a bit, though because that would have to use the existing db to be able to sort results, I'm not sure it's what I'm looking for. *doesn't want to try to figure out how to sort players by most lays using just php*

well, I'll keep playing with it at any rate. though unless anyone can tell me exactly why adding a field to the accounts table is such a bad thing, I'm probably going to leave it the way it is.
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #5 on: December 06, 2004, 01:46:30 PM »

Actually, as most of the people do enjoy... the like things being done from the userpref* function, that is attributed to the mod...

And yes, you can call in these values to generate a listing...** It is much better to keep the tracking in the module itself, rather than adding a new column to the accounts table.

*
Code:
set_module_pref/get_module_pref
**
Code:
$sql = "SELECT userid FROM module_userprefs WHERE modulename='lays'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$id = $row['userid'];
$sql2 = "SELECT name FROM accounts WHERE acctid=$id";

The generate your list. Meh, that should work, might have to toy around with it. Then, to gen the list of lays, just have it fetch the acctid's userprefs from their account. Not too hard.
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Hex
Guest
« Reply #6 on: December 06, 2004, 01:58:58 PM »

thanks Sichae, I'm working on it right now. version 2.0 will be posted as soon as I get it right..

One thing about adding the HoF entry.. I hook into the hof with module_addhook(footer-hof); to add the nav..

obviously when I go to the hof, I see the nav for lays HoF.  Is there any way to keep it on the hof page, as opposed to running it's own little page and having to add a nav back to the hof?  I'd also like to keep the sorting somewhat integrated with the current HoF (best/worst)

any thoughts?
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #7 on: December 06, 2004, 02:07:51 PM »

For the second part, when you generate the list, you would have to order it by either ASC or DESC, depending on if you want worst to best or best to worst.

The first part... I am not too sure about... it would most likely require a modding of the hof.php.
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Rowne
Guest
« Reply #8 on: December 06, 2004, 02:32:31 PM »

There's no need to be defensive Hex, after all I said that I did like the sound of it and would like to try it.  The only reason I was iffy over it was cleanliness reasons really.  Should a core update occur, it might make things more difficult if there are stuffs in the core tables which shouldn't be there ~ since the core tables are for the core files after all.  This is why I usually prefer seeing things use module_prefs myself.  I don't doubt you though, I could uninstall it but my point is that if you are already working on a userpref version, I'll just wait for that and save myself having to uninstall the mod should I ever upgrade my LoGD.

If that makes sense?

I don't doubt you at all and when the userpref variant is released I'll be one of the first to test it so null persp, eh?

Mostly though it is just a cleanliness thing so blame my personal tastes more than anything else.  I am a little obsessive about such things.  Too much so, I plead guilty to that.
Logged
Hex
Guest
« Reply #9 on: December 06, 2004, 02:49:09 PM »

Rowne:  sorry if I seemed to get a bit defensive, but really I wasn't.

I can respect the preference in the use of moduleprefs. I actually like that better myself. but being a dummy with sql queries, (I did not know I could pull moduleprefs out the way Sichae pointed out to me) I did this the only way I knew how.

As for the moduleprefs variant, I'm working on the internal HoF part, though I'm REALLY having a hard time with it. I have uploaded the new version that uses module prefs. lovers.php will still need patched, but the hof patch has been removed.

Before I go back to coding, I'd like to thank you all for your input. Hopefully I can use my newfound knowledge in future modules in order to expand on them better.

Anyone who might actually be using version 1.0 is encouraged to uninstall it before updating to 2.0

sorry if I messed anyone up =/
« Last Edit: December 06, 2004, 03:08:54 PM by Hex » Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #10 on: December 06, 2004, 03:15:27 PM »

I can respect the preference in the use of moduleprefs. I actually like that better myself. but being a dummy with sql queries, (I did not know I could pull moduleprefs out the way Sichae pointed out to me) I did this the only way I knew how.

Best to learn now. Any you are welcome ^^
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Hex
Guest
« Reply #11 on: December 06, 2004, 04:02:43 PM »

is there any way to pull multiple fields from the db and assign them as variables for use elsewhere?

here's what I have for the HoF portion so far (sql part):

Code:
$sql = "SELECT userid,lays FROM module_userprefs WHERE modulename='lays'";
      $result = db_query($sql);
      $row = db_fetch_assoc($result);
      $id = $row['userid'];
      $sql2 = "SELECT name,sex,race FROM " .db_prefix("accounts")." WHERE locked=0 $nosu acctid=$id LIMIT 0,$toplist";

from what I understand, $sql is going to pull out the id of the user, and the number of lays associated with that user. is there any way I can ORDER BY 'lays' in the $sql2 statement?

I'm sure I'll have more questions, as I may be trying to do too much at once.  The desired output is going to be something like:
Code:
Rank  |  Name      | Gender | Race    | Lays
  1      Hex         Male     Elf       10
  2      OtherGuy    Male     Human      5
  3      AGirl       Female   Felyne     3
and so on...

Don't worry, I've asked my fiancee for nothing more than SQL reference books for christmas, so with any luck I won't have to keep asking these potentially stupid questions =)
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #12 on: December 06, 2004, 04:04:22 PM »

At the end of the SQL statement:

Code:
$lays = $row['lays'];

$sql2 = "SELECT name,sex,race FROM " .db_prefix("accounts")." WHERE locked=0 $nosu acctid=$id LIMIT 0,$toplist ORDER BY $lays DESC"

That will list them in descending order, from most to least...

You have to work that in somewhere, but that is what you want.
« Last Edit: December 06, 2004, 04:07:03 PM by Sichae » Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Rowne
Guest
« Reply #13 on: December 06, 2004, 05:07:40 PM »

I'm sure you didn't mess anyone up, Hex.  Don't worry, I was only explaining my reason for the preference.  I'm still genuinely looking forward to seeing this and it's always nice to see the evolution of a new coder.  What you learn now will only aid you in creating more grand and complex modules in the future.  The sobriety module that you have under your belt so far is absolutely wonderful.  So keep at it, I can bet there are a few watching your progress and the mods you release, as am I.

Hee, anyway, I'm just waiting for the results of this current train of thought then I'm going to give it a shot!  My players are the kind who always accept things in good humour and they'll love a good joke like this one, being able to track who the server's largest pimp is.  Though how they'll react when they actually find out is ... not for me to know.  Though it'll be priceless to see that reaction.  ^.^
Logged
Hex
Guest
« Reply #14 on: December 06, 2004, 05:52:44 PM »

Rowne, as for future modules, I've been working on a HUGE one for about a month now. Each time I progress a bit more I end up taking a break to write something else that comes to mind. The sobriety thing was on my todo list, I had a moment of inspiration one night and whipped it up when yet another user was complaining about the inability to work. I wrote a couple of lodge modules as well, but haven't released them as I think they may upset the balance of other servers. the way I run mine, though, it's working out just fine.

I definately appreciate the praise in your last post. Good to know there's someone out there who like something I've done.

As of right now, the lays module is working (if you patch the lovers.php).  I'm working on the HoF still, but I'm still having problems pulling the variables out of the db correctly. hopfully I'll have all this figured out over the next couple of days. (don't quote me on that, going to be working a ton of hours this week so may not have much time to put into coding)

also, you mentioned the 'server pimp'  that is something I've already implemented into another module. I was considering building it into the lays module, however. whacha think?   (currently it works the same way the VillageIdiot thing works in Lonnys Castle. sets the title to pimp, then pulls a user from the db with the title 'pimp', so it doesn't accurately display the true pimp just yet. but I have some ideas on how to make it work properly. )  first things first though! heh

Well, enjoy
Logged
Pages: [1] 2 3 4   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
91 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search