Praryo Innovation
  • Praryo Innovation
  • Store
  • Discord
  • 🐌CFX Keymaster
    • Asset Escrow
  • PAID RESOURCES
    • 👕cfx-praryo-clperms
      • 📝Configuration
      • ⚒️Clothing Framework
    • 🎗️cfx-praryo-subscriptions
      • 📝Configuration
      • 👾Usage
    • ☠️cfx-praryo-deathcam
      • 📝Configuration
    • 💻cfx-praryo-deathscreen
      • 📝Configuration
      • 👾Events / Exports
Powered by GitBook
On this page
  • Exports
  • Events
  1. PAID RESOURCES
  2. cfx-praryo-subscriptions

Usage

This page contains details on how to use script APIs.

Exports

Server-Side Exports

getPlayerSubscriptions

This export can be used if you want to retrieve all subscriptions of the target player.

// Usage example
RegisterNetEvent("exampleEvent", function()
   local Player = Framework.Functions.GetPlayer(source)
   local currentSubscriptions = exports['cfx-praryo-subscriptions']:getPlayerSubscriptions(Player.PlayerData.source)
	
   print(json.encode(currentSubscriptions, {
     indent = true
   }))
end)

// Output (Array): {"level_1", "level_2"}
// level_1, level_2 comes from the Config.Subscriptions index.

hasPlayerSubscription

This export can be used to determine whether a player has a specific subscription.

// Usage example
RegisterNetEvent("exampleEvent", function()
   local Player = Framework.Functions.GetPlayer(source)
   local hasSub = exports['cfx-praryo-subscriptions']:hasPlayerSubscription(Player.PlayerData.source, "level_1")
	
   if hasSub then
      print("Subscribed to level_1 subscription.")
   else
      print("Not subscribed to level_1 subscription.")
   end
end)

addPlayerSubscription

This export can be used to add pending subscriptions using your scripts.

// Usage example
RegisterNetEvent("exampleEvent", function()
   local Player = Framework.Functions.GetPlayer(source)
   local success, message, message_type = exports['cfx-praryo-subscriptions']:addPlayerSubscription(Player.PlayerData.source, "level_1")
	
   if success then
      print("Added subscription pending to player")
   else
      print("Failed to add (".. message_type .."): ".. message .."")
   end
end)

removePlayerSubscription

This export can be used to remove subscriptions using your scripts.

// Usage example
RegisterNetEvent("exampleEvent", function()
   local Player = Framework.Functions.GetPlayer(source)
   local success, message, message_type = exports['cfx-praryo-subscriptions']:removePlayerSubscription(Player.PlayerData.source, "level_1")
	
   if success then
      print("Remove subscription from player")
   else
      print("Failed to remove (".. message_type .."): ".. message .."")
   end
end)

Client-Side Exports

getPlayerSubscriptions

This export can be used if you want to retrieve all subscriptions of the target player.

// Usage example
RegisterNetEvent("exampleEvent", function()
   local currentSubscriptions = exports['cfx-praryo-subscriptions']:getPlayerSubscriptions()
	
   print(json.encode(currentSubscriptions, {
     indent = true
   }))
end)

// Output (Array): {"level_1", "level_2"}
// level_1, level_2 comes from the Config.Subscriptions index.

hasPlayerSubscription

This export can be used to determine whether a player has a specific subscription.

// Usage example
RegisterNetEvent("exampleEvent", function()
   local hasSub = exports['cfx-praryo-subscriptions']:hasPlayerSubscription("level_1")
	
   if hasSub then
      print("Subscribed to level_1 subscription.")
   else
      print("Not subscribed to level_1 subscription.")
   end
end)

Events

Server-Side Events

Usage:

-- Event when a player redeem a subscription
AddEventHandler("cfx-praryo-subscriptions:serverEvents:newSubscription", function(source, subscription)
   print("[".. source .."] Subscription added: " .. subscription)
end)

-- Event when admin remove a subscription from player
AddEventHandler("cfx-praryo-subscriptions:serverEvents:removeSubscription", function(source, subscription)
   print("[".. source .."] Subscription removed: " .. subscription)
end)

Example:

AddEventHandler("cfx-praryo-subscriptions:serverEvents:newSubscription", function(source, subscription)
   local Player = Framework.Functions.GetPlayer(source)
	
   if subscription == "level_1" then
      exports.ox_inventory:AddItem(source, 'bread', 4)
   end
end)

Client-Side Events

Usage:

RegisterNetEvent("cfx-praryo-subscriptions:clientEvents:newSubscription", function(subscription)
   print("Subscription added: " .. subscription)
end)

RegisterNetEvent("cfx-praryo-subscriptions:clientEvents:removeSubscription", function(subscription)
   print("Subscription removed: " .. subscription)
end)

Example:

RegisterNetEvent("cfx-praryo-subscriptions:clientEvents:newSubscription", function(subscription)
   if subscription == "level_1" then
      exports.ox_inventory:openInventory('stash', { id = 'level_1_subscription' })
   end
end)

Last updated 1 year ago

🎗️
👾