I had Xinthis make this plugin for me, but apparently its not working right, so I was wondering if someone else could modify/fix it for me please.
Currently this creates a CFG on load in cfg/sourcemod.
The way this plugin works is you type !premium and then it gives you the custom flag O temporarily by adding the given player to your sourcebans database.
I haven't tested if it actually gave me the o flag, but by looking at my sourcebans admin list while typing !premium, I noticed that it's not adding me to the "All Servers Group" group that I made, which contains all the servers, I mean it adds me as an admin with the custom flag O, that job it does, but it doesn't add me to the group which contains all the servers.
I am also not sure if the time interval between the previous and next trial that I can use is working properly.
Here is how it is ACTUALLY SUPPOSED TO WORK...
User types !premium, user is added as to sourcebans database under the
Server Admin Group called
Premium Gamers. Then sourcebans would reload all admins on all servers. The user would then get the O flag instantly after they typed it. After X minutes the user's trial would expire. They cannot use the trial again until X hours have passed.
Here are the different messages that are supposed to appear:
User types !premium first time:
"Your Premium Gamer Trial has been activated for X Minutes!"
User types !premium while they are already using the trial:
"You have X minutes left in your trial."
When user's trial ends:
"Your Premium Gamer trial has expired. You can signup at www.brotherhoodofgamers.com/premium"
User types !premium after the trial is over:
"Sorry, only 1 trial per day! Sign up at www.brotherhoodofgamers.com/premium"
Extra Features:
1. When user first time types !premium, a menu would also pop up simply listing features that the user gets.
2. User can also type !features to see full list of Premium Gamer features.
3. When user types !premium after his trial has expired and the next trial isn't allowed yet, it would bring up a menu with the features list in addition to also writing the message:
"Sorry, only 1 trial per day! Sign up at www.brotherhoodofgamers.com/premium"
4. Same as #3, when trial has expired, the features menu would pop up in addition to showing the expiration message in chat:
"Your Premium Gamer trial has expired. You can signup at www.brotherhoodofgamers.com/premium"
I hope someone can fix this, everything is pretty much done already. Just need someone to tweak some things and make it work properly
Code:
/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
#include <clientprefs>
#define VERSION "1.1.0"
new Handle:db;
new Handle:cookie_trialVIP;
new Handle:sm_trialVIP_timelimit;
new Handle:sm_trialVIP_timeframe;
new Handle:sm_trialVIP_flags;
new String:serverGroup[512];
public Plugin:myinfo =
{
name = "Trial VIP",
author = "Xsinthis`",
description = "Allows 15 minutes of O flag",
version = VERSION,
url = "http://skulshockcommunity.com"
}
public OnPluginStart()
{
sm_trialVIP_timelimit = CreateConVar("sm_trialVIP_timelimit", "900", "Timelimit for trial period in seconds", 0, true, 0.0);
sm_trialVIP_timeframe = CreateConVar("sm_trialVIP_timeframe", "24", "How long (in hours) until a player can use their trial again", 0, true, 0.0);
sm_trialVIP_flags = CreateConVar("sm_trialVIP_flags", "o", "Flags to give trial players");
new Handle:sm_trialVIP_servergroup = CreateConVar("sm_trialVIP_servergroup", "All Servers", "Group of servers to allow trial on");
CreateConVar("trialVIP_version", VERSION, "Version of trialVIP", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
SQL_TConnect(GotDatabase, "sourcebans"); //Threaded database connection
RegConsoleCmd("sm_premium", StartTrial, "Starts your daily trial"); //regs console command
cookie_trialVIP = RegClientCookie("trialVIP", "Tracking recent Trail VIP usage", CookieAccess_Protected); //client cookie for tracking time
AutoExecConfig(true, "trialVIP", "sourcemod");
GetConVarString(sm_trialVIP_servergroup, serverGroup, sizeof(serverGroup));
}
public GotDatabase(Handle:owner, Handle:hndl, const String:error[], any:data)
{
db = hndl;
if (db == INVALID_HANDLE){
LogError("Database failure: %s", error);
return;
}
}
public Action:StartTrial(client, args)
{
decl String:trialVIP[512], timeframe, Float:timelimit;
timeframe = (GetConVarInt(sm_trialVIP_timeframe) * 60 *60);
timelimit = GetConVarFloat(sm_trialVIP_timelimit);
GetClientCookie(client, cookie_trialVIP, trialVIP, sizeof(trialVIP));
if((StringToInt(trialVIP) + timeframe) < GetTime()){
decl String:steamid[32], String:query[512], String:name[MAX_NAME_LENGTH], String:timeJoined[512], String:flags[26];
GetClientAuthString(client, steamid, sizeof(steamid));
GetClientName(client, name, sizeof(name));
GetConVarString(sm_trialVIP_flags, flags, sizeof(flags));
Format(query, sizeof(query), "INSERT INTO sb_admins (authid, user, immunity, srv_flags) VALUES ('%s', '%s', 0, '%s')", steamid, name, flags);
SQL_TQuery(db, SQLErrorCheckCallback, query);
Format(query, sizeof(query), "SELECT aid FROM sb_admins WHERE authid = '%s'", steamid);
SQL_TQuery(db, SQL_GetAID, query, client);
IntToString(GetTime(), timeJoined, sizeof(timeJoined));
SetClientCookie(client, cookie_trialVIP, timeJoined);
CreateTimer(timelimit, StopTrial, client);
ServerCommand("sb_rehash");
PrintToChat(client, "Your 15 minutes of trial time has been activated. You will recieve another message when it expires");
}else if((StringToInt(trialVIP) + timelimit) < GetTime()){
PrintToChat(client, "You are already using your trial time");
}else{
PrintToChat(client, "Error, you may not use this more than once every 24 hours");
}
return Plugin_Handled;
}
public Action:StopTrial(Handle:timer, any:client)
{
decl String:steamid[32], String:query[512];
GetClientAuthString(client, steamid, sizeof(steamid));
Format(query, sizeof(query), "DELETE FROM sb_admins WHERE authid = '%s' AND immunity = 0", steamid);
SQL_TQuery(db, SQLErrorCheckCallback, query);
PrintToChat(client, "Your trial time is up");
}
public SQL_GetAID(Handle:owner, Handle:hndl, const String:error[], any:client)
{
decl String:query[512];
new aid;
if(SQL_FetchRow(hndl)){
aid = SQL_FetchInt(hndl, 0);
}else{
LogError("Error, cannot find Server Group");
}
Format(query, sizeof(query), "SELECT gid FROM sb_groups WHERE name = '%s'", serverGroup);
SQL_TQuery(db, SQL_AddToServer, query, aid);
}
public SQL_AddToServer(Handle:owner, Handle:hndl, const String:error[], any:aid)
{
new gid;
decl String:query[512];
if(SQL_FetchRow(hndl)){
gid = SQL_FetchInt(hndl, 0);
}else{
LogError("Error, cannot find Server Group");
}
Format(query, sizeof(query), "INSERT INTO sb_admins_servers_groups (admin_id, group_id, srv_group_id, server_id) VALUES (%i, -1, %i, -1)", aid, gid);
SQL_TQuery(db, SQLErrorCheckCallback, query);
ServerCommand("sb_rehash");
}
public SQLErrorCheckCallback(Handle:owner, Handle:hndl, const String:error[], any:data)
{
if(!StrEqual("", error))
LogError("Query failed(SQLErrorCheckCallback): %s", error);
}
__________________