DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • October 19, 2017, 08:15:59 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2   Go Down
  Print  
Author Topic: get_module_objpref and how to use it  (Read 6651 times)
0 Members and 1 Guest are viewing this topic.
GenmaC
Moderator
Codemeister
*****
Offline Offline

Posts: 430

Coder


View Profile WWW
« on: March 07, 2007, 04:12:54 PM »

Object prefs are extremely useful so I will take a stab at explaining them.  Using an objpref you can track things across players and items very easily - you would want to use an objpref if you needed to look at prefs on two different players or clans.

Function:

get_module_objpref($type, $objid, $name, $module=false)

$type is an identifier for the kind of object you are using.  So if this was for an item database, you'd have an "item" type.

$objid is the unique identifier for each object.  This is where you would use a player identifier such as acctid.

$name is the name of the object, so let's say you have one shot item named "Sword of Light", your call might be:

Code:
$swords = get_module_objpref("item",$session['user']['acctid'],"Sword of Light");

This would return the number of Sword of Light the Player has.

$module is the name of the module.  For instance, if you had a seperate module and wanted to check the item module, your call might look like:

Code:
$swords = get_module_objpref("item",$session['user']['acctid'],"Sword of Light","items");

if your module was named items.php

Function:

set_module_objpref($objtype,$objid,$name,$value,$module=false)

Same info as above.  To set the number of Sword of Light a player has to 1, your call would look like:

Code:
set_module_objpref("item",$session['user']['acctid'],"Sword of Light",1);

There is no increment_module_objpref function for some reason.

The reason this is so powerful is because you can access any player's or clan's data very easily (without making a sql call).  Say you want to make a HoF module listing all the players who have a Sword of Light, you'd do something like:

Code:
$result = db_query("select name,acctid from accounts"); // get all acctids
while($row = db_fetch_assoc($result)){
if(get_module_objpref("item",$row['acctid'],"Sword of Light")>0){
output("%s has a Sword of Light",$row['name']);
}else{
output("%s does not have a Sword of Light and therefore sucks",$row['name']);
}
}
Logged



Castle Siege - a work in progress
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3598


short, sweet and to the point


View Profile
« Reply #1 on: March 07, 2007, 05:43:22 PM »

added to the wiki! thanks for the write-up!   Smiley
Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
kickme
Global Moderator
Mod God
*****
Offline Offline

Posts: 1589


Yay for elephants!


View Profile WWW
« Reply #2 on: March 07, 2007, 07:16:50 PM »

Quote
There is no increment_module_objpref function for some reason

There is in 1.1.1
Logged

Waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3598


short, sweet and to the point


View Profile
« Reply #3 on: March 07, 2007, 07:37:37 PM »

Quote
There is no increment_module_objpref function for some reason

There is in 1.1.1

can that be appropriately noted in the wiki with an explanation?  coding is not my bailiwick.

the link to the entry on the wiki is

http://wiki.dragonprime.net/index.php?title=Get_module_objpref
Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #4 on: March 07, 2007, 09:43:52 PM »

Why do you explain the function with $session['user']['acctid'] as reference ID? That's too confusing, because objprefs using the acctid as references are generally called "prefs" and accessed by "get_module_pref()" ... ... Wink
Logged

Running for more than three years now:
ThricebornPhoenix
Codemeister
****
Offline Offline

Posts: 370


Dying is the easy part.


View Profile
« Reply #5 on: March 07, 2007, 10:53:15 PM »

I haven't been able to write up the 1.1.1 function infos yet, sorry. I don't foresee it happening soon, either (I think I'm running on negative time...), but I'll see what I can do.

This is great wiki info... if anyone else wants to contribute information for functions that still aren't documented in the wiki, that would be great. I already added pretty much all of the functions that had commented documentation in the source, but that's sadly few in 1.0.6.
Logged

"I was talking aloud to myself. A habit of the old: they choose the wisest person present to speak to; the long explanations needed by the young are wearying."
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #6 on: March 07, 2007, 10:58:08 PM »

The v1.1.1 function has already been added...
Logged

Running for more than three years now:
GenmaC
Moderator
Codemeister
*****
Offline Offline

Posts: 430

Coder


View Profile WWW
« Reply #7 on: March 08, 2007, 12:22:27 AM »

Why do you explain the function with $session['user']['acctid'] as reference ID? That's too confusing, because objprefs using the acctid as references are generally called "prefs" and accessed by "get_module_pref()" ... ... Wink

I guess clanid would be a better example (I use them to handle the war declaration/alliance clan system on castle siege) but I'm not very good at documentation, just thought I'd throw it up there since I've been using it heavily for religion/clan and stuff recently hehe

by this time next year I'll have forgotten it completely o_O
Logged



Castle Siege - a work in progress
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #8 on: March 08, 2007, 12:25:37 AM »

Yeah.. Wink acctid is the only index which shouldn't be used with objprefs... Grin Clans are a more common one (or mounts) because they are available on every server.
Logged

Running for more than three years now:
ThricebornPhoenix
Codemeister
****
Offline Offline

Posts: 370


Dying is the easy part.


View Profile
« Reply #9 on: March 11, 2007, 07:31:52 PM »

The v1.1.1 function has already been added...

I was referring to the information for functions that are new/changed in 1.1.1... or has someone done that already?
Logged

"I was talking aloud to myself. A habit of the old: they choose the wisest person present to speak to; the long explanations needed by the young are wearying."
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 143


View Profile
« Reply #10 on: October 03, 2017, 06:50:25 AM »

I run 1.1.0 - the way I got around thee being no increment fuction was to increment a different variable, and then use the set function to set the value to the variable value...and just increment the variable.

It's a three-step process istead of a one-step process but it works.

I know, nobody but me uses 1.1.0 anymore right...because older core is so terrible, right?

BUT if you are using older core...or you don't really understand how to use the increment...or, if you are like me and you LIKE more steps so that you can SEE each step...this is how it can be done.

I know I am a terrible and sloppy coder, and not too confident of my abilities, so I tend, myself, to like the extra steps so that I can SEE each function as it happens.  I am just not all that confident of getting it right when I skip steps or combine steps.  Just an idiosyncracy I have.

SO...FWIW, there is a workaround for the not having an increment function, if anyone is interested.
Logged
Anharat
Codemeister
****
Offline Offline

Posts: 266



View Profile WWW
« Reply #11 on: October 03, 2017, 11:37:01 AM »

Why do you dig up a 10 year old thread without even asking a question?  Huh
Logged

TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 143


View Profile
« Reply #12 on: October 06, 2017, 08:39:31 AM »

Why do you dig up a 10 year old thread without even asking a question?  Huh

Because I do not look at how old a thread is.  I'm not sure why that matters so much.

It was a subject I was interested in, okay?

Maybe the better question is why you and some others must absolutely find fault with everyone else. 

I have n idea why some people here are so absoultely terrible to other people?  Why the cruelty?
Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1777


You're welcome.


View Profile WWW
« Reply #13 on: October 06, 2017, 03:51:50 PM »

Because I do not look at how old a thread is.  I'm not sure why that matters so much.

It was a subject I was interested in, okay?

Maybe the better question is why you and some others must absolutely find fault with everyone else. 

I have n idea why some people here are so absoultely terrible to other people?  Why the cruelty?

Because it's a thread that is a decade old. The code has advanced great amounts since then, so further comments to it are probably irrelevant due to deprecated code, especially when they didn't actually contribute anything.

If you had an idea on it, you should have started a new thread. It's not cruelty (wow, drama, much), it's efficiency.
Logged

TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 143


View Profile
« Reply #14 on: October 06, 2017, 05:07:30 PM »

Because I do not look at how old a thread is.  I'm not sure why that matters so much.

It was a subject I was interested in, okay?

Maybe the better question is why you and some others must absolutely find fault with everyone else. 

I have n idea why some people here are so absoultely terrible to other people?  Why the cruelty?

Because it's a thread that is a decade old. The code has advanced great amounts since then, so further comments to it are probably irrelevant due to deprecated code, especially when they didn't actually contribute anything.

If you had an idea on it, you should have started a new thread. It's not cruelty (wow, drama, much), it's efficiency.

Didn't your mothers ever teach you that if you don't have something nice to say, DON'T SAY ANYTHING AT ALL??

You COULD have just let it go if efficiency is what you were after, so I call B.S.  - you were cruel and intended to be so.
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

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