Coder Social home page Coder Social logo

kalrnlo / rankcache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from whitehillgroup/rankcache

0.0 0.0 0.0 57 KB

A library designed to make it easier to obtain up-to-date group ranking information across all of your in-game scripts.

License: MIT License

Lua 100.00%

rankcache's Introduction

RankCache

RankCache is a fully typed library designed to make it easier to obtain up-to-date group ranking information across all of your in-game scripts.

Why use this over :GetRankInGroup/:GetRoleInGroup?

  • This library ensures that you get up-to-date rank information whilst keeping API requests to a minimum.
  • It provides almost full control over when rank data is refreshed, through the use of being able
  • to change the refresh time to whatever you'd like.
  • Its this way so that there should be minimal yielding when ever any of the methods are called,
  • as its not doing the api requests within any of the methods except for ForceRefresh.

Installation methods

Method 1: Rojo

  1. Download the GitHub repository to your computer.
  2. Install Rojo and all associated Studio/VSC plugins.
  3. Use Rojo to sync the RankCache library into your Studio project. (Or build the library using rojo build -o RankCache.rbxm)

Basic Usage

local RankCache = require(game:GetService("ServerStorage").RankCache)

RankCache.Config.DefualtGroupId = 23930122
RankCache.Init()

-- Fetches Player1's role and rank for group 1234
local Role, Rank = RankCache.GetRoleAndRank(game.Players.Player1, 1234)

-- Fetches Player1's rank for group 1234
local Rank = RankCache.GetRank(game.Players.Player1, 1234)

-- Fetches Player1's role for group 1234
local Role = RankCache.GetRole(game.Players.Player1, 1234)

-- Checks if Player1 is in group 1234
local IsPlayerInGroup = RankCache.IsInGroup(game.Players.Player1, 1234)

-- Forces a refesh in the cache for Player1
local Sucess = RankCache.ForceRefresh(game.Players.Player1)

-- Creates a callback thats called whenever any players rank changes in any group
local Disconnect = RankCache.GlobalOnRankChanged(function(GroupId, Player, NewRank, OldRank)
    print(`{Player.Name}'s new rank is {NewRank} in group {GroupId}`)
end)

-- Creates a callback to be called whenever a players rank changes in the defualt group
-- that then immediatly disconnects
local Disconnect = RankCache.OnRankChanged(functiion(Player, NewRank, OldRank)
    print(`{Player.Name}'s new rank is {NewRank} in group {RankCache.Config.DefualtGroupId})`)
    Disconnect()
end)

-- Creates a callback to be called whenever a players rank changes in the group 1234
local Disconnect = RankCache.OnRankChanged(1234, functiion(Player, NewRank, OldRank)
    print(`{Player.Name}'s new rank is {NewRank} in group 1234`)
end)

More examples are available in the examples folder.

rankcache's People

Contributors

kalrnlo avatar thecakechicken avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.