Exemple #1
0
 protected function giveItemToWorld($gameId, $intItemID, $floatLat, $floatLong, $intQty = 1)
 {
     //Find any items on the map nearby
     $clumpingRangeInMeters = 10;
     $query = "SELECT *,((ACOS(SIN({$floatLat} * PI() / 180) * SIN(latitude * PI() / 180) + \n            COS({$floatLat} * PI() / 180) * COS(latitude * PI() / 180) * \n            COS(({$floatLong} - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) * 1609.344\n            AS `distance`, location_id \n            FROM locations \n            WHERE type = 'item' AND type_id = '{$intItemID}' AND game_id = '{$gameId}'\n            HAVING distance<= {$clumpingRangeInMeters}\n        ORDER BY distance ASC";
     $result = Module::query($query);
     if ($closestLocationWithinClumpingRange = @mysql_fetch_object($result)) {
         //We have a match
         $query = "UPDATE locations\n                SET item_qty = item_qty + {$intQty}\n            WHERE location_id = {$closestLocationWithinClumpingRange->location_id} AND game_id = '{$gameId}'";
         Module::query($query);
     } else {
         $itemName = $this->getItemName($gameId, $intItemID);
         $error = 100;
         //Use 100 meters
         $icon_media_id = $this->getItemIconMediaId($gameId, $intItemID);
         //Set the map icon = the item's icon
         $query = "INSERT INTO locations (game_id, name, type, type_id, icon_media_id, latitude, longitude, error, item_qty)\n                VALUES ('{$gameId}', '{$itemName}','Item','{$intItemID}', '{$icon_media_id}', '{$floatLat}','{$floatLong}', '{$error}','{$intQty}')";
         Module::query($query);
         $newId = mysql_insert_id();
         //Create a coresponding QR Code
         QRCodes::createQRCode($gameId, "Location", $newId, '');
     }
 }
Exemple #2
0
 protected function giveItemToWorld($gameId, $itemId, $floatLat, $floatLong, $intQty = 1)
 {
     $clumpingRangeInMeters = 10;
     $query = "SELECT *,((ACOS(SIN({$floatLat} * PI() / 180) * SIN(latitude * PI() / 180) + \n                COS({$floatLat} * PI() / 180) * COS(latitude * PI() / 180) * \n                COS(({$floatLong} - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) * 1609.344\n                AS `distance`, location_id \n                FROM locations \n                WHERE type = 'item' AND type_id = '{$itemId}' AND game_id = '{$gameId}'\n                HAVING distance<= {$clumpingRangeInMeters}\n            ORDER BY distance ASC";
     $result = Module::query($query);
     if ($closestLocationWithinClumpingRange = @mysql_fetch_object($result)) {
         Module::query("UPDATE locations SET item_qty = item_qty + {$intQty} WHERE location_id = {$closestLocationWithinClumpingRange->location_id} AND game_id = '{$gameId}'");
     } else {
         $item = Module::queryObject("SELECT * FROM items WHERE item_id = '{$itemId}'");
         Module::query("INSERT INTO locations (game_id, name, type, type_id, icon_media_id, latitude, longitude, error, item_qty) VALUES ('{$gameId}', '{$item->name}','Item','{$itemId}', '{$item->icon_media_id}', '{$floatLat}','{$floatLong}', '100','{$intQty}')");
         QRCodes::createQRCode($gameId, "Location", mysql_insert_id(), '');
     }
 }
Exemple #3
0
 public function createLocationWithQrCode($gameId, $strLocationName, $intIconMediaID, $dblLatitude, $dblLongitude, $dblError, $strObjectType, $intObjectID, $intQuantity, $boolHidden, $boolForceView, $boolAllowQuickTravel, $boolAllowWiggle, $boolDisplayAnnotation, $qrCode = '', $imageMatchId, $errorText)
 {
     if (!$intQuantity) {
         $intQuantity = 1;
     }
     if (!$boolAllowQuickTravel) {
         $boolAllowQuickTravel = 0;
     }
     $strLocationName = addslashes($strLocationName);
     //if ($dblError < 5) $dblError = 25; // <-- NO!
     //Check the object Type is good or null
     if (!Locations::isValidObjectType($strObjectType) or !strlen($strObjectType) > 0) {
         return new returnData(4, NULL, "invalid object type");
     }
     $query = "INSERT INTO locations \n            (game_id, name, icon_media_id, latitude, longitude, error, \n             type, type_id, item_qty, hidden, force_view, allow_quick_travel, wiggle, show_title)\n            VALUES ('{$gameId}','{$strLocationName}', '{$intIconMediaID}',\n                    '{$dblLatitude}','{$dblLongitude}','{$dblError}',\n                    '{$strObjectType}','{$intObjectID}','{$intQuantity}',\n                    '{$boolHidden}','{$boolForceView}', '{$boolAllowQuickTravel}', '{$boolAllowWiggle}', '{$boolDisplayAnnotation}')";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     $newId = mysql_insert_id();
     //Create a coresponding QR Code
     QRCodes::createQRCode($gameId, "Location", $newId, $qrCode, $imageMatchId, $errorText);
     return new returnData(0, $newId);
 }