Raised This Month: $51 Target: $400
 12% 

Comand to give vip


Post New Thread Reply   
 
Thread Tools Display Modes
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 09-21-2017 , 15:17   Re: Comand to give vip
Reply With Quote #11

I haven't written anything for a while ^^

PHP Code:
#include <sourcemod>
#include <sdktools>
 
#pragma newdecls required
#pragma semicolon 1

#define TAG_MESSAGE "[\x02VIP\x01]"

public Plugin myinfo =
{
    
name "Give VIP",
    
author "B3none",
    
description "Temporarily give players VIP in the server.",
    
version "0.1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=301305"
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_addstatus"addStatusADMFLAG_GENERIC);
}

public 
Action addStatus(int clientint target)
{
    if (!
IsValidClient(client) || !IsValidClient(target)) {
        return;
    }
    
    
    
char clientName[64];
    
char targetName[64];
    
    
GetClientName(clientclientNamestrlen(clientName));
    
GetClientName(targettargetNamestrlen(targetName));
    
    if (
CheckCommandAccess(target"sm_admin_check"ADMFLAG_RESERVATION)) {
        
AddUserFlags(targetAdmin_Reservation);
    }
    
    
PrintToChatAll("%s %s granted VIP access to %s"TAG_MESSAGEclientNametargetName);
}

stock bool IsValidClient(int client)
{
    return (
client <= || client MAXPLAYERS+|| !IsClientInGame(client));

In theory this code should work but if anyone else wants to suggest otherwise by all means do so

If you have any questions then feel free to ask and I will explain what I have written to you from a PHP developers perspective
__________________

Last edited by B3none; 09-21-2017 at 15:19.
B3none is offline
bbz
Junior Member
Join Date: Jan 2016
Old 09-21-2017 , 17:11   Re: Comand to give vip
Reply With Quote #12

Quote:
Originally Posted by Bacardi View Post
Btw @op, are you using any other admin plugins (ex. SourceBans?) than SM basic admin system ?
sourcebans

Thanks.
bbz is offline
bbz
Junior Member
Join Date: Jan 2016
Old 09-21-2017 , 17:19   Re: Comand to give vip
Reply With Quote #13

Quote:
Originally Posted by b3none View Post
I haven't written anything for a while ^^

PHP Code:
#include <sourcemod>
#include <sdktools>
 
#pragma newdecls required
#pragma semicolon 1

#define TAG_MESSAGE "[\x02VIP\x01]"

public Plugin myinfo =
{
    
name "Give VIP",
    
author "B3none",
    
description "Temporarily give players VIP in the server.",
    
version "0.1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=301305"
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_addstatus"addStatusADMFLAG_GENERIC);
}

public 
Action addStatus(int clientint target)
{
    if (!
IsValidClient(client) || !IsValidClient(target)) {
        return;
    }
    
    
    
char clientName[64];
    
char targetName[64];
    
    
GetClientName(clientclientNamestrlen(clientName));
    
GetClientName(targettargetNamestrlen(targetName));
    
    if (
CheckCommandAccess(target"sm_admin_check"ADMFLAG_RESERVATION)) {
        
AddUserFlags(targetAdmin_Reservation);
    }
    
    
PrintToChatAll("%s %s granted VIP access to %s"TAG_MESSAGEclientNametargetName);
}

stock bool IsValidClient(int client)
{
    return (
client <= || client MAXPLAYERS+|| !IsClientInGame(client));

In theory this code should work but if anyone else wants to suggest otherwise by all means do so

If you have any questions then feel free to ask and I will explain what I have written to you from a PHP developers perspective
Thank you, but maybe my english is not that good, so you understand wrong. I want something, maybe with a "db" so i mannualy add some codes, imagine ( xkaoskd, qoekqwoek, lroqwlro ), 30 each code gives 30 days of VIP. To use the code you go inside the server and do "!vip xkaoskd", after that the code "xkaoskd" is not usable anymore.

Sorry for bad english :/
bbz is offline
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 09-21-2017 , 19:13   Re: Comand to give vip
Reply With Quote #14

Ahh, I see what you mean, my SQL skills with SP are very limited and certainly very insecure, I think that the code I wrote may infact need an alteration I can look into doing it tomorrow for you. It sounds like quite a fun little task!

I suggest you look up using and integrating a database with the code i.e. connecting / editing rows and I will write the code generation and the other parts
__________________
B3none is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 09-22-2017 , 02:16   Re: Comand to give vip
Reply With Quote #15

Btw there is my VIP plugin, you can take it and edit it to be as you want it.
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 09-22-2017 , 14:42   Re: Comand to give vip
Reply With Quote #16

I'm still writing this and it can be found on my Github,

Github Link

Current code:

PHP Code:
#include <sourcemod>
#include <sdktools>
 
#pragma newdecls required
#pragma semicolon 1

#define TAG_MESSAGE "[\x02VIP\x01]"
#define TOKEN_LIMIT 6

static const char vipCodes[][] =
{
    
"adszxc",
    
"moomoo",
};

static const 
char developerArgs[][] =
{
    
"debug",
};

static const 
char tokenCharacters[][] =
{
    
"a""b""c""d""e""f",
    
"g""h""i""j""k""l",
    
"m""n""o""p""q""r",
    
"s""t""u""v""w""x",
    
"y""z""A""B""C""D",
    
"E""F""G""H""I""J",
    
"K""L""M""N""O""P",
    
"Q""R""S""T""U""V",
    
"W""X""Y""Z""0""1",
    
"2""3""4""5""6""7",
    
"8""9"
};

public 
Plugin myinfo =
{
    
name "Give VIP",
    
author "B3none",
    
description "Temporarily give players VIP in the server.",
    
version "0.1.2",
    
url "https://forums.alliedmods.net/showthread.php?t=301305"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_vip"checkCode);
    
RegAdminCmd("sm_addstatus"addStatusADMFLAG_ROOT);
    
RegAdminCmd("sm_generate"generateNewCodeADMFLAG_ROOT);
}

public 
Action generateNewCode(int clientint args)
{
    
char newToken[TOKEN_LIMIT];
    
    
char argString[64];
    
GetCmdArgString(argStringsizeof(argString));
    
    
bool debugState false;
    
    if (
strlen(argString) > 0) {
        if (
StrEqual(argStringdeveloperArgs[0])) {
            
PrintToChat(client"%s Debug mode initiated."TAG_MESSAGE);
            
debugState true;
        }
    }
    
    for (
int i 1<= TOKEN_LIMIT && strlen(newToken) < TOKEN_LIMITi++) {
        
Format(newTokensizeof(newToken), "%s%s"newTokentokenCharacters[GetRandomInt(1sizeof(tokenCharacters))]);
        if (
debugState) {
            
PrintToChat(client"%s Current token: %s (increment %i / %i)"TAG_MESSAGEnewTokeniTOKEN_LIMIT);
        }
    }
    
    
char clientName[64];
    
GetClientName(clientclientNamesizeof(clientName));
    
    if (
debugState) {
        
PrintToChat(client"%s Token to be added: %s"TAG_MESSAGEnewToken);
    }
    
    
// Add code to database
    
    
PrintToChat(client"%s The generated code is %s"TAG_MESSAGEnewToken);
    
LogMessage("%s %s generated code \"%s\""TAG_MESSAGEclientNamenewToken);
}

public 
Action checkCode(int clientint args)
{
    
char code[64];
    
GetCmdArgString(codesizeof(code));
    
    if (
strlen(code) > TOKEN_LIMIT) {
        
PrintToChat(client"%s Invalid token."TAG_MESSAGE);
        return;
    }
    
    for (
int i 0<= sizeof(vipCodes); i++) {
        if (
StrEqual(codevipCodes[i])) {
            
addStatus(0client);
            
            
// Remove used code from the database
            
            
break;
        }
    }
    
    
PrintToChat(client"%s Invalid token."TAG_MESSAGE);
}

public 
Action addStatus(int clientint target)
{
    if ((!
IsValidClient(client) && client != 0) || !IsValidClient(target)) {
        return;
    }
    
    
char clientName[64];
    
char targetName[64];
    
    
GetClientName(clientclientNamesizeof(clientName));
    
GetClientName(targettargetNamesizeof(targetName));
    
    if (
CheckCommandAccess(target"sm_admin_check"ADMFLAG_RESERVATION)) {
        
AddUserFlags(targetAdmin_Reservation);
    }
    
    if (
client == 0) {
        
PrintToChatAll("%s %s was granted VIP access via a secret token"TAG_MESSAGEtargetName);
    } else {
        
PrintToChatAll("%s %s granted VIP access to %s"TAG_MESSAGEclientNametargetName);
    }
}

stock bool IsValidClient(int client)
{
    return (
client <= || client MaxClients || !IsClientInGame(client));

__________________
B3none is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-23-2017 , 15:16   Re: Comand to give vip
Reply With Quote #17

If I have tomorrow some energy and inspiration after nightshift, I could post first version... let see.
I have just check how SourceBans work for now.
__________________
Do not Private Message @me
Bacardi is offline
bbz
Junior Member
Join Date: Jan 2016
Old 09-23-2017 , 16:36   Re: Comand to give vip
Reply With Quote #18

Thanks you guys! i'll be waiting
bbz is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-24-2017 , 13:13   Re: Comand to give vip
Reply With Quote #19

youtube video





Ok. I'm not sure how much you know MySQL+phpMyAdmin

But in your SourceBans:
Group Management
» Home » Admin Panel » Group management

- Create Server Admin Group, name it example "vip"
- Give flag(s) or you can also override commands (allow|deny).


Then you need get to SourceBans database (phpMyAdmin ?)
- Select same database where are SourceBans tables.
- Below is SQL command, you maybe not need that red part
MySQL database table

Once you have this extra table in SourceBans database (sb_vip_random_codes)
- Insert row, fill only code and admin_group part.
In code set only letters and numbers, in admin_group set your admin group name "vip"






Here plugin, first release. Maybe not perfect.
https://www.sourcemod.net/compiler.php

command is
sm_vip_code C0d3

- In those servers where you install this plugin, it creates admins from sb_vip_random_codes table (steamid and expire date)
You can't see them in SourceBans, its into SM local admin system. (See server admin dumb file)
- When player activate code, it will be working 1 month.
- You can also create "codes" for different admin groups, not need to be specific "vip" named.
- You can also let one player activate multiple codes and join multiple admin groups.
But this plugin not set admin groups in right order like it should.

PHP Code:

#include <regex>


public void OnRebuildAdminCache(AdminCachePart part)
{
    switch(
part)
    {
        case 
AdminCache_Admins:
        {
            if(
SQL_CheckConfig("sourcebans"))
            {
                
SQL_TConnect(Connect_callback"sourcebans");
            }
        }
    }
}

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_vip_code"vip_code);
}

public 
Action vip_code(int clientint arg)
{

    
// no console, connecting players, bots, not authorized
    
if(client == || !IsClientInGame(client) || IsFakeClient(client) || !IsClientAuthorized(client)) return Plugin_Handled;

    if(
arg 1)
    {
        
ReplyToCommand(client"[SM] Usage:sm_vip_code R4nd0mC0d3");
        return 
Plugin_Handled;
    }


    static 
spamblock[MAXPLAYERS+1];

    
int time GetTime();

    if(
time spamblock[client])
    {
        
ReplyToCommand(client"[SM] Do not spam command!");
        return 
Plugin_Handled;
    }

    
spamblock[client] = time 3;



    
char args[20];
    
GetCmdArgString(argssizeof(args));


    if(
SimpleRegexMatch(args"[^a-zA-Z0-9]") > 0)
    {
        
ReplyToCommand(client"[SM] Random code only numbers and letters, a-z, A-Z, 0-9");
        return 
Plugin_Handled;
    }

    
    if(
SQL_CheckConfig("sourcebans"))
    {
        
Database DB SQL_Connect("sourcebans"false""0);

        if(
DB == null) return Plugin_Handled;


        
char buffer[300];

        
Format(buffersizeof(buffer), "SELECT admin_group FROM sb_vip_random_codes WHERE code = '%s';"args);
        
//PrintToServer("%s", buffer);
        
DBResultSet result SQL_Query(DBbuffersizeof(buffer));

        if(
result == null)
        {
            
SQL_GetError(DBbuffersizeof(buffer));
            
LogError("%s"buffer);
            
delete DB;
            return 
Plugin_Handled;
        }

        if(
SQL_FetchRow(result))
        {
            
SQL_FetchString(result0buffersizeof(buffer));

            
GroupId group FindAdmGroup(buffer);
            if(
group != INVALID_GROUP_ID)
            {
                
GetClientAuthId(clientAuthId_Steam2buffersizeof(buffer));

                
Format(buffersizeof(buffer), "UPDATE sb_vip_random_codes SET steamid = '%s', expire = DATE_ADD(CURRENT_DATE, INTERVAL 1 MONTH) WHERE code = '%s'"bufferargs);
                
//PrintToServer(buffer);

                
if(!SQL_FastQuery(DBbuffer))
                {
                    
SQL_GetError(DBbuffersizeof(buffer));
                    
LogError("%s"buffer);                    
                }
                else
                {
                    
SQL_TConnect(Connect_callback"sourcebans");
                }
            }
        }

        
delete result;
        
delete DB;
    }

    return 
Plugin_Handled;
}


public 
void Connect_callback(Handle ownerHandle hndl, const char[] errorany data)
{
    if(
hndl == null) return;

    
char buffer[300];

    
    
Format(buffersizeof(buffer), "SELECT steamid, admin_group FROM sb_vip_random_codes WHERE expire >= CURDATE() AND steamid REGEXP '^STEAM_[[:digit:]]\\:[[:digit:]]\\:[[:digit:]]+$'"); //"STEAM_1:1:111111"
    
SQL_TQuery(hndlQuery_callbackbufferdataDBPrio_Low);

    
delete hndl;
}

public 
void Query_callback(Handle ownerHandle hndl, const char[] errorany data)
{

    if(
hndl == null)
    {
        
SetFailState("ERROR - %s"error);
    }


    
GroupId group;
    
AdminId admin;

    
char buffer[300];

    while (
SQL_FetchRow(hndl))
    {
        
SQL_FetchString(hndl1buffersizeof(buffer));

        
group FindAdmGroup(buffer);
        if(
group == INVALID_GROUP_ID) continue; // No such admin group on server

        
SQL_FetchString(hndl0buffersizeof(buffer));

        
admin FindAdminByIdentity("steam"buffer);

        if(
admin == INVALID_ADMIN_ID)
        {
            
admin CreateAdmin("vip");
            if(!
BindAdminIdentity(admin"steam"buffer))
            {
                
RemoveAdmin(admin);
                continue;
            }
        }

        
bool IsInGroup;

        for(
int x 0GetAdminGroupCount(admin); x++)
        {
            if(
GetAdminGroup(adminx""0) == group)
            {
                
IsInGroup true;
                break;
            }
        }

        if(
IsInGroup) continue;

        
AdminInheritGroup(admingroup);
    }

Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	265
Size:	24.6 KB
ID:	165685  
__________________
Do not Private Message @me

Last edited by Bacardi; 09-25-2017 at 12:06.
Bacardi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode