From ca7fb7caca966acaa517e588e970370729757828 Mon Sep 17 00:00:00 2001 From: Astrologies Date: Wed, 29 Dec 2021 06:55:53 -0500 Subject: [PATCH] Outfit impl update --- globals/functions.php | 150 ------------------------ html_api/user/avatar/outfits/update.php | 2 +- 2 files changed, 1 insertion(+), 151 deletions(-) diff --git a/globals/functions.php b/globals/functions.php index d1c3cd1..d819fde 100644 --- a/globals/functions.php +++ b/globals/functions.php @@ -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"); diff --git a/html_api/user/avatar/outfits/update.php b/html_api/user/avatar/outfits/update.php index d2862e6..1c1928a 100644 --- a/html_api/user/avatar/outfits/update.php +++ b/html_api/user/avatar/outfits/update.php @@ -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) {