AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   OciXCrom's Custom Shop + API (https://forums.alliedmods.net/showthread.php?t=284603)

OciXCrom 06-29-2016 15:52

OciXCrom's Custom Shop + API
 
3 Attachment(s)

Description
  • This plugin adds a unique shop in the game that contains a variety of different settings which makes it highly customizable. The shop has got a special points system that can be activated through the configuration file. It also has an API which allows you to easily add more items, as well as remove some of the default ones.

Installation
  • Bear in mind that the plugin consists of two different files that need to be added in the plugins list.
  • The files custom_shop.amxx and cshop_items.amxx go in the plugins folder. The first one is the main plugin, i.e. the shop can't work without it. The second one contains all the default shop items, so you can decide not to add it if you plan to add your own custom items.
  • The files custom_shop.sma and cshop_items.sma go in the scripting folder. It is highly recommended to compile them locally and replace them with the new .amxx files.
  • The file customshop.inc goes in scripting/include. This is the plugin's API. There you can find all of the functions that are used to create sub-plugins.
  • The file cshop_settings.inc goes in scripting/include.
  • In configs/plugins.ini you need to add only custom_shop.amxx.
  • In configs/plugins-cshop.ini you need to add cshop_items.amxx. All sub-plugins go in that file. You can add them in configs/plugins.ini as well, but they must be placed underneath custom_shop.amxx.

Default items
  • This is a list of all items that are added in the shop by default. Names, prices, limits and everything else can be changed by editing CustomShopItems.ini, which is automatically created in your configs folder after restarting the server with the plugin added. Items can also be changed directly from the server by using the command
  • cshop_edit.
  • +50 Health -- Gives +50 HP.
    • Price: 1500
    • Limit: 5
  • +100 Armor -- Gives +100 AP.
    • Price: 1000
    • Limit: 8
  • Unlimited Clip -- Unlimited bullets for your curent weapon (no reload). This item cannot be activated on a weapon that doesn't use bullets.
    • Price: 3000
    • Limit: 3
  • Unlimited Ammo -- Unlimited backpack ammo for your current weapon. This item cannot be activated on a weapon that doesn't use bullets.
    • Price: 200
    • Limit: 5
  • Bomber -- Gives +20 HE grenades.
    • Price: 1600
    • Limit: 3
  • Silent Footsteps -- You won't make any sounds when walking.
    • Price: 3000
    • Limit: 1
  • Faster Speed -- Increases your speed.
    • Price: 4300
    • Limit: 1
  • Low Gravity -- Allows you to jump higher.
    • Price: 2800
    • Limit: 1
  • Chameleon -- You get a random skin from the enemy team.
    • Price: 9000
    • Limit: 1
  • Drugs (Speed + Health) -- Distorts your screen, increases your speed and adds additional health.
    • Price: 8000
    • Limit: 2
  • Transparency -- Makes you transparent.
    • Price: 2500
    • Limit: 1
  • Invisibility (15 Seconds) -- You become fully invisible for 15 seconds.
    • Price: 16000
    • Limit: 1
  • Double Damage -- Doubles the damage you make.
    • Price: 10000
    • Limit: 1
  • Godmode (5 Seconds) -- You become immortal for 5 seconds.
    • Price: 16000
    • Limit: 1
  • Health Regeneration -- You get +1 HP each second.
    • Price: 1800
    • Limit: 1
  • Armor Regeneration -- You get +10 AP each second.
    • Price: 2000
    • Limit: 1

Admin commands
  • cshop_points <nick|#userid> <amount> -- Gives/Takes points to/from the player.
  • cshop_items -- A list of all registered items.
  • cshop_edit -- Opens the In-Game Shop Editor.
  • cshop_reset_points -- Resets everyone's points.

Settings
  • The settings can be changed in the file configs/CustomShop.ini, and the messages in data/lang/CustomShop.txt.
  • CSHOP_PREFIX -- Prefix for chat messages.
    • DEFAULT: !n[!tCustom Shop!n]
  • CSHOP_TITLE -- Menu title..
    • DEFAULT: \yOciXCrom's \rCustom Shop
  • CSHOP_TITLE_PAGE -- The text that will be added to the title if the menu has more than one page.
    • DEFAULT: \d| \w%page%:\d
  • CSHOP_TEAM_NAMES -- Team names when using %team% in the title.
    • DEFAULT: Unassigned, Terrorist, Counter-Terrorist, Spectator
  • CSHOP_SOUND_ERROR -- Error sound.
    • DEFAULT: buttons/button11.wav
  • CSHOP_SOUND_EXPIRE -- The sound when an item expires.
    • DEFAULT: buttons/blip2.wav
  • CSHOP_SOUND_OPEN -- The sound when you open the shop.
    • DEFAULT:
  • CSHOP_BUYSOUND_TYPE -- 0 = everyone around the player hears the sound when you buy an item; 1 = only the player hears it
    • DEFAULT: 0
  • CSHOP_EXPIRESOUND_TYPE -- 0 = everyone around the player hears the sound when an item expires; 1 = only the player hears it
    • DEFAULT: 0
  • CSHOP_OPENSOUND_TYPE -- 0 = everyone around the player hears the sound when the shop is opened; 1 = only the player hears it
    • DEFAULT: 1
  • CSHOP_COMMANDS -- Commands that open the shop.
    • DEFAULT: say /shop , say_team /shop , customshop
  • CSHOP_PREVPAGE -- Previous page field.
    • DEFAULT: Previous page
  • CSHOP_NEXTPAGE -- Next page field.
    • DEFAULT: Next page
  • CSHOP_EXITMENU -- Exit menu field.
    • DEFAULT: \rClose
  • CSHOP_PERPAGE -- Number of items on each page.
    • DEFAULT: 7
  • CSHOP_FLAG -- If you want the shop to be available for players with a certain flag only.
    • DEFAULT: !
  • CSHOP_TEAM -- If you want the shop to be available for a certain team only.
    • DEFAULT: 0
  • CSHOP_SHOW_TEAMED -- Controls whether items that aren't meant for your team will be displayed in the menu.
    • DEFAULT: 0
  • CSHOP_ITEM_TEAMED -- Text for items that aren't meant for your team.
    • DEFAULT: \r[\yTEAMED\r]
  • CSHOP_SHOW_FLAGGED -- Controls whether items that you don't have access to will be displayed in the menu.
    • DEFAULT: 0
  • CSHOP_ITEM_FLAGGED -- Text for items that you don't have access to.
    • DEFAULT: \r[\yFLAGGED\r]
  • CSHOP_LIMIT_TYPE -- How is the item limit going to work (0 = every players has his own limit; 1 = every team has his own limit; 2 = limit is the same for all players).
    • DEFAULT: 0
  • CSHOP_HIDE_LIMITED -- If you want to hide items that have reached their limit.
    • DEFAULT: 0
  • CSHOP_OPEN_AT_SPAWN -- If you want the shop to be displayed on spawn.
    • DEFAULT: 0
  • CSHOP_REOPEN_AFTER_USE -- Whether the shop will stay open after purchasing an item.
    • DEFAULT: 0
  • CSHOP_POINTS_ENABLE -- Enables/Disables the points system.
    • DEFAULT: 0
  • CSHOP_MONEY_NAME -- Money name.
    • DEFAULT: money
  • CSHOP_POINTS_NAME -- Points name.
    • DEFAULT: points
  • CSHOP_MONEY_CURRENCY -- Money currency.
    • DEFAULT: $
  • CSHOP_POINTS_CURRENCY -- Points currency.
    • DEFAULT: Pts.
  • CSHOP_POINTS_SAVE -- Save points? (1 = yes; 0 = no)
    • DEFAULT: 1
  • CSHOP_SAVE_TYPE -- How to save the points (0 = name; 1 = IP address; 2= SteamID)
    • DEFAULT: 0
  • CSHOP_POINTS_COMMANDS -- Commands that allow you to see how many points you have.
    • DEFAULT: say /points , say_team /points
  • CSHOP_REWARD_NORMAL -- Reward for a normal kill.
    • DEFAULT: 15
  • CSHOP_REWARD_HEADSHOT -- Reward for a headshot kill.
    • DEFAULT: 30
  • CSHOP_REWARD_KNIFE -- Reward for a knife kill.
    • DEFAULT: 50
  • CSHOP_REWARD_VIP -- If you want VIP users to get additional points for each kill
    • DEFAULT: 0
  • CSHOP_VIP_FLAG -- VIP flag for the setting above.
    • DEFAULT: b
  • CSHOP_POINTS_TEAMKILL -- Controls whether you get points for killing teammates.
    • DEFAULT: 0
  • CSHOP_KILL_MESSAGE -- Enables/Disables the message when you kill a player.
    • DEFAULT: 0
  • CSHOP_HUD_ENABLED -- Enables/Disables points being displayed on the HUD.
    • DEFAULT: 0
  • CSHOP_HUD_RED -- Red color amount for the HUD message.
    • DEFAULT: 255
  • CSHOP_HUD_GREEN -- Green color amount for the HUD message.
    • DEFAULT: 255
  • CSHOP_HUD_BLUE -- Blue color amount for the HUD message.
    • DEFAULT: 0
  • CSHOP_HUD_X -- X position for the HUD message.
    • DEFAULT: 0.01
  • CSHOP_HUD_Y -- Y position for the HUD message.
    • DEFAULT: 0.93

Using a currency from another plugin/mod
  • The plugin has the ability to use another plugin's natives instead of default money. In simple terms - you can make the shop work with Ammo Packs, BaseBuilder Credits, JBPacks etc. To achieve that, you need to edit the following lines in the file cshop_settings.inc:

    PHP Code:

    #define get_user_money(%1) cs_get_user_money(%1)
    #define set_user_money(%1,%2) cs_set_user_money(%1, %2) 

  • To make it use Ammo Packs, replace the lines with these:

    PHP Code:

    #define get_user_money(%1) zp_get_user_ammo_packs(%1)
    #define set_user_money(%1,%2) zp_set_user_ammo_packs(%1, %2) 

  • Also, add the natives that you used in both lines:

    PHP Code:

    native zp_get_user_ammo_packs(id)
    native zp_set_user_ammo_packs(idamount

  • Or:

    PHP Code:

    #include <zombieplague> 


Plugin API (customshop.inc)
  • The plugin also has an API, i.e. a library (.inc file), which allows you to make sub-plugins that will add additional items in the shop and many other things. Here's an example of a plugin that adds No Recoil in the shop (removes recoil when shooting).

    PHP Code:

    #include <amxmodx>
    #include <customshop>
    #include <fakemeta>

    #define PLUGIN_VERSION "4.x"

    additem ITEM_NORECOIL
    new bool:g_bNoRecoil[33]

    public 
    plugin_init()
    {
        
    register_plugin("CSHOP: No Recoil"PLUGIN_VERSION"OciXCrom")
        
    register_forward(FM_PlayerPreThink"PreThink")
    }

    public 
    plugin_precache()
        
    ITEM_NORECOIL cshop_register_item("norecoil""No Recoil"120001)

    public 
    cshopItemBought(idiItem)
    {
        if(
    iItem == ITEM_NORECOIL)
            
    g_bNoRecoil[id] = true
    }
        
    public 
    cshopItemRemoved(idiItem)
    {
        if(
    iItem == ITEM_NORECOIL)
            
    g_bNoRecoil[id] = false
    }
        
    public 
    PreThink(id)
    {
        if(
    is_user_alive(id) && g_bNoRecoil[id])
            
    set_pev(idpev_punchangle, {0.00.00.0}) 



Video preview (of an older version)



Translations
  • English: by me (OciXCrom)
  • Macedonian: by me (OciXCrom)
  • Bulgarian: by me (OciXCrom)
  • Spanish: by ACM1PT
  • Hungarian: by vAx
  • Slovakian: by Belo95135
  • Brazilian Portuguese: by addons_zz
  • Romanian: by Craxor
  • Ukrainian: by Leo_BH
  • Russian: by Leo_BH

https://raw.githubusercontent.com/Oc...using_this.png
https://raw.githubusercontent.com/Oc...plugin_lab.png
https://raw.githubusercontent.com/Oc...ad_default.png

OciXCrom 06-29-2016 15:52

Custom Shop Sub-Plugins
 
3 Attachment(s)
Custom Shop Addon: No Recoil

Description
  • This plugin adds No Recoil in the Custom Shop.

Installation
  • Bear in mind that this plugin won't work without the base plugin for Custom Shop (custom_shop.amxx).
  • The file cshop_norecoil.amxx goes in the plugins folder.
  • The file cshop_norecoil.sma goes in the scripting folder.
  • In configs/plugins-cshop.ini you add cshop_norecoil.amxx.

Default settings
  • The settings require editing the file cshop_norecoil.sma.

    PHP Code:

    #define NORECOIL_NAME "No Recoil"
    #define NORECOIL_PRICE 12000
    #define NORECOIL_LIMIT 1 



Description
  • This plugin adds a Golden AK47 in the Custom Shop. It has a golden model, modified damage and golden bullets.

Installation
  • Bear in mind that this plugin won't work without the base plugin for Custom Shop (custom_shop.amxx).
  • The file cshop_goldenak.amxx goes in the plugins folder.
  • The file cshop_goldenak.sma goes in the scripting folder.
  • The files v_goldenak.mdl and p_goldenak.mdl go in the models/custom_shop folder.
  • In configs/plugins-cshop.ini you add cshop_goldenak.amxx.

Default settings
  • The settings require editing the file cshop_goldenak.sma.

    PHP Code:

    additem ITEM_GOLDENAK
    #define GOLDENAK_NAME "Golden AK47"
    #define GOLDENAK_PRICE 16000
    #define GOLDENAK_LIMIT 1
    #define GOLDENAK_SOUND "weapons/gauss2.wav"
    #define GOLDENAK_VMODEL "models/custom_shop/v_goldenak.mdl"
    #define GOLDENAK_PMODEL "models/custom_shop/p_goldenak.mdl"
    #define GOLDENAK_WEAPON_STR "weapon_ak47"
    #define GOLDENAK_WEAPON_CSW CSW_AK47
    #define GOLDENAK_DAMAGE 5
    #define GOLDENAK_AMMO 500
    new bool:g_blGoldenAK[33]

    // Comment this line to disable the bullets.
    #define USE_BULLETS

    #if defined USE_BULLETS
        // You can add a shoot sound in this line, after you remove the comment.
        //#define BULLET_SOUND "weapons/ak47-1.wav"
        
        #define BULLET_MODEL "sprites/dot.spr"
        #define BULLET_STARTFRAME 1
        #define BULLET_FRAMERATE 5
        #define BULLET_LIFE 2
        #define BULLET_WIDTH 10
        #define BULLET_NOISE 0
        #define BULLET_COLOR_RED 255
        #define BULLET_COLOR_GREEN 215
        #define BULLET_COLOR_BLUE 0
        #define BULLET_BRIGHTNESS 200
        #define BULLET_SPEED 150
        
    new g_iGoldenBullet
    #endif

    #define DEFAULT_VMODEL "models/v_ak47.mdl"
    #define DEFAULT_PMODEL "models/p_ak47.mdl" 



Description
  • This plugin adds leap (longjump) in the Custom Shop. With this item you can perform long jumps.

Settings
  • The settings are automatically generated in configs/CustomShopItems.ini and they can also be changed in-game with the command cshop_edit.
    • Force: 550 -- how far you will jump
    • Minimum Speed: 80 -- the minimum speed that's required in order to jump
    • Height: 255.0 -- how high you will jump
    • Cooldown: 5.0 -- how many seconds before you can jump again

Mohammad Hlwani 06-29-2016 16:56

Re: OciXCrom's Custom Shop 3.3 + API
 
best ever

Mohammad Hlwani 06-29-2016 17:10

Re: OciXCrom's Custom Shop 3.3 + API
 
man no point system ?????????
i dont like this shop now :(

OciXCrom 06-29-2016 19:14

Re: OciXCrom's Custom Shop 3.3 + API
 
What are you talking about? Points are still here, of course. Read the description and take a look at the configuration file. You simply need to enable them. Literally every third sentence in the first comment contains the word "points".

zmd94 06-29-2016 20:49

Re: OciXCrom's Custom Shop 3.3 + API
 
Nice plugin.

Mohammad Hlwani 06-30-2016 10:43

Re: OciXCrom's Custom Shop 3.3 + API
 
man there on problem
when i active the point system the game didn't enter !!!
any solution ?

Napoleon_be 06-30-2016 10:44

Re: OciXCrom's Custom Shop 3.3 + API
 
What do you mean the game didn't enter?

MihailoZ 06-30-2016 14:43

Re: OciXCrom's Custom Shop 3.3 + API
 
This is the best shop plugin I've ever seen. I've god one question...Can I display something like "Shop Info" like, how many points do you have and so?

Mohammad Hlwani 06-30-2016 15:03

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by Napoleon_be (Post 2432237)
What do you mean the game didn't enter?


when i choose the map and click on start it didnt enter

OciXCrom 06-30-2016 18:41

Re: OciXCrom's Custom Shop 3.3 + API
 
@Mohammad - the plugin has been tested many times with different settings and it's working without any problems. If it "didn't enter", then you should check the logs for errors. It would also be nice to explain how you installed the plugin, because this one is a little more complicated.

@MihailoZ - what do you mean by "shop info"? You can use the command "/points" to check how many points you have. They also show up in the shop itself and you can even make it display them on HUD - see the settings.

Mohammad Hlwani 07-01-2016 09:06

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by OciXCrom (Post 2432057)
What are you talking about? Points are still here, of course. Read the description and take a look at the configuration file. You simply need to enable them. Literally every third sentence in the first comment contains the word "points".

not work !!
i make it 1
but when choose map and click start
it didnt enter the game
plaese help !!:wink:

OciXCrom 07-01-2016 09:25

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

It would also be nice to explain how you installed the plugin, because this one is a little more complicated.
Also, post the content of your .ini file here, please.

Mohammad Hlwani 07-01-2016 12:24

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by OciXCrom (Post 2432057)
What are you talking about? Points are still here, of course. Read the description and take a look at the configuration file. You simply need to enable them. Literally every third sentence in the first comment contains the word "points".

thx it work now

the problem was from podbot

but i want to ask u something

how to give points ?
i tried to give with amx_points but not work :| :(
please help fast :/

Mohammad Hlwani 07-01-2016 12:26

Re: OciXCrom's Custom Shop 3.3 + API
 
oh sorry i dont read the title i know now thx you but amx is better than cshop

OciXCrom 07-01-2016 13:05

Re: OciXCrom's Custom Shop 3.3 + API
 
It's cshop for a reason. Some other plugin may as well use a command like amx_points because it's too common.

OciXCrom 07-04-2016 13:36

Re: OciXCrom's Custom Shop 3.3 + API
 
Added Golden AK47 and No Recoil sub-plugins in the second post.

Mohammad Hlwani 07-04-2016 14:13

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by OciXCrom (Post 2433416)
Added Golden AK47 and No Recoil sub-plugins in the second post.

man maybe i have an problem please help me when i enter the server "Bad entity in IndexOfEdict()"

please help me when i remove your plugin it enter normal

please help

OciXCrom 07-04-2016 14:23

Re: OciXCrom's Custom Shop 3.3 + API
 
Man please, please and please give more information about your problem and explain how you're installing the plugin. Also - WHICH plugin, there are two different ones in the quote.

Mohammad Hlwani 07-04-2016 19:17

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by OciXCrom (Post 2433435)
Man please, please and please give more information about your problem and explain how you're installing the plugin. Also - WHICH plugin, there are two different ones in the quote.

i install the plugin normal like any plugin install all are in his place configs, plugins, sma.....etc

and the game start normal

i go to the config file to active points system and edit how every thing spend

and when i save the file i open the game than the problem are start

i dont know if any other plugin are make it like that

but i dont think so

you can see the problem download the mode and u can see when you active the plugin it dont enter :

https://www.youtube.com/watch?v=pU5N4YMuCsM

please reply after test :wink::wink::wink:

OciXCrom 07-04-2016 20:42

Re: OciXCrom's Custom Shop 3.3 + API
 
Few days ago you said that you fixed the problem and now you are saying the opposite? Why did you post a video tutorial on how to install basebuilder? I can't help you unless you start speaking the same language as me. Please stop spamming my topic with comments that lead nowhere.

Mohammad Hlwani 07-05-2016 09:24

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by OciXCrom (Post 2433547)
Few days ago you said that you fixed the problem and now you are saying the opposite? Why did you post a video tutorial on how to install basebuilder? I can't help you unless you start speaking the same language as me. Please stop spamming my topic with comments that lead nowhere.

you mean you dont want to help me ? :cry:

Napoleon_be 07-05-2016 09:43

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by Mohammad Hlwani (Post 2433719)
you mean you dont want to help me ? :cry:

He does, just explain to him what he asks for nothing else.

Mohammad Hlwani 07-09-2016 11:39

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by Napoleon_be (Post 2433726)
He does, just explain to him what he asks for nothing else.

i told him man this is the problem
http://fbcdn-sphotos-a-a.akamaihd.ne...c4d76b9fd01d6c
when i enter the game before choose team the game be normal when i enter an team the game turn off than give me this error

please if you know help me plz :cry::cry::cry::cry::cry:

Napoleon_be 07-09-2016 11:40

Re: OciXCrom's Custom Shop 3.3 + API
 
You get thisproblem only when this plugin is enabled?

Mohammad Hlwani 07-09-2016 12:45

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by Napoleon_be (Post 2435170)
You get thisproblem only when this plugin is enabled?

yes only

OciXCrom 07-09-2016 14:31

Re: OciXCrom's Custom Shop 3.3 + API
 
PodBot is causing this problem and I don't know what I should do to prevent that. Some part of the plugin needs to be stopped for bots, but I don't know which. However, try it with this code and let me know if it changed something:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cshop_settings>
#include <fun>
#include <hamsandwich>
#include <nvault>

#define PLUGIN_VERSION "3.3"
#define TASK_HUDBAR 388838

#define mtop(%1) floatround(float(%1) / 10.0, floatround_floor)

enum _:Items
{
    
iName[64],
    
iPrice,
    
iLimit,
    
iSound[128],
    
Float:iSeconds,
    
iTeam,
    
iFlag[2]
}

enum _:Settings
{
    
stgPrefix[32],
    
stgTitle[128],
    
stgTitlePage[128],
    
stgSoundError[128],
    
stgSoundExpire[128],
    
stgSoundOpen[128],
    
stgBuySoundType,
    
stgExpireSoundType,
    
stgOpenSoundType,
    
stgPrevPage[32],
    
stgNextPage[32],
    
stgMenuExit[32],
    
stgPerPage,
    
stgFlag[2],
    
stgTeam,
    
stgPointsEnable,
    
stgMoneyName[32],
    
stgMoneyNameUC[32],
    
stgCurrency[16],
    
stgSavePoints,
    
stgSaveType,
    
stgShowTeamed,
    
stgItemTeamed[32],
    
stgShowFlagged,
    
stgItemFlagged[32],
    
stgLimitType,
    
stgHideLimited,
    
stgOpenAtSpawn,
    
stgRewardNormal,
    
stgRewardHeadshot,
    
stgRewardKnife,
    
stgRewardVip,
    
stgVipFlag[2],
    
stgTeamKill,
    
stgKillMessage,
    
stgHudEnable,
    
stgHudRed,
    
stgHudGreen,
    
stgHudBlue,
    
Float:stgHudX,
    
Float:stgHudY
}

enum _:Fields
{
    
FIELD_TEAM,
    
FIELD_MONEY,
    
FIELD_CURRENCY,
    
FIELD_NEWLINE,
    
FIELD_PAGE
}

new const 
g_szVaults[][] = { "CustomShop""CustomShopIP""CustomShopSI" }
new const 
g_szColorReplace[][] = { "!g""^4""!t""^3""!n""^1" }
new const 
g_szHideChat[][] = { "\r""\y""\w""\d""\R" }

new Array:
g_aItems
new g_eSettings[Settings]
new 
g_szFields[Fields][16] = { "%team%""%money%""%currency%""%newline%""%page%" }

new Array:
g_aSounds
new g_iTotalItems
new g_msgSayText
new g_iLimit[33][MAX_ITEMS]
new 
g_iItemTeamLimit[4][MAX_ITEMS]
new 
g_iItemLimit[MAX_ITEMS]
new 
bool:g_blHasItem[33][MAX_ITEMS]
new 
g_szItems[MAX_ITEMS][192]
new 
g_szItemsLoaded[192]
new 
g_szTeams[4][32]
new 
g_szInfo[33][35]
new 
g_iPoints[33]
new 
g_fwdSelectItem
new g_fwdRemoveItem
new g_iVault
new g_iHUD

public plugin_init()
{
    
register_plugin("Custom Shop"PLUGIN_VERSION"OciXCrom")
    
register_cvar("CustomShop"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
register_dictionary("CustomShop.txt")
    
register_logevent("eventRoundStart"2"0=World triggered""1=Round_Start")
    
RegisterHam(Ham_Spawn"player""eventPlayerSpawn"1)
    
register_event("DeathMsg""eventPlayerKilled""a")
    
register_concmd("cshop_points""cmdGivePoints"FLAG_ADMIN"<nick|#userid> <points to give/take>")
    
register_concmd("cshop_items""cmdListItems"FLAG_ADMIN"-- lists all loaded items")
    
g_fwdSelectItem CreateMultiForward("cshopItemBought"ET_STOPFP_CELLFP_CELL)
    
g_fwdRemoveItem CreateMultiForward("cshopItemRemoved"ET_IGNOREFP_CELLFP_CELL)
    
g_msgSayText get_user_msgid("SayText")
    
g_iVault nvault_open(g_szVaults[g_eSettings[stgSaveType]])
    
g_iHUD CreateHudSyncObj()
    
formStuff()
}

formStuff()
{
    new 
szTemp[128], eItem[Items]
    
    for(new 
ig_iTotalItemsi++)
    {
        
ArrayGetArray(g_aItemsieItem)
        
formatex(g_szItems[i], charsmax(g_szItems[]), "#%i: %s [%L: %i%s"1eItem[iName], LANG_TYPE"CSHOP_PRICE"eItem[iPrice], g_eSettings[stgCurrency])
        
        if(
eItem[iLimit])
            
format(g_szItems[i], charsmax(g_szItems[]), "%s | %L: %i"g_szItems[i], LANG_TYPE"CSHOP_LIMIT"eItem[iLimit])
            
        if(
eItem[iSeconds])
            
format(g_szItems[i], charsmax(g_szItems[]), "%s | %L: %.1f"g_szItems[i], LANG_TYPE"CSHOP_TIME"eItem[iSeconds])
            
        if(
eItem[iTeam])
            
format(g_szItems[i], charsmax(g_szItems[]), "%s | %L: %i"g_szItems[i], LANG_TYPE"CSHOP_TEAM"eItem[iTeam])
            
        if(
eItem[iFlag])
            
format(g_szItems[i], charsmax(g_szItems[]), "%s | %L: %s"g_szItems[i], LANG_TYPE"CSHOP_FLAG"eItem[iFlag])
            
        
add(g_szItems[i], charsmax(g_szItems[]), " ]")
    }
    
    
formatex(g_szItemsLoadedcharsmax(g_szItemsLoaded), "%L"LANG_TYPE"CSHOP_ITEMS_LOADED"g_iTotalItems)
    
    if(
contain(g_eSettings[stgTitle], g_szFields[FIELD_CURRENCY]) != -1)
        
replace_all(g_eSettings[stgTitle], charsmax(g_eSettings[stgTitle]), g_szFields[FIELD_CURRENCY], g_eSettings[stgMoneyNameUC])
        
    if(
contain(g_eSettings[stgTitle], g_szFields[FIELD_NEWLINE]) != -1)
        
replace_all(g_eSettings[stgTitle], charsmax(g_eSettings[stgTitle]), g_szFields[FIELD_NEWLINE], "^n")
    
    if(
contain(g_eSettings[stgTitlePage], g_szFields[FIELD_NEWLINE]) != -1)
        
replace_all(g_eSettings[stgTitlePage], charsmax(g_eSettings[stgTitlePage]), g_szFields[FIELD_NEWLINE], "^n")
        
    if(
contain(g_eSettings[stgTitlePage], g_szFields[FIELD_PAGE]) != -1)
    {
        
formatex(szTempcharsmax(szTemp), "%L"LANG_TYPE"CSHOP_PAGE")
        
replace_all(g_eSettings[stgTitlePage], charsmax(g_eSettings[stgTitlePage]), g_szFields[FIELD_PAGE], szTemp)
    }
}

public 
plugin_precache()
{
    
g_aItems ArrayCreate(Items)
    
g_aSounds ArrayCreate(1281)
    
fileRead()
}

public 
plugin_end()
{
    
ArrayDestroy(g_aItems)
    
ArrayDestroy(g_aSounds)
}

fileRead()
{
    new 
szConfigsName[256], szFilename[256]
    
get_configsdir(szConfigsNamecharsmax(szConfigsName))
    
formatex(szFilenamecharsmax(szFilename), "%s/CustomShop.ini"szConfigsName)
    new 
iFilePointer fopen(szFilename"rt")
    
    if(
iFilePointer)
    {
        new 
szData[160], szKey[32], szValue[128]
        
        while(!
feof(iFilePointer))
        {
            
fgets(iFilePointerszDatacharsmax(szData))
            
trim(szData)
            
            switch(
szData[0])
            {
                case 
EOS';': continue
                default:
                {
                    
strtok(szDataszKeycharsmax(szKey), szValuecharsmax(szValue), '=')
                    
trim(szKey); trim(szValue)
                    
                    if(
is_blank(szValue))
                        continue
                    
                    if(
equal(szKey"CSHOP_PREFIX"))
                        
copy(g_eSettings[stgPrefix], charsmax(g_eSettings[stgPrefix]), szValue)
                    else if(
equal(szKey"CSHOP_TITLE"))
                        
copy(g_eSettings[stgTitle], charsmax(g_eSettings[stgTitle]), szValue)
                    else if(
equal(szKey"CSHOP_TITLE_PAGE"))
                        
copy(g_eSettings[stgTitlePage], charsmax(g_eSettings[stgTitlePage]), szValue)
                    else if(
equal(szKey"CSHOP_TEAM_NAMES"))
                    {
                        for(new 
i4i++)
                        {
                            
strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ',')
                            
trim(szKey); trim(szValue)
                            
copy(g_szTeams[i], charsmax(g_szTeams[]), szKey)
                        }
                    }
                    else if(
equal(szKey"CSHOP_SOUND_ERROR"))
                    {
                        
copy(g_eSettings[stgSoundError], charsmax(g_eSettings[stgSoundError]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"CSHOP_SOUND_EXPIRE"))
                    {
                        
copy(g_eSettings[stgSoundExpire], charsmax(g_eSettings[stgSoundExpire]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"CSHOP_SOUND_OPEN"))
                    {
                        
copy(g_eSettings[stgSoundOpen], charsmax(g_eSettings[stgSoundOpen]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"CSHOP_BUYSOUND_TYPE"))
                        
g_eSettings[stgBuySoundType] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_EXPIRESOUND_TYPE"))
                        
g_eSettings[stgExpireSoundType] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_OPENSOUND_TYPE"))
                        
g_eSettings[stgOpenSoundType] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_PREVPAGE"))
                        
copy(g_eSettings[stgPrevPage], charsmax(g_eSettings[stgPrevPage]), szValue)
                    else if(
equal(szKey"CSHOP_NEXTPAGE"))
                        
copy(g_eSettings[stgNextPage], charsmax(g_eSettings[stgNextPage]), szValue)
                    else if(
equal(szKey"CSHOP_EXITMENU"))
                        
copy(g_eSettings[stgMenuExit], charsmax(g_eSettings[stgMenuExit]), szValue)
                    else if(
equal(szKey"CSHOP_PERPAGE"))
                        
g_eSettings[stgPerPage] = clamp(str_to_num(szValue), 07)
                    else if(
equal(szKey"CSHOP_COMMANDS"))
                    {
                        while(
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                        {
                            
trim(szKey); trim(szValue)
                            
register_clcmd(szKey"menuShop")
                        }
                    }
                    else if(
equal(szKey"CSHOP_FLAG"))
                        
copy(g_eSettings[stgFlag], charsmax(g_eSettings[stgFlag]), szValue)
                    else if(
equal(szKey"CSHOP_TEAM"))
                        
g_eSettings[stgTeam] = clamp(str_to_num(szValue), 03)
                    else if(
equal(szKey"CSHOP_POINTS_ENABLE"))
                        
g_eSettings[stgPointsEnable] = clamp(str_to_num(szValue), 01)
                    else if((
g_eSettings[stgPointsEnable] && equal(szKey"CSHOP_POINTS_NAME")) || (!g_eSettings[stgPointsEnable] && equal(szKey"CSHOP_MONEY_NAME")))
                    {
                        
copy(g_eSettings[stgMoneyName], charsmax(g_eSettings[stgMoneyName]), szValue)
                        
copy(g_eSettings[stgMoneyNameUC], charsmax(g_eSettings[stgMoneyNameUC]), szValue)
                        
ucfirst(g_eSettings[stgMoneyNameUC])
                    }
                    else if((
g_eSettings[stgPointsEnable] && equal(szKey"CSHOP_POINTS_CURRENCY")) || (!g_eSettings[stgPointsEnable] && equal(szKey"CSHOP_MONEY_CURRENCY")))
                        
copy(g_eSettings[stgCurrency], charsmax(g_eSettings[stgCurrency]), szValue)
                    else if(
equal(szKey"CSHOP_POINTS_SAVE"))
                        
g_eSettings[stgSavePoints] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_SAVE_TYPE"))
                        
g_eSettings[stgSaveType] = clamp(str_to_num(szValue), 02)
                    else if(
equal(szKey"CSHOP_POINTS_COMMANDS"))
                    {
                        while(
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                        {
                            
trim(szKey); trim(szValue)
                            
register_clcmd(szKey"cmdPoints")
                        }
                    }
                    else if(
equal(szKey"CSHOP_SHOW_TEAMED"))
                        
g_eSettings[stgShowTeamed] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_ITEM_TEAMED"))
                        
copy(g_eSettings[stgItemTeamed], charsmax(g_eSettings[stgItemTeamed]), szValue)
                    else if(
equal(szKey"CSHOP_SHOW_FLAGGED"))
                        
g_eSettings[stgShowFlagged] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_ITEM_FLAGGED"))
                        
copy(g_eSettings[stgItemFlagged], charsmax(g_eSettings[stgItemFlagged]), szValue)
                    else if(
equal(szKey"CSHOP_LIMIT_TYPE"))
                        
g_eSettings[stgLimitType] = clamp(str_to_num(szValue), 02)
                    else if(
equal(szKey"CSHOP_HIDE_LIMITED"))
                        
g_eSettings[stgHideLimited] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_OPEN_AT_SPAWN"))
                        
g_eSettings[stgOpenAtSpawn] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_REWARD_NORMAL"))
                        
g_eSettings[stgRewardNormal] = str_to_num(szValue)
                    else if(
equal(szKey"CSHOP_REWARD_HEADSHOT"))
                        
g_eSettings[stgRewardHeadshot] = str_to_num(szValue)
                    else if(
equal(szKey"CSHOP_REWARD_KNIFE"))
                        
g_eSettings[stgRewardKnife] = str_to_num(szValue)
                    else if(
equal(szKey"CSHOP_REWARD_VIP"))
                        
g_eSettings[stgRewardVip] = str_to_num(szValue)
                    else if(
equal(szKey"CSHOP_VIP_FLAG"))
                        
copy(g_eSettings[stgVipFlag], charsmax(g_eSettings[stgVipFlag]), szValue)
                    else if(
equal(szKey"CSHOP_POINTS_TEAMKILL"))
                        
g_eSettings[stgTeamKill] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_KILL_MESSAGE"))
                        
g_eSettings[stgKillMessage] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_HUD_ENABLED"))
                        
g_eSettings[stgHudEnable] = clamp(str_to_num(szValue), 01)
                    else if(
equal(szKey"CSHOP_HUD_RED"))
                        
g_eSettings[stgHudRed] = clamp(str_to_num(szValue), 0255)
                    else if(
equal(szKey"CSHOP_HUD_GREEN"))
                        
g_eSettings[stgHudGreen] = clamp(str_to_num(szValue), 0255)
                    else if(
equal(szKey"CSHOP_HUD_BLUE"))
                        
g_eSettings[stgHudBlue] = clamp(str_to_num(szValue), 0255)
                    else if(
equal(szKey"CSHOP_HUD_X"))
                        
g_eSettings[stgHudX] = _:floatclamp(str_to_float(szValue), -1.01.0)
                    else if(
equal(szKey"CSHOP_HUD_Y"))
                        
g_eSettings[stgHudY] = _:floatclamp(str_to_float(szValue), -1.01.0)
                }
            }    
        }
        
        
fclose(iFilePointer)
    }
}

public 
client_disconnect(id)
    
nvault_read(id0g_szInfo[id])
        
public 
client_putinserver(id)
{
    
g_iPoints[id] = 0
    
    
switch(g_eSettings[stgSaveType])
    {
        case 
0get_user_name(idg_szInfo[id], charsmax(g_szInfo[]))
        case 
1get_user_ip(idg_szInfo[id], charsmax(g_szInfo[]), 1)
        case 
2get_user_authid(idg_szInfo[id], charsmax(g_szInfo[]))
    }
    
    
nvault_read(id1g_szInfo[id])
    
    if(
g_eSettings[stgPointsEnable] && g_eSettings[stgHudEnable])
        
set_task(1.0"showHUD"id TASK_HUDBAR__"b")
        
    
arrayset(g_iLimit[id], 0sizeof(g_iLimit[]))
    
arrayset(g_blHasItem[id], falsesizeof(g_blHasItem[]))
}

public 
client_infochanged(id)
{
    if(
g_eSettings[stgSaveType])
        return
        
    new 
szNewName[32], szOldName[32]
    
get_user_info(id"name"szNewNamecharsmax(szNewName))
    
get_user_name(idszOldNamecharsmax(szOldName))
    
    if(!
equal(szNewNameszOldName))
    {
        
nvault_read(id0szOldName)
        
nvault_read(id1szNewName)
    }
}

nvault_read(idiTypeszInfo[])
{
    if(!
g_eSettings[stgSavePoints] || is_user_bot(id))
        return
        
    new 
szPoints[20]
    
    switch(
iType)
    {
        case 
0:
        {
            
num_to_str(g_iPoints[id], szPointscharsmax(szPoints))
            
nvault_set(g_iVaultszInfoszPoints)
        }
        case 
1:
        {
            
nvault_get(g_iVaultszInfoszPointscharsmax(szPoints))
            
g_iPoints[id] = str_to_num(szPoints)
        }
    }
}

public 
showHUD(id)
{
    
id -= TASK_HUDBAR
    
    
if(!is_user_connected(id))
    {
        
remove_task(id TASK_HUDBAR)
        return
    }
    
    
set_hudmessage(g_eSettings[stgHudRed], g_eSettings[stgHudGreen], g_eSettings[stgHudBlue], g_eSettings[stgHudX], g_eSettings[stgHudY], 01.01.5)
    
ShowSyncHudMsg(idg_iHUD"%s: %i"g_eSettings[stgMoneyNameUC], g_iPoints[id])
}

public 
eventRoundStart()
{
    switch(
g_eSettings[stgLimitType])
    {
        case 
1:
        {
            for(new 
i4i++)
                
arrayset(g_iItemTeamLimit[i], 0sizeof(g_iItemTeamLimit[]))
        }
        case 
2:    arrayset(g_iItemLimit0sizeof(g_iItemLimit))
    }
}

public 
eventPlayerSpawn(id)
{
    if(!
g_eSettings[stgLimitType])
    {
        
arrayset(g_iLimit[id], 0sizeof(g_iLimit[]))
        
        for(new 
ig_iTotalItemsi++)
            if(
g_blHasItem[id][i])
                
removeItem(idi)
    }
    
    if(
g_eSettings[stgOpenAtSpawn])
        if(
has_access_flag(id))
            if(
has_access_team(id))
                if(
is_user_alive(id))
                    
menuShop(id)
}

public 
eventPlayerKilled()
{
    if(!
g_eSettings[stgPointsEnable])
        return
        
    new 
iAttacker read_data(1)
    new 
iVictim read_data(2)
    
    if(!
is_user_connected(iAttacker) || !is_user_connected(iVictim) || iAttacker == iVictim)
        return
    
    if(!
has_access_flag(iAttacker))
        return
        
    if(
get_user_team(iAttacker) == get_user_team(iVictim))
        if(!
g_eSettings[stgTeamKill])
            return
    
    new 
iReward
    
    iReward 
+= g_eSettings[stgRewardNormal]
    
    if(
read_data(3))
        
iReward += g_eSettings[stgRewardHeadshot]
    
    new 
szWeapon[16]
    
read_data(4szWeaponcharsmax(szWeapon))
    
    if(
equal(szWeapon"knife"))
        
iReward += g_eSettings[stgRewardKnife]
        
    if(
g_eSettings[stgRewardVip] && get_user_flags(iAttacker) & g_eSettings[stgVipFlag])
        
iReward += g_eSettings[stgRewardVip]
        
    
g_iPoints[iAttacker] += iReward
    
    
if(g_eSettings[stgKillMessage])
    {
        new 
szName[32]
        
get_user_name(iVictimszNamecharsmax(szName))
        
ColorChat(iAttacker"%L"iAttacker"CSHOP_KILL"iRewardg_eSettings[stgCurrency], szName)
    }
}

public 
cmdPoints(id)
{
    if(
g_eSettings[stgPointsEnable])
        
ColorChat(id"%L"id"CSHOP_POINTS"g_iPoints[id], g_eSettings[stgCurrency])
    else
        
ColorChat(id"%L"id"CSHOP_POINTS_DISABLED")
        
    return 
PLUGIN_HANDLED
}

public 
cmdGivePoints(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid3))
        return 
PLUGIN_HANDLED
        
    
if(!g_eSettings[stgPointsEnable])
    {
        
ColorChat(id"%L"id"CSHOP_POINTS_DISABLED")
        return 
PLUGIN_HANDLED
    
}

    new 
szPlayer[32]
    
read_argv(1szPlayercharsmax(szPlayer))
    
    new 
iPlayer cmd_target(idszPlayer0)
    
    if(!
iPlayer)
        return 
PLUGIN_HANDLED
    
    
new szAmount[10]
    
read_argv(2szAmountcharsmax(szAmount))
    
    new 
iAmount str_to_num(szAmount)
    new 
bool:blGive szAmount[0] == '-' false true
    
    g_iPoints
[iPlayer] += iAmount
    
    
if(!blGive)
        
iAmount *= -1
    
    
if(is_user_connected(id))
    {
        new 
szMessage[192], szName[32], szName2[32]
        
get_user_name(idszNamecharsmax(szName))
        
get_user_name(iPlayerszName2charsmax(szName2))
        
formatex(szMessagecharsmax(szMessage), "%L"LANG_TYPEblGive "CSHOP_CMD_GIVE" "CSHOP_CMD_TAKE"szNameiAmountg_eSettings[stgCurrency], szName2)
        
ColorChat(0szMessage)
        
        for(new 
isizeof(g_szColorReplace); += 2)
            
replace_all(szMessagecharsmax(szMessage), g_szColorReplace[i], "")
        
        
log_amx(szMessage)
    }
    
    return 
PLUGIN_HANDLED
}

public 
cmdListItems(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid1))
        return 
PLUGIN_HANDLED
        
    client_print
(idprint_consoleg_szItemsLoaded)
    
    for(new 
ig_iTotalItemsi++)
        
client_print(idprint_consoleg_szItems[i])
    
    
client_print(idprint_consoleg_szItemsLoaded)
    return 
PLUGIN_HANDLED
}

public 
menuShop(id)
{
    if(!
has_access_flag(id))
    {
        
ColorChat(id"%L"id"CSHOP_NOTALLOWED_FLAG")
        
errorSound(id)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iUserTeam get_user_team(id)
    
    if(!
has_access_team(id))
    {
        
ColorChat(id"%L"id"CSHOP_NOTALLOWED_TEAM")
        
errorSound(id)
        return 
PLUGIN_HANDLED
    
}
    
    if(!
is_user_alive(id))
    {
        
ColorChat(id"%L"id"CSHOP_NOTALLOWED_DEAD")
        
errorSound(id)
        return 
PLUGIN_HANDLED
    
}
    
    if(!
is_blank(g_eSettings[stgSoundOpen]))
    {
        switch(
g_eSettings[stgOpenSoundType])
        {
            case 
0emitSound(idg_eSettings[stgSoundOpen])
            case 
1speakSound(idg_eSettings[stgSoundOpen])
        }
    }
    
    new 
szTitle[256], szItem[128], szKey[5], eItem[Items], iUserLimit
    
new iMoney g_eSettings[stgPointsEnable] ? g_iPoints[id] : get_user_money(id)
    new 
iFlags get_user_flags(id)
    
    
copy(szTitlecharsmax(szTitle), g_eSettings[stgTitle])
    
    if(
contain(szTitleg_szFields[FIELD_TEAM]) != -1)
        
replace_all(szTitlecharsmax(szTitle), g_szFields[FIELD_TEAM], g_szTeams[iUserTeam])
    
    if(
contain(szTitleg_szFields[FIELD_MONEY]) != -1)
    {
        new 
szMoney[16]
        
num_to_str(iMoneyszMoneycharsmax(szMoney))
        
replace_all(szTitlecharsmax(szTitle), g_szFields[FIELD_MONEY], szMoney)
    }
        
    new 
iMenu menu_create(szTitle"handlerShop")
    
    for(new 
ig_iTotalItemsi++)
    {
        
ArrayGetArray(g_aItemsieItem)
        
num_to_str(iszKeycharsmax(szKey))
        
        if(
eItem[iTeam] && eItem[iTeam] != iUserTeam)
        {
            if(
g_eSettings[stgShowTeamed])
            {
                
formatex(szItemcharsmax(szItem), "\d%s %s"eItem[iName], g_eSettings[stgItemTeamed])
                goto 
cpAddItem
            
}
            
            continue
        }
        
        if(!
is_blank(eItem[iFlag]) && !(iFlags read_flags(eItem[iFlag])))
        {
            if(
g_eSettings[stgShowFlagged])
            {
                
formatex(szItemcharsmax(szItem), "\d%s %s"eItem[iName], g_eSettings[stgItemFlagged])
                goto 
cpAddItem
            
}
                
            continue
        }
        
        
iUserLimit get_user_limit(idi)
        
        if(
g_eSettings[stgHideLimited] && (eItem[iLimit] && iUserLimit == eItem[iLimit]))
            continue
        
        if(
eItem[iLimit])
            
formatex(szItemcharsmax(szItem), "%s%s \r[\y%i%s\r] [\y%i\r/\y%i\r]"
            (
iMoney >= eItem[iPrice] && iUserLimit eItem[iLimit]) ? "" "\d"eItem[iName], eItem[iPrice], g_eSettings[stgCurrency], iUserLimiteItem[iLimit])
        else
            
formatex(szItemcharsmax(szItem), "%s%s \r[\y%i%s\r]"
            (
iMoney >= eItem[iPrice]) ? "" "\d"eItem[iName], eItem[iPrice], g_eSettings[stgCurrency])
        
        
cpAddItem:
        
menu_additem(iMenuszItemszKey)
    }
    
    new 
iPages menu_pages(iMenu)
    
    if(!
iPages)
    {
        
ColorChat(id"%L"id"CSHOP_NOITEMS")
        
errorSound(id)
    }
    else
    {
        if(
iPages 1)
        {
            
add(szTitlecharsmax(szTitle), g_eSettings[stgTitlePage])
            
menu_setprop(iMenuMPROP_TITLEszTitle)
        }
            
        
menu_setprop(iMenuMPROP_BACKNAMEg_eSettings[stgPrevPage])
        
menu_setprop(iMenuMPROP_NEXTNAMEg_eSettings[stgNextPage])
        
menu_setprop(iMenuMPROP_EXITNAMEg_eSettings[stgMenuExit])
        
menu_setprop(iMenuMPROP_PERPAGEg_eSettings[stgPerPage])
        
menu_display(idiMenu0)
    }
    
    return 
PLUGIN_HANDLED
}

public 
handlerShop(idiMenuiItem)
{
    if(
iItem == MENU_EXIT || !is_user_alive(id))
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
szName[64], szData[6], accesscallback
    menu_item_getinfo
(iMenuiItemaccessszDatacharsmax(szData), szNamecharsmax(szName), callback)
    new 
iKey str_to_num(szData)
    
    new 
eItem[Items]
    
ArrayGetArray(g_aItemsiKeyeItem)
    new 
iMoney g_eSettings[stgPointsEnable] ? g_iPoints[id] : get_user_money(id)
    new 
iUserLimit get_user_limit(idiKey)
    
    if(
eItem[iTeam] && eItem[iTeam] != get_user_team(id))
    {
        
ColorChat(id"%L"id"CSHOP_NOT_TEAM")
        
errorSound(id)
    }
    else if(!
is_blank(eItem[iFlag]) && !(get_user_flags(id) & read_flags(eItem[iFlag])))
    {
        
ColorChat(id"%L"id"CSHOP_NOT_FLAG")
        
errorSound(id)
    }
    else if(
iMoney eItem[iPrice])
    {
        
ColorChat(id"%L"id"CSHOP_NOT_MONEY"g_eSettings[stgMoneyName], iMoneyeItem[iPrice], g_eSettings[stgCurrency])
        
errorSound(id)
    }
    else if(
eItem[iLimit] && (iUserLimit == eItem[iLimit]))
    {
        
ColorChat(id"%L"id"CSHOP_NOT_LIMIT"iUserLimiteItem[iLimit])
        
errorSound(id)
    }
    else if(
eItem[iSeconds] && g_blHasItem[id][iKey])
    {
        
ColorChat(id"%L"id"CSHOP_NOT_DELAY"eItem[iSeconds])
        
errorSound(id)
    }
    else 
buyItem(idiKey)
    
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED
}

buyItem(idiItem)
{
    new 
iReturn
    ExecuteForward
(g_fwdSelectItemiReturnidiItem)
    
    if(
iReturn)
        return 
iReturn
        
    
new eItem[Items]
    
ArrayGetArray(g_aItemsiItemeItem)
    
    if(
g_eSettings[stgPointsEnable])
        
g_iPoints[id] -= eItem[iPrice]
    else
        
take_user_money(ideItem[iPrice])
        
    
ColorChat(id"%L"id"CSHOP_ITEM_BOUGHT"eItem[iName], eItem[iPrice], g_eSettings[stgCurrency])
    
    switch(
g_eSettings[stgBuySoundType])
    {
        case 
0emitSound(ideItem[iSound])
        case 
1speakSound(ideItem[iSound])
    }
    
    switch(
g_eSettings[stgLimitType])
    {
        case 
0g_iLimit[id][iItem]++
        case 
1g_iItemTeamLimit[get_user_team(id)][iItem]++
        case 
2g_iItemLimit[iItem]++
    }
    
    
g_blHasItem[id][iItem] = true
    
    
if(eItem[iSeconds])
    {
        new 
iArray[2]
        
iArray[0] = id
        iArray
[1] = iItem
        set_task
(eItem[iSeconds], "autoRemoveItem"0iArray2)
    }
    
    return 
PLUGIN_HANDLED
}

public 
autoRemoveItem(iArray[2])
{
    new 
id iArray[0], iItem iArray[1], eItem[Items]
    
ArrayGetArray(g_aItemsiItemeItem)
    
removeItem(idiItem)
    
    if(
is_user_alive(id))
    {
        
ColorChat(id"%L"id"CSHOP_ITEM_EXPIRED"eItem[iSeconds], eItem[iName])
        
        switch(
g_eSettings[stgExpireSoundType])
        {
            case 
0:    emitSound(idg_eSettings[stgSoundExpire])
            case 
1:    speakSound(idg_eSettings[stgSoundExpire])
        }
    }
}

get_user_limit(idiItem)
{
    switch(
g_eSettings[stgLimitType])
    {
        case 
0: return g_iLimit[id][iItem]
        case 
1: return g_iItemTeamLimit[get_user_team(id)][iItem]
        case 
2: return g_iItemLimit[iItem]
    }
    
    return 
0
}

removeItem(idiItem)
{
    new 
iReturn
    g_blHasItem
[id][iItem] = false
    ExecuteForward
(g_fwdRemoveItemiReturnidiItem)
}
    
speakSound(idszSound[])
    
client_cmd(id"spk %s"szSound)
    
emitSound(idszSound[])
    
emit_sound(idCHAN_ITEMszSound1.0ATTN_NORM0PITCH_NORM)
    
errorSound(id)
    
speakSound(idg_eSettings[stgSoundError])
    
bool:has_access_flag(id)
    return (
equal(g_eSettings[stgFlag], "!") || get_user_flags(id) & read_flags(g_eSettings[stgFlag])) ? true false
    
bool
:has_access_team(id)
    return (!
g_eSettings[stgTeam] || get_user_team(id) == g_eSettings[stgTeam]) ? true false
    
bool
:is_blank(szString[])
    return 
szString[0] == EOS true false
    
public plugin_natives()
{
    
register_library("CustomShop")
    
register_native("cshopRegisterItem""_cshopRegisterItem")
    
register_native("cshopHasItem""_cshopHasItem")
    
register_native("cshopPointsEnabled""_cshopPointsEnabled")
    
register_native("cshopGetLimit""_cshopGetLimit")
    
register_native("cshopRemoveItem""_cshopRemoveItem")
    
register_native("cshopErrorSound""_cshopErrorSound")
    
register_native("cshopTotalItems""_cshopTotalItems")
    
register_native("cshopGivePoints""_cshopGivePoints")
    
register_native("ColorChat""_ColorChat")
}

public 
_cshopRegisterItem(iPluginiParams)
{
    new 
szSound[128], eItem[Items], bool:blPrecache true
    get_string
(1eItem[iName], charsmax(eItem[iName]))
    
    if(
g_eSettings[stgPointsEnable])
    {
        new 
iPoints get_param(6)
        
eItem[iPrice] = iPoints iPoints mtop(get_param(2))
    }
    else 
eItem[iPrice] = get_param(2)
    
    
eItem[iLimit] = get_param(3)
    
get_string(4eItem[iSound], charsmax(eItem[iSound]))
    
eItem[iSeconds] = get_param(5)
    
eItem[iTeam] = get_param(7)
    
get_string(8eItem[iFlag], charsmax(eItem[iFlag]))
    
ArrayPushArray(g_aItemseItem)
    
g_iTotalItems++
    
    for(new 
iArraySize(g_aSounds); i++)
    {
        
ArrayGetString(g_aSoundsiszSoundcharsmax(szSound))
        
        if(
equal(szSoundeItem[iSound]))
        {
            
blPrecache false
            
break
        }
    }
    
    if(
blPrecache)
    {
        
precache_sound(eItem[iSound])
        
ArrayPushString(g_aSoundseItem[iSound])
    }
    
    return 
g_iTotalItems 1
}

public 
bool:_cshopHasItem(iPluginiParams)
    return 
g_blHasItem[get_param(1)][get_param(2)] ? true false
    
public bool:_cshopPointsEnabled(iPluginiParams)
    return 
g_eSettings[stgPointsEnable] ? true false
    
public _cshopGetLimit(iPluginiParams)
    return 
get_user_limit(get_param(1), get_param(2))
    
public 
_cshopRemoveItem(iPluginiParams)
    
removeItem(get_param(1), get_param(2))

public 
_cshopErrorSound(iPluginiParams)
    
speakSound(get_param(1), g_eSettings[stgSoundError])
    
public 
_cshopTotalItems(iPluginiParams)
    return 
g_iTotalItems
    
public _cshopGivePoints(iPluginiParams)
    
g_iPoints[get_param(1)] += get_param(2)
    
public 
_ColorChat(iPluginiParams)
{
    new 
szMessage[191]
    
vdformat(szMessagecharsmax(szMessage), 23)
    
ColorChat(get_param(1), szMessage)
}
    
ColorChat(const id, const szInput[], any:...)
{
    new 
iPlayers[32], iCount 1
    
static szMessage[191]
    
vformat(szMessagecharsmax(szMessage), szInput3)
    
format(szMessage[0], charsmax(szMessage), "%s %s"g_eSettings[stgPrefix], szMessage)
    
    for(new 
isizeof(g_szColorReplace); += 2)
        
replace_all(szMessagecharsmax(szMessage), g_szColorReplace[i], g_szColorReplace[1])
        
    for(new 
isizeof(g_szHideChat); i++)
        
replace_all(szMessagecharsmax(szMessage), g_szHideChat[i], "")
    
    if(
id)
        
iPlayers[0] = id
    
else
        
get_players(iPlayersiCount"ch")
    
    for(new 
iiCounti++)
    {
        if(
is_user_connected(iPlayers[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_iPlayers[i])
            
write_byte(iPlayers[i])
            
write_string(szMessage)
            
message_end()
        }
    }



Airkish 07-20-2016 15:47

Re: OciXCrom's Custom Shop 3.3 + API
 
How u made Golden AK47 shot Multi-Color?

OciXCrom 07-20-2016 19:20

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by Airkish (Post 2438137)
How u made Golden AK47 shot Multi-Color?

If you're talking about the shoot sprite - that's not a part of the plugin. It's just I have modified my game files. Sorry if the picture confused you, but I'm used to using those colors and totally forget that they are different.

sirerick 07-20-2016 23:30

Re: OciXCrom's Custom Shop 3.3 + API
 
This look very well. I think I will use this for a mod. Ty for share

OciXCrom 07-23-2016 10:13

Re: OciXCrom's Custom Shop 3.3 + API
 
I'm glad that you like it. Soon I am going to add a in-game Shop Editor, that will allow you to change the settings for each item - name, price, limit, duration, etc.

http://i.imgur.com/pwU7L7Q.jpg

Also, a .ini file containing all the items will be created when you start the server - http://i.imgur.com/coSZEVr.jpg , allowing you to customize all the items from there, instead of chaning the .sma files.

Mohammad Hlwani 07-27-2016 14:10

Re: OciXCrom's Custom Shop 3.3 + API
 
good job bro

i'm asking u for something

i alot enter base builders servers

but some of servers has music for end start and preper and playing time

please if u know how to add them

i try the win sounds and alot of plugins but i cant find the right one

Fuck For Fun 07-27-2016 15:30

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by OciXCrom (Post 2438967)
I'm glad that you like it. Soon I am going to add a in-game Shop Editor, that will allow you to change the settings for each item - name, price, limit, duration, etc.

http://i.imgur.com/pwU7L7Q.jpg

Also, a .ini file containing all the items will be created when you start the server - http://i.imgur.com/coSZEVr.jpg , allowing you to customize all the items from there, instead of chaning the .sma files.

Will be more convenient and easy if you remove the numbers.

for example:
- Name: invisbility
- Price: \ d1600

But without numbers
1:

siriusmd99 07-27-2016 18:21

Re: OciXCrom's Custom Shop 3.3 + API
 
He uses new style menu where numbers are added
automatically . In this case he must use old style ones .

Mohammad Hlwani 07-29-2016 12:06

Re: OciXCrom's Custom Shop 3.3 + API
 
bro there a problem

i cant compiler the sma to amxx
cshop_items -----> #include < customshop >
custom_shop -----> #include <cshop_settings>
that the problems
i try to download the compiler files again but now work
plz hel[p

siriusmd99 07-30-2016 03:30

Re: OciXCrom's Custom Shop 3.3 + API
 
You need also to put files in scripting/include folder, not only to download them.

Mohammad Hlwani 07-30-2016 11:35

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by siriusmd99 (Post 2440720)
You need also to put files in scripting/include folder, not only to download them.

thx i worked

Mohammad Hlwani 07-30-2016 11:37

Re: OciXCrom's Custom Shop 3.3 + API
 
i fix my problem bad intity
i make an folder and name it plugins-customshop
and i put on it the plugins insted of in plugins.ini
and worked !!
and i add some thing exited to the shop
buy an skin !
and remove chamilon and put instead f it an mincraft skin
on my mod !
thx u for the shop !
best shop ever 1

siriusmd99 07-30-2016 16:03

Re: OciXCrom's Custom Shop 3.3 + API
 
Quote:

Originally Posted by Mohammad Hlwani (Post 2440811)
thx i worked

Lol, i said sarcastic but you actually didn't that thing :D:D

OciXCrom 08-04-2016 08:42

Re: OciXCrom's Custom Shop 3.3 + API
 
@Fuck For Fun - All of the things on the picture are selectable, i.e. if you select an item from the menu, you are able to change it right away, so it won't be more convenient if I removed the numbers, since you'll have to count the rows in order to know which number to choose.


All times are GMT -4. The time now is 20:55.

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