ExtendedMarketPlace V1.1

Hello my name is Jar and I wanted to make subscriptions for my game. So I started making a module but then I kept going and now it has around 20 functions! If u use this a credit in the description would be appreciated!

Set the value path to your stat folder name, standard is “Stats”

If something bugs make sure to send me a message as this is the first version make sure to test your things!!

Discord: Jar_Dev#0001

Functions:

Subscriptions
IsSubscribed

This function returns true or false depending if the subscription is still active

function SS.IsSubscribed(plr, endtime)
	if os.time() > endtime then
		return false
	else
		return true
	end
end
Subscibe

This can be used to calculate the UNIX EPOCH time, you need to put in the player the amount of time and the timenotation

function SS.Subscribe(plr, timeamount ,notation)
	-- Converting timeamount to seconds --
	-- if notation = seconds then timeamount is already in seconds --
	if notation == "Minutes" then
		timeamount *= 60
	elseif notation == "Hours" then
		timeamount *= 3600
	elseif notation == "Days" then
		timeamount *= 86400
	elseif notation == "Weeks" then
		timeamount *= 604800
	elseif notation == "Months" then
		timeamount *= 2629800
	end
	return os.time() + timeamount
end
Gift

Use this to give a player a boolvalue or numbervalue, this can be used for for example gamepass gifting. Just make a BoolValue call it after the gamepass and call the function with the player who is gifting, the player who is being gifted to, the stat name, if it is a numbervalue put the amount

function SS.Gift(plr,target,stat,amount)
	--[[
		How to use: plr is the player who is gifting target is the player who is being gifted to stat is the name of the stat that is being gifted
		yourvariable.Gift(Player1,Player2,"VIP")
		yourvariable.Gift(Player1,Player2,"Money",100)	
		READ!: if the stat being gifted is a gamepass then amount is not needed if it is a NumberValue then amount is the amount being gifted
		if a gamepass is being gifted make sure you have a BoolValue named after the gamepass being gifted
	]]
	
	if game.Players:FindFirstChild(target) then
		if game.Players[target][path][stat]:IsA("NumberValue") then
			game.Players[target][path][stat].Value = tonumber(amount)
		elseif game.Players[target][path][stat]:IsA("BoolValue") then
			game.Players[target][path][stat].Value = true
		else
			return false
		end
		return true
	else
		return false		
	end
end
Boosters
BoosterActive

returns either true or false depending on if the booster is still active

function SS.BoosterActive(plr,boosttype) -- For example x2Coins
	if os.time() > plr[path][boosttype].Value then
		return false
	else
		return true
	end
end
GetTimeRemaining

returns a integer value of how much time is left on the booster

function SS.GetTimeRemaining(plr,boosttype)
	if SS.BoosterActive(plr,boosttype) then
		return plr[path][boosttype].Value - os.time()
	else
		return false
	end
end

SetBoosterTime

Used to calculate the UNIX EPOCH time returns your input in seconds so you can use boosters with os.time()

function SS.SetBoosterTime(plr,boostertype,timeamount,notation)
	-- Converting timeamount to seconds --
	
	if notation == "Minutes" then
		timeamount *= 60
	elseif notation == "Hours" then
		timeamount *= 3600
	elseif notation == "Days" then
		timeamount *= 86400
	elseif notation == "Weeks" then
		timeamount *= 604800
	elseif notation == "Months" then
		timeamount *= 2629800
	end
	return os.time() + timeamount
end
Other
Prompting

PromptGamepass:

function SS.PromptGamepass(plr,id)
	return MS:PromptGamePassPurchase(plr,id)
end

PromptPremium:

function SS.PromptPremium(plr)
	return MS:PromptPremiumPurchase(plr)
end

PromptAsset:

function SS.PromptAsset(plr,id)
	MS:PromptPurchase(plr,id)
end

PromptBundle:

function SS.PromptBundle(plr,id)
	return MS:PromptBundlePurchase(plr,id)
end

PromptProduct:

function SS.PromptProduct(plr,id)
	return MS:PromptProductPurchase(plr,id)
end

OwnsGP:
Returns true or false depending if the user owns the gamepass or has been gifted/boolvalue is true

function SS.OwnsGP(plr,id,gpname)
	if MS:UserOwnsGamePassAsync(plr,id) or plr[path][gpname].Value then
		return true
	else
		return false
	end
end

OwnsAsset:
returns true or false depending if the user owns the asset

function SS.OwnsAsset(plr,assetid)
	return MS:PlayerOwnsAsset(plr,assetid)
end

IsPremium:
returns true or false if the user is a subscriber of premium

function SS.IsPremium(plr)
	if plr.MembershipType == Enum.MembershipType.Premium then
		return true
	else
		return false
	end
end

GetProductInfo:

function SS.GetProductInfo(id,infotype)
	return MS:GetProductInfo(id,infotype)
end

GetDeveloperProductsAsync:

function SS.GetDeveloperProductsAsync()
	return MS:GetDeveloperProductsAsync()
end

IsPrivateServer:
returns true or false depending if the serevr is a private server

function SS.IsPrivateServer()
	if game.PrivateServerOwnerId ~= 0 then
		return true
	else 
		return false
	end
end

GetDate:
returns the date like 10/6/98

function SS.GetDate(num)
	return os.date("%x",num)
end

TimeConvert:
returns the numbervalue in 10:8:16 which means 10 hours 8 minutes 16 seconds

function SS.TimeConvert(num)
	local txt = ""

	local days = math.floor(num/86400)
	num = math.fmod(num, 86400)
	local hours = math.floor(num/3600)
	num = math.fmod(num, 3600)
	local minutes = math.floor(num/60)
	num = math.fmod(num, 60)
	local seconds = math.floor(num)
	if days > 0 then
		txt = txt .. days .. ":"
		txt = txt .. math.floor(hours/10) .. math.fmod(hours, 10) .. ":"
		txt = txt .. math.floor(minutes/10) .. math.fmod(minutes, 10) .. ":"
		txt = txt .. math.floor(seconds/10) .. math.fmod(seconds, 10) .. "."
	elseif hours > 0 then
		txt = txt .. hours .. ":"
		txt = txt .. math.floor(minutes/10) .. math.fmod(minutes, 10) .. ":"
		txt = txt .. math.floor(seconds/10) .. math.fmod(seconds, 10) .. "."
	elseif minutes > 0 then
		txt = txt .. minutes .. ":"
		txt = txt .. math.floor(seconds/10) .. math.fmod(seconds, 10) .. ""
	else
		txt = txt .. seconds .. ""
	end
	return txt
end
StartPacks

gives the player the rewards from the starterpack

function SS.StarterPack(plr,pack)
	local rewards = id4[pack].Rewards
	local stats = plr[path]
	local count = 1
	for i=1,#rewards/2 do
		stats[rewards[count]].Value = stats[rewards[count]].Value + rewards[count+1]
		count+=2
	end
	return
end

Roadmap:
V1.1 will feature starterpacks and some optimization
V1.2 will feature passes/battle passes
V1.3 give me suggestions

10 Likes

Hey man, not a bad resource! If you’d like, here’s some tip(s) on how you can clean up your code a little bit.

Tip #1:

for code sections like these:


you could instead simply return the returned value from the MPS call, since it is already a bool value. In other words, you can remove the “if” statement and just write return MPS:func().

You’ve already done this with some of your code, so great job on that!

Tip #2:

Now, you can call me a neat freak on this one, but I would clean up this kinda code here:

A way to clean it is by storing your notations into a dictionary, with each notation given a multiplier value. e.g:

local Notations = {
     [“Minutes”] = 60
}

— in your module script

 local multi = Notations[notation]
 timeamount *= multi

That’s all for now, lemme know if you have any questions :slightly_smiling_face:

4 Likes

Thanks! I’ll work on v1.1 right now!

1 Like

V1.1 is out with some optimization and a new feature StarterPacks! You can use this feature in a developerproducthandler by doing, EMP.StarterPack(player,packnumber) packnumber needs to be in sync with the module StarterPacks in ReplicatedStorage

I don’t understand why you wouldn’t internally store & save the endtime variable in case it is not provided as a parameter.

How To Add

To achieve this, create a dictionary in the module to ensure its access with self (To access self in module functions, they need to use a colon instead of a dot). Then, whenever a subscription/boost/etc is set, save the plr.UserId as a dict key and endtime as its value.

Then, in the Is____ functions, check if the endtime parameter is being passed and if not, get it from your internal dictionary.

Hello! I am trying to use your module but I don’t know how to setup it. I just want to make a Gifting Gamepass System.

I’m not sure why you wouldn’t internally save and save the single data point variable if it wasn’t given as an input.

I’m not sure why you’re offering some functions that can easily be written in seconds, however .Subscribe and smthn like that should stay

bro tip : if this is a resource, don’t write useless code or short code.

This is an old module and therefore should probably not be used if you are trying to make a game. The functions are outdated and yes most are useless.