Outfit impl update

This commit is contained in:
Astrologies 2021-12-29 06:55:53 -05:00
parent b54819e972
commit ca7fb7caca
2 changed files with 1 additions and 151 deletions

View File

@ -1951,156 +1951,6 @@ function setDefaults($uid) //gives default shirt and pants, body colors and wear
$check8->execute();
}
function wearingItems($type) //returns how many of the item type the user is wearing
{
$localuser = $GLOBALS['user']->id;
$check = $GLOBALS['pdo']->prepare("SELECT * FROM wearing_items WHERE uid = :u");
$check->bindParam(":u", $localuser, PDO::PARAM_INT);
$check->execute();
$count = 0;
foreach ($check as $item)
{
$iteminfo = getAssetInfo($item['aid']);
if ($iteminfo->AssetTypeId == $type)
{
$count = $count + 1;
}
}
return $count;
}
function equippedAssetByType($type) //returns the users last equipped item by type, limited to one
{
$localuser = $GLOBALS['user']->id;
$check = $GLOBALS['pdo']->prepare("SELECT * FROM wearing_items WHERE uid = :u ORDER BY whenWorn ASC");
$check->bindParam(":u", $localuser, PDO::PARAM_INT);
$check->execute();
$wearing = 0;
foreach ($check as $item)
{
$iteminfo = getAssetInfo($item['aid']);
if ($iteminfo->AssetTypeId == $type)
{
$wearing = $item['aid'];
break;
}
}
return $wearing;
}
function deequipItem($assetId)
{
$localuser = $GLOBALS['user']->id;
$item = $GLOBALS['pdo']->prepare("SELECT * FROM wearing_items WHERE uid = :u AND aid = :i");
$item->bindParam(":u", $localuser, PDO::PARAM_INT);
$item->bindParam(":i", $assetId, PDO::PARAM_INT);
$item->execute();
if($item->rowCount() > 0)
{
if (isThumbnailerAlive())
{
if (!UsersRender::RenderCooldown($localuser))
{
$deequip = $GLOBALS['pdo']->prepare("DELETE from wearing_items WHERE uid = :u AND aid = :a"); //delete db key
$deequip->bindParam(":u", $localuser, PDO::PARAM_INT);
$deequip->bindParam(":a", $assetId, PDO::PARAM_INT);
$deequip->execute();
UsersRender::RenderPlayer($localuser);
}
else
{
return "Slow down!";
}
}
else
{
return "Thumbnail Server is offline";
}
}
return true;
}
function equipItem($assetId)
{
$localuser = $GLOBALS['user']->id;
$asset = $GLOBALS['pdo']->prepare("SELECT * FROM assets WHERE id = :i");
$asset->bindParam(":i", $assetId, PDO::PARAM_INT);
$asset->execute();
if($asset->rowCount() > 0)
{
if (playerOwnsAsset($assetId))
{
$item = $GLOBALS['pdo']->prepare("SELECT * FROM wearing_items WHERE uid = :u AND aid = :i");
$item->bindParam(":u", $localuser, PDO::PARAM_INT);
$item->bindParam(":i", $assetId, PDO::PARAM_INT);
$item->execute();
if(!($item->rowCount() > 0))
{
if (isThumbnailerAlive())
{
if (!UsersRender::RenderCooldown($localuser))
{
if (!isAssetModerated($assetId))
{
//pdo object, assettypeid
$iteminfo = getAssetInfo($assetId);
$type = $iteminfo->AssetTypeId;
if (isWearable($type))
{
$maxitems = (int)typeToMaxCosmetic($type);
if (wearingItems($type) == $maxitems)
{
//grab the currently wearing asset of the type
$wearingasset = (int)equippedAssetByType($type);
//unwear current asset of that type
$deequip = $GLOBALS['pdo']->prepare("DELETE from wearing_items WHERE uid = :u AND aid = :a"); //delete db key
$deequip->bindParam(":u", $localuser, PDO::PARAM_INT);
$deequip->bindParam(":a", $wearingasset, PDO::PARAM_INT);
$deequip->execute();
}
$equip = $GLOBALS['pdo']->prepare("INSERT INTO wearing_items(uid,aid,whenWorn) VALUES(:u,:a,UNIX_TIMESTAMP())");
$equip->bindParam(":u", $localuser, PDO::PARAM_INT);
$equip->bindParam(":a", $assetId, PDO::PARAM_INT);
$equip->execute();
UsersRender::RenderPlayer($localuser);
}
}
else
{
return "Item is Moderated";
}
}
else
{
return "Slow down!";
}
}
else
{
return "Thumbnail Server is offline";
}
}
else
{
return "Already wearing this item";
}
}
else
{
return "Error Occurred";
}
}
return true;
}
function itemSalesCount($id)
{
$check = $GLOBALS['pdo']->prepare("SELECT * FROM assets WHERE id = :i");

View File

@ -30,7 +30,7 @@ else
$name = $data->name;
try {
if (Outfit::UpdateOutfit($user->id, $id, $name)) {
if (Outfit::UpdateOutfit($user->id, $outfitid, $name)) {
$outfitchange = "Outfit Updated";
}
} catch (Exception $e) {