View Single Post
Author Message
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 01-22-2015 , 06:31   [Hosties] DrugShop for JailBreak
Reply With Quote #1

DrugShop for JailBreak


/* Introduction */
Terrorists accumulate cash by winning rounds and can buy one of 5 drugs when they reach $16000.
10 drugs of a certain type can be redeemed for a pistol. The pistol given is determined by which drug is being redeemed.

/* Modules */
[DrugShop] Confiscate
If a CT sees a T buying or selling drugs then they will confiscate those drugs and it will be added to their drug totals.
Where multiple CT's can see the drug trade, only the closest will confiscate the drugs.
To activate this module, move ds_confiscate.smx to your plugin folder.

/* Setup */
Add one of the following to your databases.cfg in /addons/sourcemod/config/
PHP Code:
If you have a MySQL database:
"drugshop"
{
    
"driver"                        "mysql"
    "host"                          "<your-database-host>"
    "database"                      "<your-database-name>"
    "user"                          "<username>"
    "pass"                          "<password>"
}

If 
you dont have a MySQL database (it will host a SQLite db on your gameserver):
"drugshop"
{
    
"driver"                        "sqlite"
    "host"                          "localhost"
    "database"                      "drugshop"
    "user"                          "root"
    "pass"                          ""

The plugin will automatically create the necessary tables.

Drag and drop drugshop.smx to your plugins directory: /addons/sourcemod/plugins/

Drag and drop drugshop.phrases.txt to your translations directory: /addons/sourcemod/translations/

/* Commands */
PHP Code:
say !drugshop in chat to open the menu 
/* Global Forwards */
PHP Code:
/**
 * Called after a drug purchase is made.
 *
 * @param auth               Full steam ID of client making purchase.
 * @param drug_name          Name of the drug being purchased.
 * @param drug               ID of the drug being purchased.
 * @param num_drugs          Number of drugs purchased.
 */ 
forward OnDrugBuy(const String:auth[], const String:drug_name[], drugnum_drugs);

/**
 * Called after a drug is sold.
 *
 * @param auth               Full steam ID of client making purchase.
 * @param drug_name          Name of the drug being purchased.
 * @param drug               ID of the drug being purchased.
 * @param num_drugs          Number of drugs sold.
 */ 
forward OnDrugSell(const String:auth[], const String:drug_name[], drugnum_drugs);

/**
 * Called when drugs per pistol is changed.
 *
 * @param num_drugs          Number of drugs it costs to buy a pistol.
 */ 
forward OnDrugsPerPistolChanged(num_drugs);

/**
 * Called when cost per drug is changed.
 *
 * @param cost               Cost to purchase a Drug.
 */ 
forward OnCostPerDrugChanged(cost);

/**
 * Called when a Weapon name is changed.
 *
 * @param weapon_name        New Weapon name.
 * @param weapon_id          Weapon ID.
 */ 
forward OnWeaponNameChanged(const String:weapon_name[], weapon_id);

/**
 * Called when a Drug name is changed.
 *
 * @param drug_name          New Drug name.
 * @param drug               Drug ID.
 */ 
forward OnDrugNameChanged(const String:drug_name[], drug); 
/* Natives */
PHP Code:
/**
 * Add (or remove by specifying -ve num_drugs) drugs to/from a player.
 *
 * @param auth               Full steam id of client making purchase.
 * @param drug               Name of the drug being purchased.
 * @param num_drugs          Number of drugs purchased.
 * @noreturn
 */ 
native DrugShop_AddDrugs(const String:auth[], drugnum_drugs);

/**
 * Gets the name of a drug for a specified index.
 *
 * @param drug_name          Name of the drug.
 * @param drug               Drug index between 0 & 4.
 * @param drug               Max length of name string.
 * @return                   true on success.
 */ 
native DrugShop_GetDrugName(const String:drug_name[], drugmax_size);

/**
 * Gets the name of a weapon for a specified index.
 *
 * @param weapon_name        Name of the weapon. (pass in empty string atleast size 32)
 * @param weapon             Weapon index between 0 & 4.
 * @param drug               Max length of name string.
 * @return                   True on success.
 */ 
native DrugShop_GetWeaponName(const String:weapon_name[], weaponmax_size);

/**
 * Gets the ID of a drug for a specified drug name.
 *
 * @param drug_name          Name of the drug.
 * @return                   Drug index number on success or -1 if name not found.
 */ 
native DrugShop_GetDrugID(const String:drug_name[]);

/**
 * Gets the ID of a weapon for a specified weapon name.
 *
 * @param weapon_name        Name of the weapon.
 * @return                   Weapon index number on success or -1 if name not found.
 */ 
native DrugShop_GetWeaponID(const String:weapon_name[]);

/**
 * Gets the number of drugs required to be traded for a pistol.
 *
 * @return                   Number of drugs_per_pitol required to be traded for a pistol.
 */ 
native DrugShop_GetDrugsPerPistol();

/**
 * Gets the cost per drug.
 *
 * @return                   Cost of each drug purchase.
 */ 
native DrugShop_GetCostPerDrug();

/**
 * Sets the number of drugs required to be traded for a pistol.
 *
 * @param num_drugs          Amount of drugs required to trade for a pistol. (must be > 0)
 * @return                   True on success.
 */ 
native DrugShop_SetDrugsPerPistol(num_drugs);

/**
 * Sets the cost per drug.
 *
 * @param cost               Cost per drug. (must be > 0)
 * @return                   True on success.
 */ 
native DrugShop_SetCostPerDrug(cost);

/**
 * Sets the name of a drug for a specified index.
 *
 * @param drug_name          Name of the drug.
 * @param drug               Drug index between 0 & 4.
 * @return                   true on success.
 */ 
native DrugShop_SetDrugName(const String:drug_name[], drug);

/**
 * Sets the name of a weapon for a specified index.
 *
 * @param weapon_name        Name of the weapon.
 * @param weapon             Weapon index between 0 & 4.
 * @return                   True on success.
 */ 
native DrugShop_SetWeaponName(const String:weapon_name[], weapon);

/**
 * Sets the number of a given drug for a user.
 *
 * @param auth               Steam ID of the user to modify.
 * @param drug               Drug index between 0 & 4.
 * @param num_drugs          Number of drugs to set.
 * @return                   True on success.
 */ 
native DrugShop_SetNumDrugs(const String:auth[], drugnum_drugs);

/**
 * Gets the number of a given drug for a user.
 *
 * @param auth               Steam ID of the user to modify.
 * @param drug               Drug index between 0 & 4.
 * @return                   Number of Drugs.
 */ 
native DrugShop_GetNumDrugs(const String:auth[], drug);

/**
 * Checks if a given steam ID is in the database
 *
 * @param auth               Steam ID of the user to modify.
 * @return                   True if exists else False.
 */ 
native bool:DrugShop_CheckUserExists(const String:auth[]);

/**
 * Insert new user into the datbase
 *
 * @param auth               Steam ID of the user to modify.
 * @noreturn                   
 */ 
native DrugShop_AddNewUser(const String:auth[]); 
/* Changelog */
PHP Code:
v1.0.5 Added ds_confiscate addon
v1.0.4 Added even more natives
v1.0.3 Added translations 
and fixed some formatting
v1.0.2 Added Forwards
v1.0.1 Added a heap of Natives 
test code
v1.0.0 Initial Release 
/* To Do */
PHP Code:
No features requested :( 
Attached Files
File Type: smx drugshop.smx (17.9 KB, 458 views)
File Type: sp Get Plugin or Get Source (drugshop.sp - 398 views - 21.2 KB)
File Type: txt drugshop.phrases.txt (735 Bytes, 517 views)
File Type: smx ds_confiscate.smx (12.9 KB, 471 views)
File Type: sp Get Plugin or Get Source (ds_confiscate.sp - 360 views - 5.4 KB)
File Type: inc drugshop.inc (6.0 KB, 436 views)

Last edited by Jasonbourne; 01-29-2015 at 00:18.
Jasonbourne is offline