Kyttias
11-10-2014, 01:01 PM
How can I check if a user owns at least one adoptable above a certain level?
I'd like to bar entry to certain pages until the user has an adoptable "strong enough" to protect them there. I don't need a guide on how to make a custom page, just... the database statement.
edit: Nvm, after a lot of tinkering, I got it:
#Check if user has an adoptable at least lvl 10
$mysidia = Registry::get("mysidia");
$req_lvl = 10;
$stmt = $mysidia->db->select("owned_adoptables", array("currentlevel"), "owner='{$mysidia->user->username}'");
if ($stmt >= $req_lvl) {
$msg = "You have a lvl {$req_lvl}, {$mysidia->user->username}? Awesome!";
}
else {
$msg = "{$mysidia->user->username}, you do not have a lvl {$req_lvl}.";
}
But while I'm here, any way I can get the name of said strongest adoptable?
I'd like to bar entry to certain pages until the user has an adoptable "strong enough" to protect them there. I don't need a guide on how to make a custom page, just... the database statement.
edit: Nvm, after a lot of tinkering, I got it:
#Check if user has an adoptable at least lvl 10
$mysidia = Registry::get("mysidia");
$req_lvl = 10;
$stmt = $mysidia->db->select("owned_adoptables", array("currentlevel"), "owner='{$mysidia->user->username}'");
if ($stmt >= $req_lvl) {
$msg = "You have a lvl {$req_lvl}, {$mysidia->user->username}? Awesome!";
}
else {
$msg = "{$mysidia->user->username}, you do not have a lvl {$req_lvl}.";
}
But while I'm here, any way I can get the name of said strongest adoptable?