Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ArkShop/ArkShop/Private/Kits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ namespace ArkShop::Kits
return;
}

const unsigned time = kit_entry.value("Time", 0) * 3600;
auto currentServerTime = ArkApi::GetApiUtils().GetWorld()->TimeSecondsField();

if (time > currentServerTime)
{
Tools::Time_t timediff = Tools::GetAvailableTimeDiff(time, currentServerTime);

ArkApi::GetApiUtils().SendChatMessage(player_controller, GetText("Sender"),
*GetText("BadTimeKit"), timediff.hours, timediff.minutes);

return;
}

if (const int kit_amount = GetKitAmount(steam_id, kit_name);
kit_amount > 0 && ChangeKitAmount(kit_name, -1, steam_id))
{
Expand Down
13 changes: 13 additions & 0 deletions ArkShop/ArkShop/Private/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,19 @@ namespace ArkShop::Store
return false;
}

const unsigned time = item_entry.value("Time", 0) * 3600;
auto currentServerTime = ArkApi::GetApiUtils().GetWorld()->TimeSecondsField();

if (time > currentServerTime)
{
Tools::Time_t timediff = Tools::GetAvailableTimeDiff(time, currentServerTime);

ArkApi::GetApiUtils().SendChatMessage(player_controller, GetText("Sender"),
*GetText("BadTimeShop"), timediff.hours, timediff.minutes);

return false;
}

if (type == "item")
{
success = BuyItem(player_controller, item_entry, steam_id, amount);
Expand Down
41 changes: 41 additions & 0 deletions ArkShop/ArkShop/Private/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

namespace ArkShop::Tools
{
/* ============================================ [type definitions] ============================================ */

/**
* \brief time struct
*/
typedef struct
{
int hours; /**< \brief value for hours */
int minutes; /**< \brief value for minutes */
int secounds; /**< \brief value for secounds */

}Time_t;


inline int GetRandomNumber(int min, int max)
{
const int n = max - min + 1;
Expand All @@ -18,4 +32,31 @@ namespace ArkShop::Tools

return min + x % n;
}

/**
* \brief Gets a Time_t
*
* This functions returns a Time_t with difference of the time
*
* \param[in] AvailableTime the timer
* \param[in] ServerRunTime the current server runntime
* \return Time_t struct with the times
*/
inline Time_t GetAvailableTimeDiff(long double AvailableTime, long double ServerRunTime)
{
Time_t result = { 0 };

int timediff = int(AvailableTime - ServerRunTime);

if (0 < timediff)
{
result.hours = (int)(timediff / 3600);
result.minutes = (int)(((float)(timediff % 3600)) / 60);
result.secounds = (int)((float)((timediff % 3600) % 60));
}

return result;
}


} // namespace Tools // namespace ArkShop
35 changes: 33 additions & 2 deletions ArkShop/Configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,29 @@
"Blueprint":"Blueprint'/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_WeaponStoneClub.PrimalItem_WeaponStoneClub'"
}
]
}
},
"Startflyer": {
"DefaultAmount": 2,
"Description": "Ptera and saddle (useable 40 hours after wipe)",
"OnlyFromSpawn": false,
"Time": 40,
"Items": [
{
"Amount": 1,
"Quality": 0,
"ForceBlueprint": false,
"Blueprint": "Blueprint'/Game/PrimalEarth/CoreBlueprints/Items/Armor/Saddles/PrimalItemArmor_PteroSaddle.PrimalItemArmor_PteroSaddle'"
}
],
"Dinos": [
{
"Level": 180,
"Blueprint": "Blueprint'/Game/PrimalEarth/Dinos/Ptero/Ptero_Character_BP.Ptero_Character_BP'"
}
]
}
},
"ShopItems":{
"ShopItems":{
"ingots100":{
"Type":"item",
"Description":"Metal Ingot (100x)",
Expand Down Expand Up @@ -115,6 +135,15 @@
"MaxLevel":15,
"Blueprint":"Blueprint'/Game/PrimalEarth/Dinos/Para/Para_Character_BP.Para_Character_BP'"
},
"Pteranodon": {
"Type": "dino",
"Description": "Pteranodon (buyable 72 hours after wipe)",
"Level": 224,
"Price": 1200,
"Time": 72,
"Neutered": false,
"Blueprint": "Blueprint'/Game/PrimalEarth/Dinos/Ptero/Ptero_Character_BP.Ptero_Character_BP'"
},
"carno":{
"Type":"dino",
"Description":"Carnotaurus",
Expand Down Expand Up @@ -215,6 +244,8 @@
"NotEnoughItems":"<RichColor Color=\"1, 0, 0, 1\">You don't have enough items ({0}/{1})</>",
"SoldItems":"<RichColor Color=\"0, 1, 0, 1\">You have successfully sold items</>",
"BadLevel":"<RichColor Color=\"1, 0, 0, 1\">Required level: {0} - {1}</>",
"BadTimeShop": "<RichColor Color=\"1, 0, 0, 1\">Item available in: {0} hours, {1} minutes </>",
"BadTimeKit": "<RichColor Color=\"1, 0, 0, 1\">Kit available in: {0} hours, {1} minutes </>",
"KitsListPrice":"Price: {0}",
"KitsListFormat":"\"{0}\" - {1}. {2} left. {3}\n",
"StoreListDino":"{0}) {1}. Level: {2}. Id: {3}. Price: {4}\n",
Expand Down