Dechevious
01-23-2005, 10:00 PM
What this hack does and how it operates:
This hack was requested by Detomah (and a substantial number of others over the years) which will allow you, the admin, to control the number of games that can be played, based on the users access permission level.
The concept/design/installation of this mod is quite simple.
Example:
Usergroup A: You assign how many 'credits' they are assigned.
Usergroup B: You assign how many 'credits' they are assigned.
Lets say you set the default 'credits' to 50 for Usergroup A
Lets say you set the default 'credits' to 100 for Usergroup B
The cost to play 1 game is 1 credit.
1 Game Play is defined when the user selects the game to play and it loads. (Not when it submits a score, as he could play, and simply not submit, thus cheating by not recording his play).
When a user selects the game he wishes to play, a check is made to see if his access level can play. If no, hes given the standard no permission page. If yes, another check is made to get the users access level credit quota, then compares it wiith how many gameplays the user has remaining. If the user has the credits, 1 will be deducted, and the game will load for play. If he has no remaining credits, he will be given the 'You have no more play credits page'. (A simple match equation).
You could create a 'Cost per Game' if you really wanted to, but in this progammers eyes, its more trouble then its actually worth. It wouldnt take much to implement this to work in that fashion.
Likewise, you could change a variable or two, to allow it to work with any of the existing 'Point Systems' which you currently have in place. I dont use any of them, but its also easily done.
This mod is more or less for those who want to offer their user a 'Premium' access level package. Each premium access level would allow them additional game play credits.
Now for the hack:
QUERIES TO BE RUN: (Dont forget to add your prefix if needed)
ALTER TABLE user ADD COLUMN totalplays smallint(5) unsigned NOT NULL default '0';
ALTER TABLE usergroup ADD COLUMN playquota smallint(5) unsigned NOT NULL default '0';
IN FILE: arcade.php FIND:
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
DIRECTLY BELOW IT ADD:
$gameplaysremaining = $permissions['playquota'] - $bbuserinfo['totalplays'];
FIND:
// ############################ PLAY PAGE ################################
if ($_GET['do']=="play") {
// pre-cache templates used by all actions
$globaltemplates = array(
'ARCADE',
'arcade_header',
'arcade_play'
);
require_once('./global.php');
require_once('./includes/functions_user.php');
require_once('./includes/functions_arcade.php');
DIRECTLY BELOW IT ADD:
// ### PAY FOR PLAY MOD BY DECHEVIOUS - BEGIN
if ($bbuserinfo['totalplays'] > $permissions['playquota'] OR ($bbuserinfo['totalplays'] == $permissions['playquota']))
{
eval(print_standard_error('error_yourplayquotaexce eded'));
}
$addaplay = $bbuserinfo['totalplays'];
$addaplay = $addaplay + 1;
$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET totalplays='$addaplay' WHERE userid = $bbuserinfo[userid]");
// ### PAY FOR PLAY MOD BY DECHEVIOUS - END
SAVE YOUR FILE - EDITS ARE COMPLETE - MOVE ONTO NEXT STEP.
IN FILE: admin/usergroup.php FIND:
'pmquota' => 0, 'pmsendmax' => 5, 'attachlimit' => 1000000,
REPLACE IT WITH:
'pmquota' => 0, 'playquota' => 0, 'pmsendmax' => 5, 'attachlimit' => 1000000,
FIND:
print_yes_no_row("Can Delete Leaderboard Scores? <dfn>Allows usergroup to delete scores and comments left by other members</dfn>", 'usergroup[candelscores]', $ug_bitfield['candelscores']);
DIRECTLY UNDER IT ADD:
print_input_row("How many Game Credits are allowed ? <dfn>You can restrict user to how many games he can play in the arcade</dfn>", 'usergroup[playquota]', $usergroup['playquota'], 1, 20);
SAVE YOUR FILE - EDITS ARE COMPLETE - MOVE ONTO NEXT STEP.
IN FILE: admin/user.php FIND:
$display = array('username' => 1, 'options' => 1, 'email' => 1, 'joindate' => 1, 'lastvisit' => 1, 'posts' => 1);
REPLACE IT WITH:
$display = array('username' => 1, 'options' => 1, 'email' => 1, 'joindate' => 1, 'lastvisit' => 1, 'posts' => 1, 'totalplays' => 1);
FIND:
$searchquery = "
SELECT
user.userid, reputation, username, usergroupid, birthday_search, email,
parentemail,(options & $_USEROPTIONS[coppauser]) AS coppauser, homepage, icq, aim, yahoo, msn, signature,
usertitle, joindate, lastvisit, lastpost, posts, ipaddress, userfield.*
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
WHERE $condition
ORDER BY $orderby $direction
LIMIT $limitstart, $limitnumber
";
REPLACE IT WITH:
$searchquery = "
SELECT
user.userid, reputation, username, usergroupid, birthday_search, email,
parentemail,(options & $_USEROPTIONS[coppauser]) AS coppauser, homepage, icq, aim, yahoo, msn, signature,
usertitle, joindate, lastvisit, lastpost, posts, totalplays, ipaddress, userfield.*
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
WHERE $condition
ORDER BY $orderby $direction
LIMIT $limitstart, $limitnumber
";
FIND:
print_input_row($vbphrase['post_count'], 'user[posts]', $user['posts']);
DIRECTLY BELOW IT ADD:
print_input_row("Total Games Played", 'user[totalplays]', $user['totalplays']);
FIND:
$user['posts'] = intval($user['posts']);
DIRECTLY BELOW IT ADD:
$user['totalplays'] = intval($user['totalplays']);
FIND:
print_yes_no_row($vbphrase['display_post_count'], 'display[posts]', 1);
DIRECTLY BELOW IT ADD:
print_yes_no_row("Total Arcade Plays", 'display[totalplays]',1);
FIND:
if ($display['posts'])
{
$header[] = $vbphrase['post_count'];
}
DIRECTLY BELOW IT ADD:
if ($display['totalplays'])
{
$header[] = $vbphrase['total_plays'];
}
FIND:
if ($display['posts'])
{
$cell[] = vb_number_format($user['posts']);
}
DIRECTLY BELOW IT ADD:
if ($display['totalplays'])
{
$cell[] = vb_number_format($user['totalplays']);
}
SAVE YOUR FILE - EDITS ARE COMPLETE - MOVE ONTO NEXT STEP.
Goto Phrase Manager, Add a Phrase.
"Front-End Error Messages"
Varname: yourplayquotaexceeded
TEXT:
You have reached the limit of arcade credits which is assigned to your usergroup. You can obtain more play credits <a href="http://whateveryouwantittogotohere.com">Here</a> or by contacting the system admin.
Add another Phrase, this time in "GLOBAL Phrases".
Varname: total_plays
TEXT: Total Games Played
IN TEMPLATE: arcade_header FIND:
| <a href="arcade.php?do=challenges">Challenges</a> |
CHANGE IT TO: (note this line above may vary, dependant on which hacks you already have installed)
| <a href="arcade.php?do=challenges">Challenges</a> | You can play $gameplaysremaining more Games
Save everything, upload your files, whamo, presto, changeo, your done. Now goto your admincp and assign the number of play credits each user group is allowed, and your ready to roll.
Enjoy! (Screen shots are attached)
This hack was requested by Detomah (and a substantial number of others over the years) which will allow you, the admin, to control the number of games that can be played, based on the users access permission level.
The concept/design/installation of this mod is quite simple.
Example:
Usergroup A: You assign how many 'credits' they are assigned.
Usergroup B: You assign how many 'credits' they are assigned.
Lets say you set the default 'credits' to 50 for Usergroup A
Lets say you set the default 'credits' to 100 for Usergroup B
The cost to play 1 game is 1 credit.
1 Game Play is defined when the user selects the game to play and it loads. (Not when it submits a score, as he could play, and simply not submit, thus cheating by not recording his play).
When a user selects the game he wishes to play, a check is made to see if his access level can play. If no, hes given the standard no permission page. If yes, another check is made to get the users access level credit quota, then compares it wiith how many gameplays the user has remaining. If the user has the credits, 1 will be deducted, and the game will load for play. If he has no remaining credits, he will be given the 'You have no more play credits page'. (A simple match equation).
You could create a 'Cost per Game' if you really wanted to, but in this progammers eyes, its more trouble then its actually worth. It wouldnt take much to implement this to work in that fashion.
Likewise, you could change a variable or two, to allow it to work with any of the existing 'Point Systems' which you currently have in place. I dont use any of them, but its also easily done.
This mod is more or less for those who want to offer their user a 'Premium' access level package. Each premium access level would allow them additional game play credits.
Now for the hack:
QUERIES TO BE RUN: (Dont forget to add your prefix if needed)
ALTER TABLE user ADD COLUMN totalplays smallint(5) unsigned NOT NULL default '0';
ALTER TABLE usergroup ADD COLUMN playquota smallint(5) unsigned NOT NULL default '0';
IN FILE: arcade.php FIND:
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
DIRECTLY BELOW IT ADD:
$gameplaysremaining = $permissions['playquota'] - $bbuserinfo['totalplays'];
FIND:
// ############################ PLAY PAGE ################################
if ($_GET['do']=="play") {
// pre-cache templates used by all actions
$globaltemplates = array(
'ARCADE',
'arcade_header',
'arcade_play'
);
require_once('./global.php');
require_once('./includes/functions_user.php');
require_once('./includes/functions_arcade.php');
DIRECTLY BELOW IT ADD:
// ### PAY FOR PLAY MOD BY DECHEVIOUS - BEGIN
if ($bbuserinfo['totalplays'] > $permissions['playquota'] OR ($bbuserinfo['totalplays'] == $permissions['playquota']))
{
eval(print_standard_error('error_yourplayquotaexce eded'));
}
$addaplay = $bbuserinfo['totalplays'];
$addaplay = $addaplay + 1;
$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET totalplays='$addaplay' WHERE userid = $bbuserinfo[userid]");
// ### PAY FOR PLAY MOD BY DECHEVIOUS - END
SAVE YOUR FILE - EDITS ARE COMPLETE - MOVE ONTO NEXT STEP.
IN FILE: admin/usergroup.php FIND:
'pmquota' => 0, 'pmsendmax' => 5, 'attachlimit' => 1000000,
REPLACE IT WITH:
'pmquota' => 0, 'playquota' => 0, 'pmsendmax' => 5, 'attachlimit' => 1000000,
FIND:
print_yes_no_row("Can Delete Leaderboard Scores? <dfn>Allows usergroup to delete scores and comments left by other members</dfn>", 'usergroup[candelscores]', $ug_bitfield['candelscores']);
DIRECTLY UNDER IT ADD:
print_input_row("How many Game Credits are allowed ? <dfn>You can restrict user to how many games he can play in the arcade</dfn>", 'usergroup[playquota]', $usergroup['playquota'], 1, 20);
SAVE YOUR FILE - EDITS ARE COMPLETE - MOVE ONTO NEXT STEP.
IN FILE: admin/user.php FIND:
$display = array('username' => 1, 'options' => 1, 'email' => 1, 'joindate' => 1, 'lastvisit' => 1, 'posts' => 1);
REPLACE IT WITH:
$display = array('username' => 1, 'options' => 1, 'email' => 1, 'joindate' => 1, 'lastvisit' => 1, 'posts' => 1, 'totalplays' => 1);
FIND:
$searchquery = "
SELECT
user.userid, reputation, username, usergroupid, birthday_search, email,
parentemail,(options & $_USEROPTIONS[coppauser]) AS coppauser, homepage, icq, aim, yahoo, msn, signature,
usertitle, joindate, lastvisit, lastpost, posts, ipaddress, userfield.*
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
WHERE $condition
ORDER BY $orderby $direction
LIMIT $limitstart, $limitnumber
";
REPLACE IT WITH:
$searchquery = "
SELECT
user.userid, reputation, username, usergroupid, birthday_search, email,
parentemail,(options & $_USEROPTIONS[coppauser]) AS coppauser, homepage, icq, aim, yahoo, msn, signature,
usertitle, joindate, lastvisit, lastpost, posts, totalplays, ipaddress, userfield.*
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
WHERE $condition
ORDER BY $orderby $direction
LIMIT $limitstart, $limitnumber
";
FIND:
print_input_row($vbphrase['post_count'], 'user[posts]', $user['posts']);
DIRECTLY BELOW IT ADD:
print_input_row("Total Games Played", 'user[totalplays]', $user['totalplays']);
FIND:
$user['posts'] = intval($user['posts']);
DIRECTLY BELOW IT ADD:
$user['totalplays'] = intval($user['totalplays']);
FIND:
print_yes_no_row($vbphrase['display_post_count'], 'display[posts]', 1);
DIRECTLY BELOW IT ADD:
print_yes_no_row("Total Arcade Plays", 'display[totalplays]',1);
FIND:
if ($display['posts'])
{
$header[] = $vbphrase['post_count'];
}
DIRECTLY BELOW IT ADD:
if ($display['totalplays'])
{
$header[] = $vbphrase['total_plays'];
}
FIND:
if ($display['posts'])
{
$cell[] = vb_number_format($user['posts']);
}
DIRECTLY BELOW IT ADD:
if ($display['totalplays'])
{
$cell[] = vb_number_format($user['totalplays']);
}
SAVE YOUR FILE - EDITS ARE COMPLETE - MOVE ONTO NEXT STEP.
Goto Phrase Manager, Add a Phrase.
"Front-End Error Messages"
Varname: yourplayquotaexceeded
TEXT:
You have reached the limit of arcade credits which is assigned to your usergroup. You can obtain more play credits <a href="http://whateveryouwantittogotohere.com">Here</a> or by contacting the system admin.
Add another Phrase, this time in "GLOBAL Phrases".
Varname: total_plays
TEXT: Total Games Played
IN TEMPLATE: arcade_header FIND:
| <a href="arcade.php?do=challenges">Challenges</a> |
CHANGE IT TO: (note this line above may vary, dependant on which hacks you already have installed)
| <a href="arcade.php?do=challenges">Challenges</a> | You can play $gameplaysremaining more Games
Save everything, upload your files, whamo, presto, changeo, your done. Now goto your admincp and assign the number of play credits each user group is allowed, and your ready to roll.
Enjoy! (Screen shots are attached)