- Joined
- Aug 25, 2006
- Messages
- 15
- Reaction score
- 0
hello,
I just figured out how the SubLeader, TenAble, RegularAble, TempAble fields in the guild table work. Well I knew how it worked but not which DB Value fits with which right.
I'm not quite sure whether this should be called a Guide or a release, but I figured guide would fit best since it has some explanation of how the system works.
I got a list of all values and rights for the ones who don't understand how the system works. The list is on the bottom of this guide
Guide
The system is based on exponentiations of 2.
Like: 2^0 = 1 => invitation
2^1 = 2 => Expulsion
If you have Invitation and Expulsion on you get 2^0+2^1 = 1+2 = 3
That's pretty much all there is to it .
What I did to figure out which value belongs to which right, everytime I selected 1 right and checked which value the database gave.
That gave me this basic list:
2^0 = 1 => invitation
2^1 = 2 => expulsion
2^2 = 4 => notice
2^3 = 8 => position change
2^4 = 16 => position name change.
Now with combining rights I checked if my theory on the values was correct. And everytime the DB values matched my calculated ones. Which is not really weird, since this way of saving rights is a commonly used method for programmers.
It's based on the way bits work. But I'll save you that explanation.
I also made a basic PHP script on how to implement this in your website.
I hoped this guilde/release helped anyone.
Script is below:
Script
List
I just figured out how the SubLeader, TenAble, RegularAble, TempAble fields in the guild table work. Well I knew how it worked but not which DB Value fits with which right.
I'm not quite sure whether this should be called a Guide or a release, but I figured guide would fit best since it has some explanation of how the system works.
I got a list of all values and rights for the ones who don't understand how the system works. The list is on the bottom of this guide
Guide
The system is based on exponentiations of 2.
Like: 2^0 = 1 => invitation
2^1 = 2 => Expulsion
If you have Invitation and Expulsion on you get 2^0+2^1 = 1+2 = 3
That's pretty much all there is to it .
What I did to figure out which value belongs to which right, everytime I selected 1 right and checked which value the database gave.
That gave me this basic list:
2^0 = 1 => invitation
2^1 = 2 => expulsion
2^2 = 4 => notice
2^3 = 8 => position change
2^4 = 16 => position name change.
Now with combining rights I checked if my theory on the values was correct. And everytime the DB values matched my calculated ones. Which is not really weird, since this way of saving rights is a commonly used method for programmers.
It's based on the way bits work. But I'll save you that explanation.
I also made a basic PHP script on how to implement this in your website.
I hoped this guilde/release helped anyone.
Script is below:
Script
Code:
<?php
/**************************************************************\
|* Script made by Martijn of the Asgard Server. *|
|* Script is free to use if the credits are kept in. *|
|* Script doesn't contain any protection against hacking *|
|* User will have to add that himself because the protection *|
|* is centralised in our website *|
\**************************************************************/
// make defines for easy checking
define('R_INVITE', 1);
define('R_EXPEL', 2);
define('R_NOTICE', 4);
define('R_POSCHANGE', 8);
define('R_POSNAMECHANGE', 16);
// guild ID used for query.
$gid = 1;
$db = odbc_connect("host", "db username", "db pass");
// query to get guild info
$query_get_guild = "SELECT Exp, Leader, SubLeader, Centurion, Ten, Regular, Temp, SubLeaderAble, CenturionAble, TenAble, RegularAble, TempAble FROM Guild WHERE Gid = $gid";
$result_get_guild = odbc_exec($db,$query_get_guild);
if(!$result_get_guild) {
echo 'error in query_get_guild<br>';
echo 'query_get_guild: <b>',$query_get_guild,'</b><br>';
exit;
}
while($r_guild = odbc_fetch_array($result_get_guild)) {
$p_exp = $r_guild["Exp"];
$p_leader = $r_guild["Leader"];
$p_subleader = $r_guild["SubLeader"];
$p_centurion = $r_guild["Centurion"];
$p_ten = $r_guild["Ten"];
$p_regular = $r_guild["Regular"];
$p_temp = $r_guild["Temp"];
$p_subleaderable = $r_guild["SubLeaderAble"];
$p_centurionable = $r_guild["CenturionAble"];
$p_tenable = $r_guild["TenAble"];
$p_regularable = $r_guild["RegularAble"];
$p_tempable = $r_guild["TempAble"];
}
// Making sure all vars have values to make sure php warnings don't come up
$r_sub_namechange = FALSE;
$r_sub_poschange = FALSE;
$r_sub_notice = FALSE;
$r_sub_expel = FALSE;
$r_sub_invite = FALSE;
// checking if the rights are on or off
if($p_subleaderable & R_POSNAMECHANGE) {
$r_sub_namechange = TRUE;
}
if($p_subleaderable & R_POSCHANGE) {
$r_sub_poschange = TRUE;
}
if($p_subleaderable & R_NOTICE) {
$r_sub_notice = TRUE;
}
if($p_subleaderable & R_EXPEL) {
$r_sub_expel = TRUE;
}
if($p_subleaderable & R_INVITE) {
$r_sub_invite = TRUE;
}
echo "r_sub_namechange = $r_sub_namechange<br>
r_sub_poschange = $r_sub_poschange<br>
r_sub_notice = $r_sub_notice<br>
r_sub_expel = $r_sub_expel<br>
r_sub_invite = $r_sub_invite<br>";
echo "<p style=\"font-size: 70%;\">Script by: Martijn - Asgard Server</p>";
?>
List
Code:
Value: 1
Right: Invitation
Value: 2
Right: Expulsion
Value: 3
Right: Invitation+Expulsion
Value: 4
Right: Notice
Value: 5
Right: Notice+Invitation
Value: 6
Right: Notice+Expulsion
Value: 7
Right: Notice+Invitation+Expulsion
Value: 8
Right: Position Change
Value: 9
Right: Position Change+Invitation
Value: 10
Right: Position Change+Expulsion
Value: 11
Right: Position change+Invitation+Expulsion
Value: 12
Right: Position Change+Notice
Value: 13
Right: Position Change+Notice+Invitation
Value: 14
Right: Position Change+Notice+Expulsion
Value: 15
Right: Position Change+Notice+Invitation+Expulsion
Value: 16
Right: Position Name Change
Value: 17
Right: Position Name Change+Invitation
Value: 18
Right: Position Name Change+Expulsion
Value: 19
Right: Position Name Change+Invitation+Expulsion
Value: 20
Right: Position Name Change+Notice
Value: 21
Right: Position Name Change+Notice+Invitation
Value: 22
Right: Position Name Change+Notice+Expulsion
Value: 23
Right: Position Name Change+Notice+Invitation+Expulsion
Value: 24
Right: Position Name Change+Position Change
Value: 25
Right: Position Name Change+Position Change+Invitation
Value: 26
Right: Position Name Change+Position Change+Expulsion
Value: 27
Right: Position Name Change+Position Change+Invitation+Expulsion
Value: 28
Right: Position Name Change+Position Change+Notice
Value: 29
Right: Position Name Change+Position Change+Notice+Invitation
Value: 30
Right: Position Name Change+Position Change+Notice+Expulsion
Value: 31
Right: Position Name Change+Position Change+Notice+Invitation+Expulsion