Code Monkey home page Code Monkey logo

cs2-vipcore's Introduction

GitHub all releases

cs2-VIPCore

If you find an error or anything else. Please message me in discord: thesamefabius

Installation

  1. Install CounterStrike Sharp, Metamod:Source
  2. Download VIPCore
  3. Unpack the archive and upload it to the game server (example path: addons/counterstrikesharp/plugins)

Put the modules in this path addons/counterstrikesharp/plugins

Commands

Command Description
css_vip_reload or !vip_reload Reloads the configuration (@css/root)
css_vip_adduser <steamid or accountid> <vipgroup> <time or 0 permanently> Adds a VIP player (for server console only)
css_vip_updateuser <steamid or accountid> <group or -s> <time or -s> Updates the player's VIP (for server console only)
css_vip_deleteuser <steamid or accountid> Allows you to delete a player by SteamID identifier (for server console only)
css_vip or !vip Opens the VIP menu

Configs

Located in the folder addons/counterstrikesharp/configs/plugins/VIPCore

Core.json

{
  "TimeMode": 0,		   // 0 - seconds | 1 - minutes | 2 - hours | 3 - days)
  "ServerId": 0,		   // SERVER ID
  "UseCenterHtmlMenu": true,	   //If `true`, the menu will be in the center, if `false`, it will be in the chat. Note that if you have another plugin that uses `CenterHtml`, server crashes may occur
  "ServerIP": "0.0.0.0", 	   // default ip
  "ServerPort": 27015, 		   // default port
  "ReOpenMenuAfterItemClick": true,//Whether to reopen the menu after selecting an item | true - yes | false - no
  "VipLogging": true,	   	   //Whether to log VIPCore | true - yes | false - no
  "Connection": {
	"Host": 	"host",
	"Database": "database",
	"User": 	"user",
	"Password": "password",
	"Port": 3306
  }
}

vip.json

{
  "Delay": 2.0
  "Groups": {
    "VIP1": {
      "Values": {
        "feature1": value1,
	"feature2": value2
      }
    }
  }
}

Example Module

using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using VipCoreApi;

namespace VIPMyModule;

public class VIPMyModule : BasePlugin
{
    public override string ModuleAuthor => "Author";
    public override string ModuleName => "[VIP] My Module";
    public override string ModuleVersion => "1.0.0";

    private MyPlugin _myPlugin;

    private IVipCoreApi? _api;
    private PluginCapability<IVipCoreApi> PluginCapability { get; } = new("vipcore:core");

    public override void OnAllPluginsLoaded(bool hotReload)
    {
        _api = PluginCapability.Get();
        if (_api == null) return;

        _api.OnCoreReady += () =>
        {
            _myPlugin = new MyPlugin(this, _api);
            _api.RegisterFeature(_myPlugin);
        };
    }

    public override void Unload(bool hotReload)
    {
        _api?.UnRegisterFeature(_myPlugin);
    }
}

public class MyPlugin : VipFeatureBase
{
    public override string Feature => "MyFeature";
    private TestConfig _config;

    public MyPlugin(VIPMyModule vipMyModule, IVipCoreApi api) : base(api)
    {
        vipMyModule.AddCommand("css_viptestcommand", "", OnCmdVipCommand);
        _config = LoadConfig<TestConfig>("VIPMyModule");
    }

    public override void OnPlayerSpawn(CCSPlayerController player)
    {
        if (PlayerHasFeature(player))
        {
            PrintToChat(player, $"VIP player - {player.PlayerName} has spawned");
        }
    }

    public override void OnSelectItem(CCSPlayerController player, IVipCoreApi.FeatureState state)
    {
        if (state == IVipCoreApi.FeatureState.Enabled)
        {
            PrintToChat(player, "Enabled");
        }
        else
        {
            PrintToChat(player, "Disabled");
        }
    }
    
    public void OnCmdVipCommand(CCSPlayerController? player, CommandInfo info)
    {
        if (player == null) return;

        if (IsClientVip(player) && PlayerHasFeature(player))
        {
            PrintToChat(player, $"{player.PlayerName} is a VIP player");
            return;
        }

        PrintToChat(player, $"{player.PlayerName} not a VIP player");
    }
}

public class TestConfig
{
    public int Test1 { get; set; } = 50;
    public bool Test2 { get; set; } = true;
    public string Test3 { get; set; } = "TEST";
    public float Test4 { get; set; } = 30.0f;
}

cs2-vipcore's People

Contributors

partiusfabaa avatar pandathebeasty avatar crashzk avatar t3marius avatar xshadowbringer avatar daffyyyy avatar hobsrkm avatar ilyhalight avatar sashaxser avatar panikajoreserv 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.