This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[TF2] Shop Credit Mod + Tweaks


Post New Thread Reply   
 
Thread Tools Display Modes
TheSpyHunter
Senior Member
Join Date: Jul 2009
Old 01-08-2010 , 13:45   Re: Credit/ Candy Mod: Tweaks
Reply With Quote #41

Hmmm, ive already added the ability to give credits as an item on the shop.

So players can goto the menu with "Give Credits" it then shows a menu of players, they user can then give 250 creds at a time, costing of course 250 of there own.

Gambling on the server would be fun...thinks
__________________
TheSpyHunter is offline
DeathMaster
AlliedModders Donor
Join Date: Mar 2009
Old 01-22-2010 , 07:35   Re: Credit/ Candy Mod: Tweaks
Reply With Quote #42

Quote:
Originally Posted by TheSpyHunter View Post
Hi DeathMaster,

Edited Pumpkin Code ->

The Evil Pumpkin Hat!

In the buymenu.txt

sm_pumpkin @me
Spawns a pumpkin at your aim.

sm_buypumpkin $
Displays a menu to buyer of who to give the evil pumpkin hat.

Attached code, tested and works! Yay!
Some players on my server have found an exploit to the pumpkin in the buy menu. If you go in spectate and buy a pumpkin, whoever your spectating through will get the pumpkin spawned at his feet and will result in being stuck. Is there any way to prevent the usage from spectators?
DeathMaster is offline
DeathMaster
AlliedModders Donor
Join Date: Mar 2009
Old 02-22-2010 , 23:18   Re: Credit/ Candy Mod: Tweaks
Reply With Quote #43

Is there a way to prevent spectators from using the pumpkin in the buy menu?
DeathMaster is offline
cybersquare420
Veteran Member
Join Date: Nov 2008
Old 03-12-2010 , 12:52   Re: Credit/ Candy Mod: Tweaks
Reply With Quote #44

alright... i been messing about with something for a while and i cant figure it out so i decided to ask you guys... Can any of you think of a way to make a different buy menu for admins / donators? i want every one to have access to some things, but i would like to researve a few of the cooler things for VIP access... just a thought...
__________________
cybersquare420 is offline
TheSpyHunter
Senior Member
Join Date: Jul 2009
Old 03-27-2010 , 15:09   Re: Credit/ Candy Mod: Tweaks
Reply With Quote #45

Ok, I've been offered money for other versions in the past but I thought it was about time to make this public.

Ladies and gents please see my heavily edited version of Gachls Candy Credit Mod.

It's stable and works fine with a bunch of other plugins such as equiment editor, give guns etc etc.

Buy menus can be set (in the .sp)

and each item can be assigned to that sub menu example

1. Guns
-1. Flamethrower
-2. Sniper Rifle
2. Buffs
-1. Health +25
-2. Crtits 10 Secs
3. Evil
-1. Kill a player
-2. Blind a player

etc etc etc

You can set to give admins/donators with a specific flag win points at the end of winning round. (Default 1000 pints set to ADMFLAG_GENERIC)

Installation:

  • candyscript.sp in the scripting folder
  • candyscript.smx in the sourcemod/plugins folder
  • candy_funpack.sp in scripting
  • candy_funpack.smx in sourcemod/plugins folder
  • Create an sql database and make sure you have given all rights to db user.
  • Add database info to databases.cfg (see example at bottom of post)
  • Buymenu.txt needs to go into "addons/sourcemod/config/buymenu.txt"
  • The plugin auto creates a config in "cfg/sourcemod/plugin.candyscript"
  • Groups can be changed in the script (.sp) the plugin currently has 6 groups. 0 = Player Buffs, 1 = Team Buffs, 2 = Hats etc etc. These can be edited in the following lines.
PHP Code:
// SUB MENU
#define SHOP_MENU_MAX                6
#define SHOPMENU_OTHER_INDEX        5 // where is the "Others" index
new String:ShopMenuName[SHOP_MENU_MAX][] = {"Player Buffs","Team Buffs","Hats","Weapons","Evil","Others"};
new 
Client_iCurrentMoney[MAXPLAYERS+1] = 0
CVARS
PHP Code:
// This file was auto-generated by SourceMod (v1.3)
// ConVars for plugin "candyscript.smx"


// Custom chat trigger for the buy menu
// -
// Default: ""
sm_candy_chat_buy1 "shop"

// Custom chat trigger for the buy menu
// -
// Default: ""
sm_candy_chat_buy2 "buy"

// Custom chat trigger for the player stats
// -
// Default: ""
sm_candy_chat_stats1 "credits"

// Custom chat trigger for the player stats
// -
// Default: ""
sm_candy_chat_stats2 "bank"

// Tag for messages printed to the chat ([value] text)
// -
// Default: "candy"
sm_candy_chat_tag "UFF Credits"


// Starting credits for new steamids
// -
// Default: "0"
sm_candy_start_credits "120"

// Credits a user gets for killing someone
// -
// Default: "1"
sm_candy_credit_per_kill "2"

// Kills required to receive sm_candy_credits_per_kill/assist
// -
// Default: "1"
sm_candy_kills_for_credit "1"

// Credit gain for assists (counting on sm_candy_kills_for_credit)
// -
// Default: "1"
sm_candy_credits_per_assist "2"

// Credits a user gets each tick
// -
// Default: "1"
sm_candy_credit_per_tick "200"

// Database to use (from databases.cfg)
// -
// Default: "default"
sm_candy_database "candyscript"

// Credits a user loses if he gets killed
// -
// Default: "1"
sm_candy_loss_per_death "0"

// Credits a user loses if he kills himself
// -
// Default: "0"
sm_candy_loss_per_suicide "0"

// Set the noise level 1-3
// -
// Default: "2"
// Minimum: "1.000000"
// Maximum: "3.000000"
sm_candy_noise_level "3"

// Prefix for the table to store data in
// -
// Default: "cndy_"
sm_candy_table_prefix "cndy_"

// Give only alive players credit on tick
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sm_candy_tick_only_alive "0"

// Time between two ticks in seconds
// -
// Default: "60"
sm_candy_tick_speed "900"
//
sm_candy_start_credits "120"
//
sm_candy_admin "1000"
// Candy plugin version
// -
// Default: "0.6.0"
sm_candy_version "4.0" 
Candyscript.sp

PHP Code:
#include <sourcemod>
    
/* defines */
#define PLUGIN_VERSION "4.0"
//#define DEBUG "1"
#define NULLNAME "$$NULL##"

public Plugin:myinfo 
{
    
name "TF2 Shop Mod",
    
author "GachL & TheSpyHunter",
    
description "Credit Shop Mod",
    
version PLUGIN_VERSION,
    
url "UltimateFragForce.Co.uk",
}

/* Global variables */
new Handle:cvCreditPerTick;
new 
Handle:cvCreditPerKill;
new 
Handle:cvCreditLossPerSuicide;
new 
Handle:cvCfgTickSpeed;
new 
Handle:cvCfgDatabaseToUse;
new 
Handle:cvCfgTablePrefix;
new 
Handle:cvCfgChatTag;
new 
Handle:cvCfgTickOnlyAlive;
new 
Handle:cvCfgNoiseLevel;
new 
Handle:cvCreditLossPerDeath;
new 
Handle:cvKillsForCredit;
new 
Handle:cvCreditForAssist;
new 
Handle:cvCustomChatTriggerBuyMenu1;
new 
Handle:cvCustomChatTriggerBuyMenu2;
new 
Handle:cvCustomChatTriggerPlayerStats1;
new 
Handle:cvCustomChatTriggerPlayerStats2;
new 
Handle:cvCandlyAdmin;

new 
Handle:dbConnection INVALID_HANDLE;

new 
String:sChatTag[32];
new 
String:sTablePrefix[32];
new 
String:sCurrentDB[64];

new 
bool:bRunning false;

new 
iKills[MAXPLAYERS];

new 
String:sConnectingClients[34][128]; // Store SteamId for sql callbacks
new iPushArray[34];

new 
iBuyCount 0;
new Function:
fCallbacks[512][2];
new 
String:sNames[512][128];
new 
iCosts[512];
new 
Float:iStopTimes[512];
new 
iGroups[512];


// SUB MENU
#define SHOP_MENU_MAX                6
#define SHOPMENU_OTHER_INDEX        5 // where is the "Others" index
new String:ShopMenuName[SHOP_MENU_MAX][] = {"Player Buffs","Team Buffs","Hats","Weapons","Evil","Others"};
new 
Client_iCurrentMoney[MAXPLAYERS+1] = 0;

public 
OnPluginStart()
{
    
PrintDebug("Creating convars");
    
/* Create convars */
    
InitializeConvars();
    
    
HookEvent("player_connect"ePlayerConnect);
    
HookEvent("player_death"ePlayerDeath);
    
HookEvent("teamplay_round_win"eRoundWin);


    for (new 
0sizeof(sNames); i++)
        
sNames[i] = NULLNAME;
    
    
LoadTranslations("common.phrases")
    
//LoadTranslations("candy.phrases")
}

public 
OnConfigsExecuted()
{
    
InitializeTimersAndCValues();
    
InitializeDatabase();
}

public 
bool:AskPluginLoad(Handle:myselfbool:lateString:error[], err_max)
{
    
CreateNative("RegisterCandy"RegisterCandy);
    
CreateNative("DeregisterCandy"DeregisterCandy);
    return 
true;
}

/**
 * If debug is enabled print a debug message
 */
public PrintDebug(String:sMessage[])
{
#if defined DEBUG
    
PrintToServer("[CDBG] %s"sMessage);
#endif
}

public 
PrintNoise(String:sMessage[], leveltarget)
{
    
PrintDebug("Printing noise");
    new 
iNoiseLevel GetConVarInt(cvCfgNoiseLevel);
    if (
level <= iNoiseLevel)
    {
        if (
target == 0)
        {
            
PrintDebug("Print noise to all");
            
PrintToChatAll(sMessage);
        }
        else
        {
            
PrintDebug("Print noise to [target]");
            if (!
FullCheckClient(target))
            {
                
PrintDebug("Invalid target!");
                return;
            }
            
PrintToChat(targetsMessage);
        }
    }
}

/**
 * Create all convars
 */
public InitializeConvars()
{
    
cvCreditPerKill CreateConVar("sm_candy_credit_per_kill""1""Credits a user gets for killing someone"FCVAR_PLUGIN);
    
cvCreditPerTick CreateConVar("sm_candy_credit_per_tick""1""Credits a user gets each tick"FCVAR_PLUGIN);
    
cvCreditLossPerSuicide CreateConVar("sm_candy_loss_per_suicide""0""Credits a user loses if he kills himself"FCVAR_PLUGIN);
    
cvCfgTickSpeed CreateConVar("sm_candy_tick_speed""60""Time between two ticks in seconds"FCVAR_PLUGIN);
    
cvCfgDatabaseToUse CreateConVar("sm_candy_database""default""Database to use (from databases.cfg)"FCVAR_PLUGIN);
    
cvCfgTablePrefix CreateConVar("sm_candy_table_prefix""cndy_""Prefix for the table to store data in"FCVAR_PLUGIN);
    
cvCfgChatTag CreateConVar("sm_candy_chat_tag""candy""Tag for messages printed to the chat ([value] text)"FCVAR_PLUGIN);
    
cvCfgTickOnlyAlive CreateConVar("sm_candy_tick_only_alive""0""Give only alive players credit on tick"FCVAR_PLUGINtrue0.0true1.0);
    
cvCfgNoiseLevel CreateConVar("sm_candy_noise_level""2""Set the noise level 1-3"FCVAR_PLUGINtrue1.0true3.0);
    
cvCreditLossPerDeath CreateConVar("sm_candy_loss_per_death""1""Credits a user loses if he gets killed"FCVAR_PLUGIN);
    
cvKillsForCredit CreateConVar("sm_candy_kills_for_credit""1""Kills required to receive sm_candy_credit_per_kill"FCVAR_PLUGIN);
    
cvCustomChatTriggerBuyMenu1 CreateConVar("sm_candy_chat_buy1""""Custom chat trigger for the buy menu"FCVAR_PLUGIN);
    
cvCustomChatTriggerBuyMenu2 CreateConVar("sm_candy_chat_buy2""""Custom chat trigger for the buy menu"FCVAR_PLUGIN);
    
cvCustomChatTriggerPlayerStats1 CreateConVar("sm_candy_chat_stats1""""Custom chat trigger for the player stats"FCVAR_PLUGIN);
    
cvCustomChatTriggerPlayerStats2 CreateConVar("sm_candy_chat_stats2""""Custom chat trigger for the player stats"FCVAR_PLUGIN);
    
cvCreditForAssist CreateConVar("sm_candy_credits_per_assist""1""Receive credits for an assist"FCVAR_PLUGIN);
    
cvCandlyAdmin CreateConVar("sm_candy_admin","1000","How many credits give to admin"FCVAR_PLUGIN);
    
    
PrintDebug("AutoExecConfig");
    
AutoExecConfig();
    
    
CreateConVar("sm_candy_version"PLUGIN_VERSION"Candy plugin version"FCVAR_PLUGIN FCVAR_PROTECTEDFCVAR_NOTIFY);
    
    
PrintDebug("Getting new chat tag");
    
GetConVarString(cvCfgChatTagsChatTagsizeof(sChatTag));
}

/**
 * Create all admin commands
 */
public InitializeAdminCommands()
{
    
RegAdminCmd("sm_candy_add"cAddCandyADMFLAG_CUSTOM5"Give an user some credits (sm_candy_add user amount)");
    
RegAdminCmd("sm_candy_remove"cRemoveCandyADMFLAG_RCON"Remove some credits (sm_candy_remove user amount)");
    
RegAdminCmd("sm_candy_get"cGetCandyADMFLAG_RCON"Get the amount of candy (sm_candy_get userid)");
    
RegAdminCmd("sm_candy_reset"cResetCandyADMFLAG_RCON"Reset the amount of candy of every player to a certain amount (sm_candy_reset amount)");
    
RegAdminCmd("sm_candy_resetdb"cResetDBADMFLAG_RCON"Reset the database (sm_candy_resetdb)");
    
RegAdminCmd("sm_candy_msg"cMsgADMFLAG_KICK"Prints a candy buy message (sm_candy_msg user item)");
}

/**
 * Initialize or renew database connection
 */
public InitializeDatabase()
{
    
// Check if db connection is the same
    
new String:sDBHndlName[128];
    
GetConVarString(cvCfgDatabaseToUsesDBHndlNamesizeof(sDBHndlName));
    if (
strcmp(sCurrentDBsDBHndlName) == 0)
    {
        
PrintDebug("No change in db connection detected.");
        return;
    }
    
    
// Check if db connection exist
    
if (dbConnection != INVALID_HANDLE)
    {
        
PrintDebug("Closing existing DB handle!");
        
CloseHandle(dbConnection);
    }
    
    if (!
SQL_CheckConfig(sDBHndlName))
    {
        
PrintToServer("[%s] I wasn't able to find your database configuration %s"sChatTagsDBHndlName);
        return;
    }
    
SQL_TConnect(cDatabaseEstablishedsDBHndlName);
}

/**
 * Callback for threaded database connection
 */
public cDatabaseEstablished(Handle:ownerHandle:dbString:error[], any:data)
{
    
PrintDebug("Database connection established");
    if (
db == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Failed to connect: %s"sChatTagerror);
        
dbConnection INVALID_HANDLE;
        return;
    }
    else
    {
        
PrintDebug("Success! Create tables if not exist!");
        new 
String:sDBHndlName[128];
        
GetConVarString(cvCfgDatabaseToUsesDBHndlNamesizeof(sDBHndlName));
        
strcopy(sCurrentDBsizeof(sCurrentDB), sDBHndlName);
        
dbConnection db;
        new 
String:qCreateTable[255];
        
Format(qCreateTablesizeof(qCreateTable), "DESCRIBE %scandydata;"sTablePrefix);
        new 
Handle:qCheckTableVersion SQL_Query(dbConnectionqCreateTable)
        if (
qCheckTableVersion != INVALID_HANDLE)
        {
            if (
SQL_GetRowCount(qCheckTableVersion) == 2)
            {
                
Format(qCreateTablesizeof(qCreateTable), "ALTER TABLE %scandydata ADD lifetimecandy INT UNSIGNED;"sTablePrefix);
                
SQL_FastQuery(dbConnectionqCreateTable);
                
PrintDebug("Update database!");
            }
            else if (
SQL_GetRowCount(qCheckTableVersion) == 3)
            {
                
SQL_FetchRow(qCheckTableVersion);
                
SQL_FetchRow(qCheckTableVersion);
                
SQL_FetchRow(qCheckTableVersion); // lifetime candy
                
new String:sLifeTimeCandy[255];
                
SQL_FetchString(qCheckTableVersion4sLifeTimeCandysizeof(sLifeTimeCandy));
                
Format(qCreateTablesizeof(qCreateTable), "ltc: '%s'"sLifeTimeCandy);
                
PrintDebug(qCreateTable);
                if (
strcmp(sLifeTimeCandy""false) == 0)
                {
                    
Format(qCreateTablesizeof(qCreateTable), "ALTER TABLE %scandydata CHANGE candy candy INT NOT NULL DEFAULT '0', CHANGE lifetimecandy lifetimecandy INT UNSIGNED NOT NULL DEFAULT '0';"sTablePrefix);
                    
SQL_FastQuery(dbConnectionqCreateTable);
                    
PrintDebug("Updating database!");
                }
                else
                {
                    
PrintDebug("Latest db version!");
                }
            }
            
CloseHandle(qCheckTableVersion)
        } else {
            
Format(qCreateTablesizeof(qCreateTable), "CREATE TABLE IF NOT EXISTS %scandydata (steamid VARCHAR(32) NOT NULL PRIMARY KEY, candy INT, lifetimecandy INT UNSIGNED);"sTablePrefix);
            
SQL_FastQuery(dbConnectionqCreateTable);
        }
        
PrintDebug("Prechecking all users");
        
PrecheckAllUsers();
    }
}

/**
 * Initialize timers and cvar values
 */
public InitializeTimersAndCValues()
{
    if (
bRunning)
        return;
    
PrintDebug("Creating admin commands");
    
/* Create admin commands */
    
InitializeAdminCommands();
    
PrintToServer("Candy plugin is now loaded and running!");
    
RegConsoleCmd("say"cSay);
    
RegConsoleCmd("sm_buy"cBuy"Open Buymenu");
    
RegConsoleCmd("sm_buymenu"cBuy"Open Buymenu");
    
RegConsoleCmd("sm_cstats"cStats"Show candy stats");
    
RegConsoleCmd("sm_candy"cStats"Show candy stats");
    
    
GetConVarString(cvCfgChatTagsChatTagsizeof(sChatTag));
    
GetConVarString(cvCfgTablePrefixsTablePrefixsizeof(sTablePrefix));
    
    
PrintDebug("Updating tick speed");
    new 
iTickSpeed GetConVarInt(cvCfgTickSpeed);
    new 
iCreditEarn GetConVarInt(cvCreditPerTick);
    if ((
iTickSpeed 0) && (iCreditEarn 0))
    {
        
CreateTimer(float(iTickSpeed), tTick_TIMER_REPEAT);
    }
    
    for (new 
0sizeof(sConnectingClients); i++)
    {
        
sConnectingClients[i] = "";
    }
    
bRunning true;
}

/**
 * A new player connected!
 */
public ePlayerConnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return;
    new 
String:sSteamId[128], iUserIdhUserHimself;
    
GetEventString(event"networkid"sSteamIdsizeof(sSteamId));
    
iUserId GetEventInt(event"userid");
    
hUserHimself GetClientOfUserId(iUserId);
    
iKills[hUserHimself] = 0;
    
Client_iCurrentMoney[hUserHimself] = 0;
    
    
PrintDebug("Prechecking connecting user");
    
PrecheckUser(AddToConnecters(sSteamId));
}

/**
 * Someone got killed! Call 911!
 */
public ePlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
PrintDebug("Eew, blood! player_death called!");
    
InitializeDatabase();
    new 
attackerId GetEventInt(event"attacker");
    new 
victimId GetEventInt(event"userid");
    new 
assisterId GetEventInt(event"assister");
    new 
attacker GetClientOfUserId(attackerId);
    new 
victim GetClientOfUserId(victimId);
    new 
assister GetClientOfUserId(assisterId);
    
    if (!
FullCheckClient(attacker) || !FullCheckClient(victim))
    {
        
PrintDebug("The target or the attacker are invalid clients!");
        return;
    }
    
    if (
attacker == victim)
    {
        
PrintDebug("Someone killed himself (suicide)");
        
// suicide :(
        
new iLosePoints GetConVarInt(cvCreditLossPerSuicide);
        if (
iLosePoints == 0)
            return;
        new 
String:sNoise[128];
        
Format(sNoisesizeof(sNoise), "[%s] You lost %i credits."sChatTagiLosePoints);
        
PrintNoise(sNoise3victim);
        
RemoveCandy(victimiLosePoints);
        return;
    }
    
    
// He killed someone!
    
PrintDebug("Someone got killed");
    new 
iCreditGain GetConVarInt(cvCreditPerKill);
    new 
iCreditLoss GetConVarInt(cvCreditLossPerDeath);
    new 
iKillsForCredit GetConVarInt(cvKillsForCredit);
    new 
iCreditForAssist GetConVarInt(cvCreditForAssist);
    
    new 
bool:bUserGetsCredits iKillsForCredit 2;
    
    if (!
bUserGetsCredits)
    {
        if (
iKills[attacker] >= iKillsForCredit)
        {
            
bUserGetsCredits true;
            
iKills[attacker] = 0;
        }
        else
        {
            
iKills[attacker]++;
        }
    }
    
    if (
bUserGetsCredits)
    {
        
PrintDebug("User gets credits!");
        if (
iCreditGain != 0)
            
AddCandy(attackeriCreditGain);
        
        new 
String:sNoiseAttacker[128];
        
Format(sNoiseAttackersizeof(sNoiseAttacker), "[%s] You got %i credits."sChatTagiCreditGain);
        if (
iCreditGain != 0)
            
PrintNoise(sNoiseAttacker2attacker);
    }
    
    if (
iCreditLoss != 0)
        
RemoveCandy(victimiCreditLoss);
    new 
String:sNoiseVictim[128];
    
Format(sNoiseVictimsizeof(sNoiseVictim), "[%s] You lost %i credits."sChatTagiCreditLoss);
    if (
iCreditLoss != 0)
        
RemoveCandy(victimiCreditLoss);
    
    
// Assist handling
    
if (!FullCheckClient(assister))
        return;
    
    
bUserGetsCredits iKillsForCredit 2;
    
    if (!
bUserGetsCredits)
    {
        if (
iKills[assister] >= iKillsForCredit)
        {
            
bUserGetsCredits true;
            
iKills[assister] = 0;
        }
        else
        {
            
iKills[assister]++;
        }
    }
    
    if (
bUserGetsCredits)
    {
        
PrintDebug("Assister gets credits!");
        if (
iCreditForAssist != 0)
            
AddCandy(assisteriCreditForAssist);
        
        new 
String:sNoiseAssister[128];
        
Format(sNoiseAssistersizeof(sNoiseAssister), "[%s] You got %i credits."sChatTagiCreditForAssist);
        if (
iCreditForAssist != 0)
            
PrintNoise(sNoiseAssister2assister);
    }
}

public 
Action:cBuy(clientargs)
{
    
PrintDebug("Buy event has been fired!");
    
PrintDebug("Reinitializing DB (if needed)");
    
InitializeDatabase();
    
PrintDebug("Checking DB connection");
    if (
dbConnection == INVALID_HANDLE)
    {
        
PrintDebug("Nope, no DB connection. Aborting say command");
        return 
Plugin_Continue;
    }
    
PrintDebug("Validating client");
    if (!
FullCheckClient(client))
    {
        
PrintDebug("Nope, client invalid. Aborting say command");
        return 
Plugin_Continue;
    }
    
PrintDebug("Seems to be a health client/db. Checking for commands");
    
PrintDebug("Someone wants to buy something");
    new 
String:qGetUsersCandy[255], String:sSteamId[32];
    
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
    
Format(qGetUsersCandysizeof(qGetUsersCandy), "SELECT candy FROM %scandydata WHERE steamid = '%s';"sTablePrefixsSteamId);
    
SQL_TQuery(dbConnectioncBuyMenuSQLCallbackqGetUsersCandyclient);
    
    return 
Plugin_Handled;
}

public 
Action:cStats(clientargs)
{
    
PrintDebug("Buy event has been fired!");
    
PrintDebug("Reinitializing DB (if needed)");
    
InitializeDatabase();
    
PrintDebug("Checking DB connection");
    if (
dbConnection == INVALID_HANDLE)
    {
        
PrintDebug("Nope, no DB connection. Aborting say command");
        return 
Plugin_Continue;
    }
    
PrintDebug("Validating client");
    if (!
FullCheckClient(client))
    {
        
PrintDebug("Nope, client invalid. Aborting say command");
        return 
Plugin_Continue;
    }
    
PrintDebug("Seems to be a health client/db. Checking for commands");
    
PrintDebug("Someone wants his stats");
    new 
String:qGetUsersCandy[255], String:sSteamId[32];
    
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
    
Format(qGetUsersCandysizeof(qGetUsersCandy), "SELECT candy, lifetimecandy FROM %scandydata WHERE steamid = '%s';"sTablePrefixsSteamId);
    
SQL_TQuery(dbConnectioncStatsSQLCallbackqGetUsersCandyclient);
    
    return 
Plugin_Handled;
}

public 
Action:cSay(clientargs)
{
    
PrintDebug("Say event has been fired!");
    
PrintDebug("Reinitializing DB (if needed)");
    
InitializeDatabase();
    
PrintDebug("Checking DB connection");
    if (
dbConnection == INVALID_HANDLE)
    {
        
PrintDebug("Nope, no DB connection. Aborting say command");
        return 
Plugin_Continue;
    }
    
PrintDebug("Validating client");
    if (!
FullCheckClient(client))
    {
        
PrintDebug("Nope, client invalid. Aborting say command");
        return 
Plugin_Continue;
    }
    
PrintDebug("Seems to be a health client/db. Checking for commands");
    new 
String:text[512], String:sCustChatTriggerBuy1[128], String:sCustChatTriggerBuy2[128], String:sCustChatTriggerStats1[128], String:sCustChatTriggerStats2[128];
    
GetConVarString(cvCustomChatTriggerBuyMenu1sCustChatTriggerBuy1sizeof(sCustChatTriggerBuy1));
    
GetConVarString(cvCustomChatTriggerBuyMenu2sCustChatTriggerBuy2sizeof(sCustChatTriggerBuy2));
    
GetConVarString(cvCustomChatTriggerPlayerStats1sCustChatTriggerStats1sizeof(sCustChatTriggerStats1));
    
GetConVarString(cvCustomChatTriggerPlayerStats2sCustChatTriggerStats2sizeof(sCustChatTriggerStats2));
    
GetCmdArg(1textsizeof(text));
    if (((
strcmp(sCustChatTriggerBuy1""false) != 0) && (strcmp(textsCustChatTriggerBuy1false) == 0))
        || ((
strcmp(sCustChatTriggerBuy2""false) != 0) && (strcmp(textsCustChatTriggerBuy2false) == 0)))
    {
        
PrintDebug("Someone wants to buy something");
        new 
String:qGetUsersCandy[255], String:sSteamId[32];
        
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
        
Format(qGetUsersCandysizeof(qGetUsersCandy), "SELECT candy FROM %scandydata WHERE steamid = '%s';"sTablePrefixsSteamId);
        
SQL_TQuery(dbConnectioncBuyMenuSQLCallbackqGetUsersCandyclient);
        
        return 
Plugin_Handled;
    }
    else if (((
strcmp(sCustChatTriggerStats1""false) == 0) && (strcmp(textsCustChatTriggerStats1false) == 0))
        || ((
strcmp(sCustChatTriggerStats2""false) == 0) && (strcmp(textsCustChatTriggerStats2false) == 0)))
    {
        
PrintDebug("Someone wants his stats");
        new 
String:qGetUsersCandy[255], String:sSteamId[32];
        
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
        
Format(qGetUsersCandysizeof(qGetUsersCandy), "SELECT candy, lifetimecandy FROM %scandydata WHERE steamid = '%s';"sTablePrefixsSteamId);
        
SQL_TQuery(dbConnectioncStatsSQLCallbackqGetUsersCandyclient);
        
        return 
Plugin_Handled;
    }
    
PrintDebug("Nope, no command found. Aborting say command");
    return 
Plugin_Continue;
}

/**
 * Precheck every user
 */
public PrecheckAllUsers()
{
    
InitializeDatabase();
    for (new 
1<= MaxClientsi++)
    {
        if (!
FullCheckClient(i))
            continue;
        new 
String:sSteamId[128];
        
GetClientAuthString(isSteamIdsizeof(sSteamId));
        
PrecheckUser(AddToConnecters(sSteamId));
    }
}

/**
 * Add SteamId to steamid list
 */
public AddToConnecters(String:sSteamId[128])
{
    
// Check if already in list
    
for (new 0sizeof(sConnectingClients); i++)
    {
        if (
strcmp(sConnectingClients[i], sSteamId) == 0)
            return 
i;
    }
    
    new 
iNext 0;
    for (new 
0sizeof(sConnectingClients); i++)
    {
        
iNext i;
        if (
strcmp(sConnectingClients[i], "") == 0)
            break;
    }
    
sConnectingClients[iNext] = sSteamId;
    
PrintDebug("Adding a value to the connectors");
    return 
iNext;
}

/**
 * Remove SteamId from steamid list
 */
public RemoveFromConnecters(position)
{
    
sConnectingClients[position] = "";
    
PrintDebug("Removing a value from the connectors");
}

/**
 * Tick!
 */
public Action:tTick(Handle:timer)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return;
    
    new 
String:err[255];
    
SQL_GetError(dbConnectionerrsizeof(err));
    
PrintDebug(err);
    
    
PrintDebug("Tick!");
    
    new 
iCreditEarn GetConVarInt(cvCreditPerTick);
    for (new 
1<= MaxClientsi++)
    {
        if (!
FullCheckClient(i))
            continue;
        
        
PrintDebug("Processing a client in tick!");
        
        new 
iOnlyAlive GetConVarInt(cvCfgTickOnlyAlive);
        if ((
iOnlyAlive == 1) && !IsPlayerAlive(i))
        {
            
PrintDebug("Client is dead and dead clients don't get points!");
            continue;
        }
        
        
/**
         * This client is now free to
         * get his candy
         */
        
PrintDebug("He's got candy!");
        
AddCandy(iiCreditEarn);
        new 
String:sTickNoise[128];
        if (
iCreditEarn == 1)
            
Format(sTickNoisesizeof(sTickNoise), "[%s] You received 1 credit!"sChatTag);
        else if (
iCreditEarn 1)
            
Format(sTickNoisesizeof(sTickNoise), "[%s] You received %i credits!"sChatTagiCreditEarn);
        
PrintNoise(sTickNoise3i);
    }
}

/**
 * Print a candy message to everyone
 */
public Action:cMsg(clientargs)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return 
Plugin_Handled;
    new 
String:sTarget[32], String:sItem[256];
    
    if (!
GetCmdArg(1sTargetsizeof(sTarget)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_msg user item"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_msg user item"sChatTag);
        return 
Plugin_Handled;
    }
    
    if (!
GetCmdArg(2sItemsizeof(sItem)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_msg user item"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_msg user item"sChatTag);
        return 
Plugin_Handled;
    }
    
    new 
String:sTargetName[MAX_TARGET_LENGTH];
    new 
iTargetList[MAXPLAYERS], iTargetCountbool:tn_is_ml;
    
    
iTargetCount ProcessTargetString(sTargetclientiTargetListMAXPLAYERSCOMMAND_FILTER_CONNECTEDsTargetNamesizeof(sTargetName), tn_is_ml);
    
    for (new 
0iTargetCounti++)
    {
        new 
iTarget iTargetList[i];
        
        if (!
FullCheckClient(iTarget))
        {
            if (
FullCheckClient(client))
                
PrintToChat(client"[%s] No such user (%s)"sChatTagsTarget);
            else
                
PrintToServer("[%s] No such user (%s)"sChatTagsTarget);
            return 
Plugin_Handled;
        }
        
        new 
String:sName[256];
        
GetClientName(iTargetsNamesizeof(sName));
        
        for (new 
1<= MaxClientsj++)
        {
            if (!
FullCheckClient(j))
                continue;
            
            
PrintToChat(j"\x01\x03%s \x01has bought: \x04%s"sNamesItem);
        }
    }
    
    return 
Plugin_Handled;
}

/**
 * Admin command to add candy
 * to an user
 */
public Action:cAddCandy(clientargs)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return 
Plugin_Handled;
    new 
String:sTarget[32], String:sAmount[32];
    new 
iAmount;
    
    if (!
GetCmdArg(1sTargetsizeof(sTarget)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_add userid amount"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_add userid amount"sChatTag);
        return 
Plugin_Handled;
    }
    
    if (!
GetCmdArg(2sAmountsizeof(sAmount)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_add userid amount"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_add userid amount"sChatTag);
        return 
Plugin_Handled;
    }
    
    new 
String:sTargetName[MAX_TARGET_LENGTH];
    new 
iTargetList[MAXPLAYERS], iTargetCountbool:tn_is_ml;
    
    
iTargetCount ProcessTargetString(sTargetclientiTargetListMAXPLAYERSCOMMAND_FILTER_CONNECTEDsTargetNamesizeof(sTargetName), tn_is_ml);
    
    
iAmount StringToInt(sAmount);
    
    for (new 
0iTargetCounti++)
    {
        new 
iTarget iTargetList[i];
        
        if (!
FullCheckClient(iTarget))
        {
            if (
FullCheckClient(client))
                
PrintToChat(client"[%s] No such user (%s)"sChatTagsTarget);
            else
                
PrintToServer("[%s] No such user (%s)"sChatTagsTarget);
            return 
Plugin_Handled;
        }
        
        if (
iAmount != 0)
        {
            
AddCandy(iTargetiAmount);
        }
        
        new 
String:sCandyNoise[255];
        
Format(sCandyNoisesizeof(sCandyNoise), "[%s] A nice admin gave you %i credits."sChatTagiAmount);
        
PrintNoise(sCandyNoise2iTarget);
    }
    
    return 
Plugin_Handled;
}

/**
 * Admin command to remove candy
 * from an user
 */
public Action:cRemoveCandy(clientargs)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return 
Plugin_Handled;
    new 
String:sTarget[32], String:sAmount[32];
    new 
iAmount;
    
    if (!
GetCmdArg(1sTargetsizeof(sTarget)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_remove userid amount"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_remove userid amount"sChatTag);
        return 
Plugin_Handled;
    }
    
    if (!
GetCmdArg(2sAmountsizeof(sAmount)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_remove userid amount"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_remove userid amount"sChatTag);
        return 
Plugin_Handled;
    }
    
    new 
String:sTargetName[MAX_TARGET_LENGTH];
    new 
iTargetList[MAXPLAYERS], iTargetCountbool:tn_is_ml;
    
    
iTargetCount ProcessTargetString(sTargetclientiTargetListMAXPLAYERSCOMMAND_FILTER_CONNECTEDsTargetNamesizeof(sTargetName), tn_is_ml);
    
    
iAmount StringToInt(sAmount);
    
    for (new 
0iTargetCounti++)
    {
        new 
iTarget iTargetList[i];
        
        if (!
FullCheckClient(iTarget))
        {
            if (
FullCheckClient(client))
                
PrintToChat(client"[%s] No such user (%s)"sChatTagsTarget);
            else
                
PrintToServer("[%s] No such user (%s)"sChatTagsTarget);
            return 
Plugin_Handled;
        }
        
        if (
iAmount != 0)
        {
            
RemoveCandy(iTargetiAmount);
        }
        
        new 
String:sCandyNoise[255];
        
Format(sCandyNoisesizeof(sCandyNoise), "[%s] An evil admin stole %i credits from you."sChatTagiAmount);
        
PrintNoise(sCandyNoise2iTarget);
    }
    
    return 
Plugin_Handled;
}

/**
 * Admin command to set the
 * amount of every users
 * candy to a specific value
 */
public Action:cResetCandy(clientargs)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return 
Plugin_Handled;
    new 
String:sAmount[32];
    
    if (!
GetCmdArg(1sAmountsizeof(sAmount)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_reset amount"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_reset amount"sChatTag);
        return 
Plugin_Handled;
    }
    
    new 
iAmount StringToInt(sAmount);
    if (
iAmount 0)
        return 
Plugin_Handled;
    
    if (!
FullCheckClient(client))
    {
        
// run as console -> execute it without asking. :(
        
new String:qReset[255];
        
Format(qResetsizeof(qReset), "UPDATE %scandydata SET candy = %s;"sTablePrefixsAmount);
        
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqReset);
        
PrintToServer("Reset all clients candy to %s"sAmount);
        return 
Plugin_Handled;
    }
    
    new 
Handle:mAskForSure CreateMenu(cResetCandyMenuCallback);
    
SetMenuTitle(mAskForSure"Reset candy to %s?"sAmount);
    
AddMenuItem(mAskForSure"no""No");
    
AddMenuItem(mAskForSuresAmount"Yes");
    
DisplayMenu(mAskForSureclient20);
    return 
Plugin_Handled;
}

/**
 * Admin command to reset the
 * database (deletes everything)
 */
public Action:cResetDB(clientargs)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return 
Plugin_Handled;
    
    if (!
FullCheckClient(client))
    {
        
// run as console -> execute it without asking. :(
        
new String:qReset[255];
        
Format(qResetsizeof(qReset), "DROP TABLE %scandydata;"sTablePrefix);
        
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqReset);
        
PrintToServer("Reset db, dropping EVERYTHING!");
        
CloseHandle(dbConnection);
        
dbConnection INVALID_HANDLE;
        
sCurrentDB "INVALID_DATABASE";
        
InitializeDatabase();
        return 
Plugin_Handled;
    }
    
    new 
Handle:mAskForSure CreateMenu(cResetDBMenuCallback);
    
SetMenuTitle(mAskForSure"Reset database?");
    
AddMenuItem(mAskForSure"no""No");
    
AddMenuItem(mAskForSure"yes""Yes");
    
DisplayMenu(mAskForSureclient20);
    return 
Plugin_Handled;
}

/**
 * Admin command to show how
 * much candy the user owns
 */
public Action:cGetCandy(clientargs)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return 
Plugin_Handled;
    new 
String:sTarget[32];
    
    if (!
GetCmdArg(1sTargetsizeof(sTarget)))
    {
        if (
FullCheckClient(client))
            
PrintToChat(client"[%s] Usage: sm_candy_get userid"sChatTag);
        else
            
PrintToServer("[%s] Usage: sm_candy_get userid"sChatTag);
        return 
Plugin_Handled;
    }
    
    new 
String:sTargetName[MAX_TARGET_LENGTH];
    new 
iTargetList[MAXPLAYERS], iTargetCountbool:tn_is_ml;
    
    
iTargetCount ProcessTargetString(sTargetclientiTargetListMAXPLAYERSCOMMAND_FILTER_CONNECTEDsTargetNamesizeof(sTargetName), tn_is_ml);
    
    for (new 
0iTargetCounti++)
    {
        new 
iTarget iTargetList[i];
    
        if (!
FullCheckClient(iTarget))
        {
            if (
FullCheckClient(client))
                
PrintToChat(client"[%s] No such user (%s)"sChatTagsTarget);
            else
                
PrintToServer("[%s] No such user (%s)"sChatTagsTarget);
            return 
Plugin_Handled;
        }
        
        new 
String:qGetUsersCandy[255], String:sSteamId[32];
        
GetClientAuthString(iTargetsSteamIdsizeof(sSteamId));
        
Format(qGetUsersCandysizeof(qGetUsersCandy), "SELECT candy FROM %scandydata WHERE steamid = '%s';"sTablePrefixsSteamId);
        
SQL_TQuery(dbConnectioncGetUsersCandyqGetUsersCandyclient);
        
PrintDebug(qGetUsersCandy);
    }
    
    return 
Plugin_Handled;
}

/**
 * Callback of cGetCandy
 */
public cGetUsersCandy(Handle:ownerHandle:hndlString:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Error while executing cGetCandy query: %s"sChatTagerror);
        return;
    }
    
    if (
SQL_GetRowCount(hndl) == 1)
    {
        
SQL_FetchRow(hndl);
        new 
iHisCandy SQL_FetchInt(hndl0);
        if (
FullCheckClient(data))
            
PrintToChat(data"[%s] This user has got \x03%i\x01 credits."sChatTagiHisCandy);
        else
            
PrintToServer("[%s] This user has got \x03%i\x01 credits."sChatTagiHisCandy);
    }
    else
    {
        if (
FullCheckClient(data))
            
PrintToChat(data"[%s] This user does not exist in the database."sChatTag);
        else
            
PrintToServer("[%s] This user does not exist in the database."sChatTag);
    }
}

/**
 * Check if this user exists in
 * the database
 */
public PrecheckUser(position)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return;
    new 
String:sSteamId[32];
    
strcopy(sSteamIdsizeof(sSteamId), sConnectingClients[position]);
    new 
String:qCheckForUser[255];
    
Format(qCheckForUsersizeof(qCheckForUser), "SELECT * FROM %scandydata WHERE steamid = '%s';"sTablePrefixsSteamId);
    
SQL_TQuery(dbConnectioncPrecheckUserqCheckForUserposition);
}

/**
 * Callback of PrecheckUser
 */
public cPrecheckUser(Handle:ownerHandle:hndlString:error[], any:data)
{
    new 
String:sSteamId[32];
    
strcopy(sSteamIdsizeof(sSteamId), sConnectingClients[data]);
    
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Error while executing PrecheckUser query: %s"sChatTagerror);
        return;
    }
    
    if (
SQL_GetRowCount(hndl) != 1)
    {
        
// Create new user
        
new String:qCreateNewUser[255];
        
Format(qCreateNewUsersizeof(qCreateNewUser), "INSERT INTO %scandydata (steamid, candy, lifetimecandy) VALUES ('%s', 0, 0);"sTablePrefixsSteamId);
        
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqCreateNewUser);
    }
    
    
RemoveFromConnecters(data);
}

/**
 * Give a player candy
 */
public AddCandy(clientamount)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return;
    if (!
FullCheckClient(client))
        return;
    new 
String:sSteamId[32];
    
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
    new 
String:qAddCandy[255];
    
Format(qAddCandysizeof(qAddCandy), "UPDATE %scandydata SET candy = candy + %i, lifetimecandy = lifetimecandy + %i WHERE steamid = '%s';"sTablePrefixamountamountsSteamId);
    
PrintDebug(qAddCandy);
    
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqAddCandy);
}

/**
 * You suck, so no candy for you!
 */
public RemoveCandy(clientamount)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return;
    if (!
FullCheckClient(client))
        return;
    new 
String:sSteamId[32];
    
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
    new 
String:qAddCandy[255];
    
Format(qAddCandysizeof(qAddCandy), "SELECT candy, '%s' FROM %scandydata WHERE steamid = '%s';"sSteamIdsTablePrefixsSteamId);
    
SQL_TQuery(dbConnectioncCheckForNegativeAmountqAddCandyamount);
}

public 
cCheckForNegativeAmount(Handle:ownerHandle:hndlString:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Error in remove candy query: %s"sChatTagerror);
        return;
    }
    
    
SQL_FetchRow(hndl);
    if (
SQL_FetchInt(hndl0) - data 0)
        return;
    new 
String:sSteamId[32];
    
SQL_FetchString(hndl1sSteamIdsizeof(sSteamId));

    new 
String:qAddCandy[255];
    
Format(qAddCandysizeof(qAddCandy), "UPDATE %scandydata SET candy = candy - %i WHERE steamid = '%s';"sTablePrefixdatasSteamId);
    
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqAddCandy);
}

/**
 * Set a specific amount of candy
 */
public SetCandy(clientamount)
{
    
InitializeDatabase();
    if (
dbConnection == INVALID_HANDLE)
        return;
    if (!
FullCheckClient(client))
        return;
    new 
String:sSteamId[32];
    
GetClientAuthString(clientsSteamIdsizeof(sSteamId));
    new 
String:qAddCandy[255];
    
Format(qAddCandysizeof(qAddCandy), "UPDATE %scandydata SET candy = %i WHERE steamid = '%s';"sTablePrefixamountsSteamId);
    
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqAddCandy);
}

/**
 * Discard query callback
 */
public cIgnoreQueryCallback(Handle:ownerHandle:hndlString:error[], any:data)
{
    return;
}

/**
 * Perform a full check if
 * the client is valid
 */
public bool:FullCheckClient(client)
{
    if (
client 1) {
        
PrintDebug("Client < 0");
        return 
false;
    }
    
    if (!
IsClientConnected(client)) {
        
PrintDebug("Client not connected");
        return 
false;
    }
    
    if (!
IsClientInGame(client)) {
        
PrintDebug("Client not ingame");
        return 
false;
    }
    
    if (
IsFakeClient(client)) {
        
PrintDebug("Client is fake");
        return 
false;
    }
    
    return 
true;
}

/**
 * Candy stats SQL callback
 */
public cStatsSQLCallback(Handle:ownerHandle:hndlString:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Error in buy menu query: %s"sChatTagerror);
        return;
    }
    
    
SQL_FetchRow(hndl);
    new 
iCurrentMoney SQL_FetchInt(hndl0);
    new 
iLifetimeMoney SQL_FetchInt(hndl1);
    
    
PrintToChat(data"[%s] You currently own \x04%i\x01 credits. You totally earned \x04%i\x01!"sChatTagiCurrentMoneyiLifetimeMoney);
}

/**
 * Buy menu SQL callback
 */
public cBuyMenuSQLCallback(Handle:ownerHandle:hndlString:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Error in buy menu query: %s"sChatTagerror);
        return;
    }
    
    
SQL_FetchRow(hndl);
    new 
iCurrentMoney SQL_FetchInt(hndl0);
    
    
Client_iCurrentMoney[data] = iCurrentMoney;
    new 
Handle:mBuyMenu CreateMenu(hShopMenuHandler);
    
SetMenuTitle(mBuyMenu"Your credits: %i"iCurrentMoney);

    for(new 
i=0;i<SHOP_MENU_MAX;i++)
    {
        
AddMenuItem(mBuyMenu,"",ShopMenuName[i]);
    }
    
    
DisplayMenu(mBuyMenudata20);
}

/**
 * Buy menu callback
 */
public cBuyMenu(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        new 
String:info[32]
        
GetMenuItem(menuparam2infosizeof(info))
        
        new 
String:qGetUsersCandy[255], String:sSteamId[32];
        
GetClientAuthString(param1sSteamIdsizeof(sSteamId));
        
Format(qGetUsersCandysizeof(qGetUsersCandy), "SELECT candy, '%s' FROM %scandydata WHERE steamid = '%s';"infosTablePrefixsSteamId);
        
SQL_TQuery(dbConnectioncBuyMenuCallbackSQLCallbackqGetUsersCandyparam1);
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu)
    }
}

/**
 * [Buy menu callback] [SQL callback] (lol)
 */
public cBuyMenuCallbackSQLCallback(Handle:ownerHandle:hndlString:error[], any:data)
{
    
PrintDebug("MenuCallback!");
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("[%s] Error in buy menu query: %s"sChatTagerror);
        return;
    }
    
    
PrintDebug("Get all data");
    
SQL_FetchRow(hndl);
    new 
iCurrentMoney SQL_FetchInt(hndl0);
    new 
String:sBuyEntry[32];
    
SQL_FetchString(hndl1sBuyEntrysizeof(sBuyEntry));
    new 
iBuyEntry StringToInt(sBuyEntry);
    
    if (
iBuyEntry 1024)
    {
        new 
String:sTitle[32], String:sPrice[32], String:sOnCmd[256], String:sOffCmd[256], String:sTime[32];
        new 
String:sFilePath[PLATFORM_MAX_PATH];
        
BuildPath(Path_SMsFilePathsizeof(sFilePath),"configs/buymenu.txt");

        if (!
FileExists(sFilePath))
        {
        
PrintToServer("[%s] buymenu.txt not found in configs folder!"sChatTag);
        return;
        }
        new 
Handle:kv CreateKeyValues("Buymenu");
        
FileToKeyValues(kvsFilePath);
        if (!
KvJumpToKey(kvsBuyEntry))
        {
            return;
        }
        
        
KvGetString(kv"title"sTitlesizeof(sTitle));
        
KvGetString(kv"price"sPricesizeof(sPrice));
        
KvGetString(kv"oncmd"sOnCmdsizeof(sOnCmd));
        
KvGetString(kv"offcmd"sOffCmdsizeof(sOffCmd));
        
KvGetString(kv"time"sTimesizeof(sTime));
        new 
iPriceFloat:iTime;
        
iPrice StringToInt(sPrice);
        
iTime StringToFloat(sTime);
        
CloseHandle(kv);
        if (
iCurrentMoney iPrice)
        {
            
// U faild n00b!!
            
PrintDebug("Insufficient funds!");
            
PrintToChat(data"[%s] You don't have enough credits to buy that! (Required: %i)"sChatTagiPrice);
            return;
        }

        
PrintDebug("Parsing ?$#~|");
        new 
String:sUserId[8], String:sName[128], String:sIndex[4], String:sSteamId[32], String:sQuotedName[128];
        
IntToString(GetClientUserId(data), sUserIdsizeof(sUserId));
        
GetClientName(datasNamesizeof(sName));
        
GetClientAuthString(datasSteamIdsizeof(sSteamId));
        
IntToString(datasIndexsizeof(sIndex));
        
Format(sQuotedNamesizeof(sQuotedName), "\"%s\""sName);
        
ReplaceChar("=""\""sOnCmd);
        
ReplaceChar("?"sUserIdsOnCmd);
        
ReplaceChar("$"sNamesOnCmd);
        
ReplaceChar("#"sIndexsOnCmd);
        
ReplaceChar("~"sSteamIdsOnCmd);
        
ReplaceChar("|"sQuotedNamesOnCmd);
        
        
RemoveCandy(dataiPrice);
        
PrintDebug("Running OnCmd");
        
ServerCommand(sOnCmd);
        
        if (
iTime 0)
        {
            
PrintDebug("Command has off time");
            
ReplaceChar("=""\""sOnCmd);
            
ReplaceChar("?"sUserIdsOffCmd);
            
ReplaceChar("$"sNamesOffCmd);
            
ReplaceChar("#"sIndexsOffCmd);
            
ReplaceChar("~"sSteamIdsOffCmd);
            
ReplaceChar("|"sQuotedNamesOffCmd);

            
PrintDebug("Creating off timer");
            new 
String:sSmallOffCmd[128];
            
strcopy(sSmallOffCmdsizeof(sSmallOffCmd), sOffCmd);
            new 
iDataStore AddToConnecters(sSmallOffCmd); // abuse of the AddToConnecters, but who cares?
            
CreateTimer(iTimetStopCommandiDataStore);
        }
    }
    else
    {
        
iBuyEntry -= 1024;
        if (
strcmp(sNames[iBuyEntry], NULLNAME) == 0)
            return;
        if (
iCurrentMoney iCosts[iBuyEntry])
        {
            
// U faild n00b!!
            
PrintDebug("Insufficient funds!");
            
PrintToChat(data"[%s] You don't have enough credits to buy that! (Required: %i)"sChatTagiCosts[iBuyEntry]);
            return;
        }
        
Call_StartFunction(INVALID_HANDLEfCallbacks[iBuyEntry][0]);
        
Call_PushCell(data);
        
Call_PushCell(iCurrentMoney);
        new 
Float:iResult;
        if (
Call_Finish(iResult) == SP_ERROR_NONE)
        {
            if (
iResult 0)
            {
                new 
iRemoveMoney RoundToNearest(iCosts[iBuyEntry]*iResult);
                if (
iRemoveMoney iCurrentMoney)
                    return;
                
RemoveCandy(dataiRemoveMoney);
            }
        }
        
        if ((
iStopTimes[iBuyEntry] > 0) && (fCallbacks[iBuyEntry][1] != INVALID_FUNCTION))
        {
            new 
String:sFitBuyEntry[128];
            
strcopy(sFitBuyEntrysizeof(sFitBuyEntry), sBuyEntry);
            new 
iStore AddToConnecters(sFitBuyEntry);
            
iPushArray[iStore] = data;
            
CreateTimer(iStopTimes[iBuyEntry], tStopCommandiStore);
        }
    }
}

public 
ReplaceChar(String:sSplitChar[], String:sReplace[], String:sString[256])
{
    
StrCat(sStringsizeof(sString), " ");
    new 
String:sBuffer[16][256];
    
ExplodeString(sStringsSplitCharsBuffersizeof(sBuffer), sizeof(sBuffer[]));
    
strcopy(sStringsizeof(sString), "");
    for (new 
0sizeof(sBuffer); i++)
    {
        if (
strcmp(sBuffer[i], "") == 0)
            continue;
        if (
!= 0)
        {
            new 
String:sTmpStr[256];
            
Format(sTmpStrsizeof(sTmpStr), "%s%s"sReplacesBuffer[i]);
            
StrCat(sStringsizeof(sString), sTmpStr);
        }
        else
        {
            
StrCat(sStringsizeof(sString), sBuffer[i]);
        }
    }
}

/**
 * Reset candy menu callback
 */
public cResetCandyMenuCallback(Handle:menuMenuAction:actionclientitem)
{
    if (
action == MenuAction_Select)
    {
        new 
String:info[32]
        
GetMenuItem(menuiteminfosizeof(info))
        
        if (
strcmp(info"no"false) == 0)
            return;
        
        new 
String:qResetCandy[255];
        
Format(qResetCandysizeof(qResetCandy), "UPDATE %scandydata SET candy = '%s';"sTablePrefixinfo);
        
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqResetCandy);
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu)
    }
}

/**
 * Reset database menu callback
 */
public cResetDBMenuCallback(Handle:menuMenuAction:actionclientitem)
{
    if (
action == MenuAction_Select)
    {
        new 
String:info[32]
        
GetMenuItem(menuiteminfosizeof(info))
        
        if (
strcmp(info"no"false) == 0)
            return;
        
        new 
String:qReset[255];
        
Format(qResetsizeof(qReset), "DROP TABLE %scandydata;"sTablePrefix);
        
SQL_TQuery(dbConnectioncIgnoreQueryCallbackqReset);
        
PrintToServer("Reset db, dropping EVERYTHING!");
        
CloseHandle(dbConnection);
        
dbConnection INVALID_HANDLE;
        
sCurrentDB "INVALID_DATABASE";
        
InitializeDatabase();
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu)
    }
}

/**
 * STOP the MADNESS!!
 */
public Action:tStopCommand(Handle:timerany:data)
{
    new 
iEntry StringToInt(sConnectingClients[data]);
    if (
iEntry >= 1024)
    {
        
iEntry -= 1024;
        if (
fCallbacks[iEntry][1] == INVALID_FUNCTION)
            return;
        new 
client iPushArray[data];
        
Call_StartFunction(INVALID_HANDLEfCallbacks[iEntry][1]);
        
Call_PushCell(client);
        
Call_Finish(_);
        
iPushArray[data] = 0;
    }
    else
    {
        
PrintDebug("Off timer called with this command:");
        
PrintDebug(sConnectingClients[data]);
        
ServerCommand(sConnectingClients[data]);
    }
    
RemoveFromConnecters(data);
}

/**
 * API
 */
public RegisterCandy(Handle:hPluginiNumParams)
{
    new 
String:sName[256], iBuyCostsFloat:iStopTime, Function:fStart, Function:fStop,iGroup;
    
GetNativeString(1sNamesizeof(sName));
    
iBuyCosts GetNativeCell(2);
    
iStopTime GetNativeCell(3);
    
fStart GetNativeCell(4);
    
fStop GetNativeCell(5);
    
iGroup GetNativeCell(6);
    
    if (
strlen(sName) == 0)
    {
        
LogError("Error: Candy name not given!");
        return -
1;
    }
    if (
iBuyCosts <= 0)
    {
        
LogError("Error: Buy costs <= 0!");
        return -
1;
    }
    new 
iClicks 0;
    new 
bool:run true// warning, constant expression blah blah ow shut up!
    
while (run)
    {
        if (
strcmp(sNames[iBuyCount], NULLNAME) == 0)
            break;
        
iBuyCount++;
        if (
iBuyCount >= sizeof(sNames))
        {
            
iBuyCount 0;
            
iClicks++;
        }
        if (
iClicks >= 2)
        {
            
LogError("Error: Too much candy (max. %i)"sizeof(sNames));
            return -
1// No free spots left
        
}
    }
    
strcopy(sNames[iBuyCount], sizeof(sNames[]), sName);
    
iCosts[iBuyCount] = iBuyCosts;
    
fCallbacks[iBuyCount][0] = fStart;
    
fCallbacks[iBuyCount][1] = fStop;
    if (
iStopTime 0)
        
iStopTimes[iBuyCount] = iStopTime;
    
    
iGroups[iBuyCount] = iGroup;
    return 
iBuyCount;
}

public 
DeregisterCandy(Handle:hPluginiNumParams)
{
    new 
iCandyId GetNativeCell(1);
    
fCallbacks[iCandyId][0] = INVALID_FUNCTION;
    
fCallbacks[iCandyId][1] = INVALID_FUNCTION;
    
iCosts[iCandyId] = 0;
    
sNames[iCandyId] = NULLNAME;
    
iStopTimes[iCandyId] = 0.0;
    
iGroups[iCandyId] = SHOPMENU_OTHER_INDEX;
}




public 
hShopMenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        if(
param2 SHOP_MENU_MAX)
        {
            new 
String:sFilePath[PLATFORM_MAX_PATH];
            
BuildPath(Path_SMsFilePathsizeof(sFilePath),"configs/buymenu.txt");
            if (!
FileExists(sFilePath))
            {
                
PrintToServer("[%s] buymenu.txt not found in configs folder!"sChatTag);
                return;
            }
            new 
Handle:kv CreateKeyValues("Buymenu");
            
FileToKeyValues(kvsFilePath);
         
            if (!
KvGotoFirstSubKey(kv))
            {
                
PrintToServer("[%s] Failed to read the buymenu.txt"sChatTag);
                return;
            }
            
            new 
Handle:mBuyMenu CreateMenu(cBuyMenu);
            
SetMenuTitle(mBuyMenu"Your credits: %i"Client_iCurrentMoney[param1]);

            for(new 
0sizeof(sNames); i++)
            {
                if (
strcmp(sNames[i], NULLNAME) == || iGroups[i] != param2)
                    continue;
                new 
String:sInfo[128];
                
IntToString(i+1024sInfosizeof(sInfo));
                
AddMenuItem(mBuyMenusInfosNames[i], (Client_iCurrentMoney[param1] >= iCosts[i] ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED));
            }
            
            
decl String:buffer[255];
            do
            {
                
KvGetSectionName(kvbuffersizeof(buffer));
                new 
group KvGetNum(kv"group",SHOPMENU_OTHER_INDEX);
                if(
group == param2// group match!
                
{
                    new 
String:sTitle[32], String:sCosts[32], String:sText[64]
                    
KvGetString(kv"title"sTitlesizeof(sTitle));
                    
KvGetString(kv"price"sCostssizeof(sCosts));
                    
Format(sTextsizeof(sText), "%s (%s)"sTitlesCosts);
                    
                    
AddMenuItem(mBuyMenubuffersText, (Client_iCurrentMoney[param1] >= StringToInt(sCosts) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED));
                }
            } while (
KvGotoNextKey(kv));
            
CloseHandle(kv);
            
DisplayMenu(mBuyMenuparam120);
        }
    } else if (
action == MenuAction_End)
    {
        
CloseHandle(menu)
    }
}


public 
eRoundWin(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
winteam GetEventInt(event,"team");
    if(
winteam 2)
        return;
    
    new 
maxClients GetMaxClients();
    new 
amount GetConVarInt(cvCandlyAdmin);
    new 
String:display[128];
    
Format(display,sizeof(display),"CONGRATULATIONS! YOUR TEAM WON %d CREDITS!",amount);
    for (new 
1<= maxClientsi++)
    {
        if (
IsClientInGame(i) && GetClientTeam(i) == winteam)
        {
            new 
adminflags GetUserFlagBits(i);
            if(
adminflags != && adminflags ADMFLAG_GENERIC)
            {
                
AddCandy(i,amount);
                
PrintCenterText(i,display);
            }
        }
    }

Candy_funpack.sp

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>

#define PLUGIN_VERSION "1.5"

public Plugin:myinfo 
{
    
name "Fun package for Candy",
    
author "GachL & TheSpyHunter",
    
description "This plugin is a pack of functions that work well with Candy for TF2.",
    
version PLUGIN_VERSION,
    
url "http://www.ultimatefragforce.co.uk"
}

new 
Handle:cvNoiseLevel;
//new Handle:sdkRegenerate;
new bool:bPlayerHasCrit[MAXPLAYERS]

public 
OnPluginStart()
{
    
RegAdminCmd("sm_candy_buy_crit"cBuyCritADMFLAG_BAN"Get crit 100%");
    
RegAdminCmd("sm_candy_buy_invincible"cBuyInvincibleADMFLAG_BAN"Get invincibility");
    
RegAdminCmd("sm_candy_buy_uber"cBuyUberADMFLAG_BAN"Get instant uber (medic)");
    
RegAdminCmd("sm_candy_buy_regen"cBuyRegenADMFLAG_BAN"Fill health and ammo");
    
RegAdminCmd("sm_candy_buy_repair"cBuyRepairADMFLAG_BAN"Instant repair all buildings (engineer)");
    
//RegAdminCmd("sm_candy_buy_invisible", cBuyInvisibility, ADMFLAG_BAN, "Be invisible");
    
RegAdminCmd("sm_candy_buy_noreload"cBuyReloadADMFLAG_BAN"No reloading needed");
    
RegAdminCmd("sm_candy_buy_slay"cBuySlayADMFLAG_BAN"Slay a player!");
    
    
/*StartPrepSDKCall(SDKCall_Player);
    PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Signature, "Regenerate");
    sdkRegenerate = EndPrepSDKCall();
    */
    
cvNoiseLevel CreateConVar("sm_candy_buy_noiselevel""2""1 = silent, 2 = buyer only, 3 = everyone"FCVAR_PLUGINtrue1.0true3.0);
}

public 
Action:cBuyCrit(cclientargs)
{
    new 
String:sErrStr[] = "[candypack] Usage: sm_candy_buy_crit <userid> <onoff>";
    if (
args 2)
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sclient[32];
    
GetCmdArg(1sclientsizeof(sclient));
    new 
client GetClientOfUserId(StringToInt(sclient));
    if (!
FullCheckClient(client))
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sonoff[32];
    
GetCmdArg(2sonoffsizeof(sonoff));
    new 
onoff StringToInt(sonoff);
    new 
noise GetConVarInt(cvNoiseLevel);
    
    if (
onoff == 1)
    {
        
SetPlayerCrit(clienttrue);
        if (
noise == 2)
        {
            
PrintToChat(client"Enabled criticals on you!");
        }
        else if (
noise == 3)
        {
            new 
String:name[128];
            
GetClientName(clientnamesizeof(name));
            
PrintToChatAll("Enabled criticals on %s!"name);
        }
    }
    else
    {
        
SetPlayerCrit(clientfalse);
        if (
noise == 2)
        {
            
PrintToChat(client"Disabled criticals on you!");
        }
        else if (
noise == 3)
        {
            new 
String:name[128];
            
GetClientName(clientnamesizeof(name));
            
PrintToChatAll("Disabled criticals on %s!"name);
        }
    }
    
    return 
Plugin_Handled;
}

public 
Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)
{
    if (
PlayerHasCrit(client))
    {
        
result true;
        return 
Plugin_Handled;
    }
    else
    {
        return 
Plugin_Continue;
    }
}

public 
bool:PlayerHasCrit(client)
{
    return 
bPlayerHasCrit[client-1];
}

public 
SetPlayerCrit(clientbool:onoff)
{
    
bPlayerHasCrit[client-1] = onoff;
}

public 
Action:cBuyInvincible(cclientargs)
{
    new 
String:sErrStr[] = "[candypack] Usage: sm_candy_buy_invincible <userid> <onoff>";
    if (
args 2)
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sclient[32];
    
GetCmdArg(1sclientsizeof(sclient));
    new 
client GetClientOfUserId(StringToInt(sclient));
    if (!
FullCheckClient(client))
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sonoff[32];
    
GetCmdArg(2sonoffsizeof(sonoff));
    new 
onoff StringToInt(sonoff);
    new 
noise GetConVarInt(cvNoiseLevel);
    
    if (
onoff == 1)
    {
        
SetEntProp(clientProp_Data"m_takedamage"01);
        if (
noise == 2)
        {
            
PrintToChat(client"Enabled invincibility on you!");
        }
        else if (
noise == 3)
        {
            new 
String:name[128];
            
GetClientName(clientnamesizeof(name));
            
PrintToChatAll("Enabled invincibility on %s!"name);
        }
    }
    else
    {
        
SetEntProp(clientProp_Data"m_takedamage"21);
        if (
noise == 2)
        {
            
PrintToChat(client"Disabled invincibility on you!");
        }
        else if (
noise == 3)
        {
            new 
String:name[128];
            
GetClientName(clientnamesizeof(name));
            
PrintToChatAll("Disabled invincibility on %s!"name);
        }
    }
    return 
Plugin_Handled;
}

public 
Action:cBuyUber(cclientargs)
{
    new 
String:sErrStr[] = "[candypack] Usage: sm_candy_buy_uber <userid> <percent>";
    if (
args 2)
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sclient[32];
    
GetCmdArg(1sclientsizeof(sclient));
    new 
client GetClientOfUserId(StringToInt(sclient));
    if (!
FullCheckClient(client))
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sonoff[32];
    
GetCmdArg(2sonoffsizeof(sonoff));
    new 
onoff StringToInt(sonoff);
    new 
noise GetConVarInt(cvNoiseLevel);
    
    if (
TF2_GetPlayerClass(client) == TF2_GetClass("medic"))
    {
        new 
iSlot GetPlayerWeaponSlot(client1);
        if (
iSlot 0)
            
SetEntPropFloat(iSlotProp_Send"m_flChargeLevel"onoff*0.01);
        if (
noise == 2)
        {
            
PrintToChat(client"Gave you %i\% ubercharge!"onoff);
        }
        else if (
noise == 3)
        {
            new 
String:name[128];
            
GetClientName(clientnamesizeof(name));
            
PrintToChatAll("Gave %s %i\% ubercharge!"nameonoff);
        }
    }
    return 
Plugin_Handled;
}

public 
Action:cBuyRegen(cclientargs)
{
    new 
String:sErrStr[] = "[candypack] Usage: sm_candy_buy_regen <userid>";
    if (
args 1)
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sclient[32];
    
GetCmdArg(1sclientsizeof(sclient));
    new 
client GetClientOfUserId(StringToInt(sclient));
    if (!
FullCheckClient(client))
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
noise GetConVarInt(cvNoiseLevel);
    
    new 
iClassHealth[] = {-1125125200175150300175125125};
    
SetEntityHealth(clientiClassHealth[GetEntProp(clientProp_Send"m_iClass")]);
    if (
noise == 2)
    {
        
PrintToChat(client"Gave you full health and ammo!");
    }
    else if (
noise == 3)
    {
        new 
String:name[128];
        
GetClientName(clientnamesizeof(name));
        
PrintToChatAll("Gave %s full health and ammo!"name);
    }
    return 
Plugin_Handled;
}

public 
Action:cBuyRepair(cclientargs)
{
    return 
Plugin_Handled;
}

public 
Action:cBuyInvisibility(cclientargs)
{
    return 
Plugin_Handled;
}

public 
Action:cBuyReload(cclientargs)
{
    return 
Plugin_Handled;
}

public 
Action:cBuySlay(cclientargs)
{
    new 
String:sErrStr[] = "[candypack] Usage: sm_candy_buy_slay <userid>";
    if (
args 1)
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    new 
String:sclient[32];
    
GetCmdArg(1sclientsizeof(sclient));
    new 
client GetClientOfUserId(StringToInt(sclient));
    if (!
FullCheckClient(client))
    {
        
PrintToServer(sErrStr);
        return 
Plugin_Handled;
    }
    {
    new 
Handle:hMenu CreateMenu(cSlayPlayer);
    
SetMenuTitle(hMenu"Slay who?");
    for (new 
1<= GetClientCount(); i++)
    {
    if (
IsClientConnected(i) && IsClientInGame(i))
        {
        new 
String:sName[255], String:sInfo[4];
        
GetClientName(isNamesizeof(sName));
        
IntToString(isInfosizeof(sInfo));
        
AddMenuItem(hMenusInfosName);
        }
    }
    
DisplayMenu(hMenuclient20);
    return 
Plugin_Handled;
    }
}

public 
cSlayPlayer(Handle:menuMenuAction:actionclientresult)
{
    if (
action == MenuAction_Select)
    {
        new 
String:info[32], String:sAName[255], String:sVName[255];
        
GetMenuItem(menuresultinfosizeof(info))
        new 
hTarget StringToInt(info);
        
GetClientName(clientsANamesizeof(sAName));
        
GetClientName(hTargetsVNamesizeof(sVName));
        
        
SlapPlayer(hTargetGetClientHealth(hTarget) + 10false); // +10 just to be sure
        
new noise GetConVarInt(cvNoiseLevel);
        if (
noise 1)
        {
            
PrintToChat(client"You slayed %s"sVName);
            
PrintToChat(hTarget"%s slayed you"sAName);
        }
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu)
    }
}

public 
bool:FullCheckClient(client)
{
    if (
client 1)
        return 
false;
    
    if (!
IsClientConnected(client))
        return 
false;
    
    if (!
IsClientInGame(client))
        return 
false;
    
    if (
IsFakeClient(client))
        return 
false;
    
    return 
true;

Example of buymenu.txt

PHP Code:
"Buymenu"
{
    
"1"
    
{
        
"group"         "0"
        "title"        "  +25   |  HP BOOST"
        "price"        "15"
        "oncmd"        "sm_boosthealth | 25;sm_candy_msg | =25 HP BOOST!="
        "offcmd"    ""
        "time"        ""
    
}
    
"2"
    
{
        
"group"         "1"
        "title"        "30sec  |  Disco Confusion!"
        "price"        "80"
        "oncmd"        "lights_disco 1;sm_disco 1;sm_candy_msg | =Disco Confusion!="
        "offcmd"    "lights_reset 1;sm_disco 0;sm_say Disco Confusion effects have worn off"
        "time"        "30"
    
}
    
"3"
    
{
        
"group"         "0"
        "title"        "20sec  | Running Shoes"
        "price"        "170"
        "oncmd"        "sm_effect | 5;sm_candy_msg | =Super Sonic Running Shoes!="
        "offcmd"    "sm_say $ effects have worn off"
        "time"        "20"
    
}
    
"4"
    
{
        
"group"         "0"
        "title"        "15sec  |  Critical Hits!"
        "price"        "170"
        "oncmd"        "sm_candy_buy_crit ? 1;sm_candy_msg | =Critical Hits!="
        "offcmd"    "sm_candy_buy_crit ? 0;sm_say $ effects have worn off"
        "time"        "15"
    
}
    
"5"
    
{
        
"group"         "0"
        "title"        " +300  |  HP BOOST"
        "price"        "170"
        "oncmd"        "sm_boosthealth | 300;sm_candy_msg | =300 HP BOOST!="
        "offcmd"    ""
        "time"        "0"
    
}
    
"6"
    
{
        
"group"         "0"
        "title"        "MEDIC |  200% Uber!"
        "price"        "170"
        "oncmd"        "sm_candy_buy_uber ? 100;sm_candy_msg | =200% Uber Boost!="
        "offcmd"    ""
        "time"        "0"
    
}
    
"7"
    
{
        
"group"         "5"
        "title"        "Gift A Player 250 Credits"
        "price"        "250"
        "oncmd"        "sm_candy_buy_givecred ?;sm_candy_msg | =A GIFT OF 250 CREDITS="
        "offcmd"    ""
        "time"        "1"
    
}
    
"8"
    
{
        
"group"         "5"
        "title"        "15sec  |  Helium Balloons!"
        "price"        "270"
        "oncmd"        "sm_effect | 2 | 1;sm_candy_msg | =too many balloons...fly awaaaay! ="
        "offcmd"    "sm_say $ effects have worn off"
        "time"        "15"
    
}
    
"9"
    
{
        
"group"         "5"
        "title"        "15sec  |  HP Sucking Bullets!"
        "price"        "270"
        "oncmd"        "sm_effect | 16 | 1;sm_candy_msg | =Steal HP Bullets!="
        "offcmd"    "sm_say $ effects have worn off"
        "time"        "15"
    
}
    
"10"
    
{
        
"group"         "5"
        "title"        "10sec  |  Turn into Flames!"
        "price"        "270"
        "oncmd"        "sm_effect | 6 | 1;sm_candy_msg | =Flame Onnn!, better get out of the way!="
        "offcmd"    "sm_say $ effects have worn off"
        "time"        "10"
    
}

Example of what you need to add to databases.cfg

PHP Code:
        "candyscript"
        
{
            
"driver"        "default"
            "host"             "78.12.52.63"
            "database"         "great_candycredits"
            "user"        "uff_creditsystem"
            "pass"        "thisisagreatpassword"
            
//"timeout"    "0"
            
"port"        "3306"
    

If anyone wants help hook me up on ventrilo or leave me a message on my website.

Ventrilo Details
IP: 193.238.84.120
Port 3082

Peace

Dodge (TheSpyHunter)
www.ultimatefragforce.co.uk
__________________

Last edited by TheSpyHunter; 04-01-2010 at 21:39.
TheSpyHunter is offline
TheSpyHunter
Senior Member
Join Date: Jul 2009
Old 04-01-2010 , 21:30   Credit/ Candy Mod: Tweaks
Reply With Quote #46

Anyone actualy using this mod anymore?
__________________
TheSpyHunter is offline
noodleboy347
AlliedModders Donor
Join Date: Mar 2009
Old 04-01-2010 , 21:54   Re: [TF2] Shop Credit Mod + Tweaks
Reply With Quote #47

Does this still lag the server like Gachl's versions?
noodleboy347 is offline
cybersquare420
Veteran Member
Join Date: Nov 2008
Old 04-02-2010 , 07:43   Re: [TF2] Shop Credit Mod + Tweaks
Reply With Quote #48

hmmm... i never get lag from the version i run... and yes we still run this on several servers and it is wildly popular...
i would maybe use this one... but i am happy with my setup... (well, im happy enough... and i cant seem to find a version with the couple additions i would like... or someone to code them) but i bet many will appreciate this info as this plugin set can be a royal pain for some less experienced admins to get working.
__________________
cybersquare420 is offline
drummingpro
Junior Member
Join Date: Mar 2010
Old 04-05-2010 , 15:12   Re: [TF2] Shop Credit Mod + Tweaks
Reply With Quote #49

i have the menu all installed and everything the problem is that when i popen up the menu where it says liike other,hats,evil and stuff if i select one of those nothing happens and the menu goes away
drummingpro is offline
TheSpyHunter
Senior Member
Join Date: Jul 2009
Old 04-06-2010 , 16:29   Re: [TF2] Shop Credit Mod + Tweaks
Reply With Quote #50

What plugins do you have it linked to?

This mod only links to other mods via the buymenu.txt, it has hardly any shop items of its own, thats the beauty of it - you can create/ add your own dshop items.

Example:

Equipment editor for - Hats
GiveWeapon Mod for - Guns
__________________
TheSpyHunter 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 21:23.


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