Detect a rank change during guild update

Posts from previous Beta sessions

Detect a rank change during guild update

Postby Vlorn » Tue Nov 27, 2007 5:31 am

Question 1.
Are player ranks ONLY updated during a "guild" update? (please say yes!)

Question 2.
Assuming the answer to question 1 is yes, what would be the best way to detect a players rank change during the update process? For my mod to work successfully I'd need to know the players old and new rank.


-Vlorn
User avatar
Vlorn
WR.net Apprentice
WR.net Apprentice
 
Posts: 29
Joined: Tue Jul 04, 2006 7:57 pm

Detect a rank change during guild update

Postby zanix » Tue Nov 27, 2007 6:23 am

Yes

Get the rank data during a guild_pre hook

sudocode
Code: Select all
each( $member_id )
{
   $this->rank_ids += array(
      $member_id => $rank_id,
   );

Then get the rank data in a guild_post hook

Compare and act accordingly
Last edited by zanix on Tue Nov 27, 2007 6:26 am, edited 1 time in total.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Detect a rank change during guild update

Postby zanix » Tue Nov 27, 2007 6:24 am

You can also test in the guild hook, as the member's data will have been changed by the time this hook fires

sudocode
Code: Select all
if( $this->rank_ids[member_id] != $mermber_id )
{
   rank has changed!!
}
else
{
   rank has not changed!
}
Last edited by zanix on Tue Nov 27, 2007 6:28 am, edited 1 time in total.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Detect a rank change during guild update

Postby Vlorn » Sat Dec 08, 2007 5:18 am

How do I pass the array between functions guild_pre and guild?

-Vlorn
User avatar
Vlorn
WR.net Apprentice
WR.net Apprentice
 
Posts: 29
Joined: Tue Jul 04, 2006 7:57 pm

Detect a rank change during guild update

Postby zanix » Sat Dec 08, 2007 5:55 am

Store it in a class variable
Like $rank_ids

Then in each function, this variable can be accessed via $this->rank_ids

I would also research a bit on php classes, a good read might help out as well

sudocode
Code: Select all
class addonUpdate
{
   var $rank_ids = array()

   function guild_pre
   {
      $sql = SELECT `member_id`,`rank_id` from roster_members
      $result = sql_query($sql)
      while( $row = sql_fetch($result) )
      {
         $this->rank_ids += array(
            $row['member_id'] => $row['rank_id'],
         );
      }
   }

   function guild
   {
      if( $this->rank_ids[$member_id] != $current_id )
      {
         rank has changed!!
      }
      else
      {
         rank has not changed!
      }
   }
}
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Detect a rank change during guild update

Postby Vlorn » Sat Dec 08, 2007 10:27 am

I had done that, my code originally looked very similar to what you proposed, but found the class variable was being cleared between guild_pre and guild. When I populated the variable in my Function call (the function named <addon>Update I was able to use the data in function guild.

Not sure what I was doing wrong to cause it to get cleared between function calls. probably something stupid.

-Vlorn
User avatar
Vlorn
WR.net Apprentice
WR.net Apprentice
 
Posts: 29
Joined: Tue Jul 04, 2006 7:57 pm

Detect a rank change during guild update

Postby zanix » Sat Dec 08, 2007 10:36 am

Hmm, that's weird
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Detect a rank change during guild update

Postby PleegWat » Sat Dec 08, 2007 7:23 pm

This might be a PHP 4/5 difference.
PHP 4 passes classes by copy by default.
PHP 5 always does it by reference.

The solution is probably explicitly passing the addonUpdate class by reference all the time, but I can't test on php4 myself.

Upgrading from php4 to php5 would also fix the issue.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm


Return to Archived

Who is online

Users browsing this forum: No registered users and 0 guests

cron