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

[REQ] Modify/fix Premium Gamer Trial Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bouncer
Veteran Member
Join Date: Apr 2009
Old 10-16-2010 , 14:53   [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #1

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);
}
__________________



Last edited by bouncer; 10-16-2010 at 14:57.
bouncer is offline
bouncer
Veteran Member
Join Date: Apr 2009
Old 10-16-2010 , 15:00   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #2

I'd like to add that I also rather have this plugin use it's own MYSQL database, NOT sourcebans.
__________________


bouncer is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-17-2010 , 20:22   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #3

you would need approval from the writer to make any public adjustments.
Mitchell is offline
bouncer
Veteran Member
Join Date: Apr 2009
Old 10-17-2010 , 21:13   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #4

not really since this is a private plugin.
__________________


bouncer is offline
bouncer
Veteran Member
Join Date: Apr 2009
Old 10-18-2010 , 20:10   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #5

anyone please?
__________________


bouncer is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-18-2010 , 20:11   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #6

Quote:
Originally Posted by bouncer View Post
anyone please?
Don't bump.
psychonic is offline
Rizla
SourceMod Donor
Join Date: Jun 2010
Old 10-19-2010 , 21:53   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #7

you do realise that it probably wont add you into a sb group if your steam id is already in the db?
Rizla is offline
bouncer
Veteran Member
Join Date: Apr 2009
Old 10-19-2010 , 22:37   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #8

it doesnt have to add me to an admin group if i already have the custom flag checked off....

and the current plugin already adds me...
Read the first post >.>
__________________


bouncer is offline
Rizla
SourceMod Donor
Join Date: Jun 2010
Old 10-20-2010 , 13:07   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #9

if its trying to create a new admin though (which it should be) and your steam id is already in the db, it wont add you and if it does you will have other problems like not being able to ban
Rizla is offline
bouncer
Veteran Member
Join Date: Apr 2009
Old 10-20-2010 , 16:34   Re: [REQ] Modify/fix Premium Gamer Trial Plugin
Reply With Quote #10

Well I would actually rather use a new mysql database just for this...
Can anyone make this please?
__________________


bouncer 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 10:58.


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