R1KO / VIP-Core

GNU General Public License v3.0
50 stars 34 forks source link

feat(VIP-Core): make it possible to add a local vip before database checks and before OnClientPutInServer #111

Closed maxime1907 closed 1 year ago

maxime1907 commented 2 years ago

We can use this in free vip giveaway module like this:

public void OnClientPutInServer(int client)
{
    if (GetConVarInt(g_Cvar_MinPlayers) != 0)
        return;

    char vipGroup[16];
    GetConVarString(g_Cvar_VIPGroup, vipGroup, sizeof(vipGroup));

    if (client && IsClientInGame(client) && !IsFakeClient(client) && !VIP_IsClientVIP(client))
    {
        VIP_GiveClientVIP(_, client, 0, vipGroup, false);
    }
}

Example module: https://gitlab.com/counterstrikesource/sm-plugins/vip-freevipgiveaway

R1KO commented 2 years ago

I don't understand why this is necessary. There is no guarantee that the database will respond before the OnClientPutInServer event occurs. I think the best way would be to use forward https://github.com/R1KO/VIP-Core/blob/master/addons/sourcemod/scripting/include/vip_core.inc#L176