DragonPrime - LoGD Resource Community

Coding Support => Coding Support Desk => Topic started by: GenmaC on March 07, 2007, 04:12:54 PM



Title: get_module_objpref and how to use it
Post by: GenmaC 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']);
}
}


Title: Re: get_module_objpref and how to use it
Post by: Elessa on March 07, 2007, 05:43:22 PM
added to the wiki! thanks for the write-up!   :)


Title: Re: get_module_objpref and how to use it
Post by: kickme 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


Title: Re: get_module_objpref and how to use it
Post by: Elessa 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


Title: Re: get_module_objpref and how to use it
Post by: XChrisX 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()" ... ... ;)


Title: Re: get_module_objpref and how to use it
Post by: ThricebornPhoenix 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.


Title: Re: get_module_objpref and how to use it
Post by: XChrisX on March 07, 2007, 10:58:08 PM
The v1.1.1 function has already been added...


Title: Re: get_module_objpref and how to use it
Post by: GenmaC 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()" ... ... ;)

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


Title: Re: get_module_objpref and how to use it
Post by: XChrisX on March 08, 2007, 12:25:37 AM
Yeah.. ;) acctid is the only index which shouldn't be used with objprefs... ;D Clans are a more common one (or mounts) because they are available on every server.


Title: Re: get_module_objpref and how to use it
Post by: ThricebornPhoenix 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?


Title: Re: get_module_objpref and how to use it
Post by: TGTarheel 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.


Title: Re: get_module_objpref and how to use it
Post by: Anharat on October 03, 2017, 11:37:01 AM
Why do you dig up a 10 year old thread without even asking a question?  ???


Title: Re: get_module_objpref and how to use it
Post by: TGTarheel on October 06, 2017, 08:39:31 AM
Why do you dig up a 10 year old thread without even asking a question?  ???

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?


Title: Re: get_module_objpref and how to use it
Post by: Aeolus 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.


Title: Re: get_module_objpref and how to use it
Post by: TGTarheel 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.


Title: Re: get_module_objpref and how to use it
Post by: Talisman on October 06, 2017, 05:09:02 PM
Children - drama out of Dragonprime.  End of story.

© 2017 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines