├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ └── Feature_request.md └── workflows │ └── build.yml ├── .gitignore ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── addons └── sourcemod │ ├── configs │ └── shop │ │ └── settings.txt │ ├── scripting │ ├── include │ │ ├── shop.inc │ │ └── shop │ │ │ ├── admin.inc │ │ │ ├── db.inc │ │ │ ├── functions.inc │ │ │ ├── items.inc │ │ │ ├── methodmaps.inc │ │ │ ├── players.inc │ │ │ └── register.inc │ ├── shop.sp │ └── shop │ │ ├── admin.sp │ │ ├── colors.sp │ │ ├── commands.sp │ │ ├── db.sp │ │ ├── forwards.sp │ │ ├── functions.sp │ │ ├── helpers.sp │ │ ├── item_manager.sp │ │ ├── player_manager.sp │ │ └── stats.sp │ └── translations │ ├── pt_p │ └── shop.phrases.txt │ ├── ru │ └── shop.phrases.txt │ ├── shop.phrases.txt │ └── ua │ └── shop.phrases.txt └── cfg └── shop └── shop.cfg /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sp gitlab-language=c 3 | CHANGELOG.md export-ignore 4 | README.md export-ignore -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. See error 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Server (please complete the following information):** 23 | - OS: [e.g. Linux] 24 | - Sourcemod version [e.g. 1.8.0-git1846] 25 | - Version [e.g. 3.0] 26 | 27 | **Additional context** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | env: 6 | STEAMWORKS_VERS: SteamWorks-git132 7 | 8 | jobs: 9 | compile: 10 | runs-on: ubuntu-latest 11 | continue-on-error: ${{ matrix.sm-version == '1.12.x' }} 12 | strategy: 13 | matrix: 14 | sm-version: [ '1.10.x', '1.11.x', '1.12.x' ] 15 | 16 | name: "Build SM ${{ matrix.sm-version }}" 17 | steps: 18 | - name: Prepare env 19 | shell: bash 20 | run: | 21 | echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV 22 | SMVERSION_FULL=${{ matrix.sm-version }} 23 | echo "SMVERSION_SHORT=${SMVERSION_FULL:0:-2}" >> $GITHUB_ENV 24 | - uses: actions/checkout@v2 25 | 26 | - name: Setup SP 27 | uses: rumblefrog/setup-sp@master 28 | with: 29 | version: ${{ matrix.sm-version }} 30 | 31 | - name: Run compiler 32 | run: | 33 | wget http://users.alliedmods.net/~kyles/builds/SteamWorks/${{ env.STEAMWORKS_VERS }}-linux.tar.gz 34 | wget http://users.alliedmods.net/~kyles/builds/SteamWorks/${{ env.STEAMWORKS_VERS }}-windows.zip 35 | wget -O addons/sourcemod/scripting/include/SteamWorks.inc https://raw.githubusercontent.com/JoinedSenses/SourceMod-IncludeLibrary/master/include/steamworks.inc 36 | tar -xzf ${{ env.STEAMWORKS_VERS }}-linux.tar.gz addons/sourcemod/extensions/SteamWorks.ext.so 37 | unzip -j ${{ env.STEAMWORKS_VERS }}-windows.zip addons/sourcemod/extensions/SteamWorks.ext.dll -d addons/sourcemod/extensions 38 | cd addons/sourcemod 39 | mkdir plugins 40 | cd scripting 41 | spcomp shop.sp -E -o ../plugins/shop.smx -iinclude ${{ matrix.compiler-options }} 42 | - name: Upload artifact 43 | uses: actions/upload-artifact@v3 44 | with: 45 | name: Shop-Core-${{ env.SMVERSION_SHORT }}-${{ env.GITHUB_SHA_SHORT }} 46 | path: | 47 | addons 48 | cfg 49 | LICENSE 50 | retention-days: 2 51 | 52 | release: 53 | name: Release 54 | if: github.ref_type == 'tag' 55 | needs: compile 56 | runs-on: ubuntu-latest 57 | steps: 58 | - name: Download artifacts 59 | uses: actions/download-artifact@v2 60 | 61 | - name: Find Assets 62 | shell: bash 63 | run: | 64 | echo "artifact-1_10=$(find * -maxdepth 0 -type d -name "*1.10*")" >> $GITHUB_ENV 65 | echo "artifact-1_11=$(find * -maxdepth 0 -type d -name "*1.11*")" >> $GITHUB_ENV 66 | echo "artifact-1_12=$(find * -maxdepth 0 -type d -name "*1.12*")" >> $GITHUB_ENV 67 | 68 | - name: Arhive Assets 69 | run: | 70 | zip -r ${{ env.artifact-1_10 }}.zip ${{ env.artifact-1_10 }} 71 | zip -r ${{ env.artifact-1_11 }}.zip ${{ env.artifact-1_11 }} 72 | zip -r ${{ env.artifact-1_12 }}.zip ${{ env.artifact-1_12 }} 73 | - name: Create Release 74 | id: create_release 75 | uses: actions/create-release@v1.0.0 76 | env: 77 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 78 | with: 79 | tag_name: ${{ github.ref_name }} 80 | release_name: ${{ github.ref_name }} 81 | draft: true 82 | prerelease: false 83 | 84 | - name: Upload Asset for SM 1.10 85 | uses: actions/upload-release-asset@v1.0.1 86 | env: 87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 88 | with: 89 | upload_url: ${{ steps.create_release.outputs.upload_url }} 90 | asset_path: ${{ env.artifact-1_10 }}.zip 91 | asset_name: ${{ env.artifact-1_10 }}.zip 92 | asset_content_type: application/zip 93 | 94 | - name: Upload Asset for SM 1.11 95 | uses: actions/upload-release-asset@v1.0.1 96 | env: 97 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 98 | with: 99 | upload_url: ${{ steps.create_release.outputs.upload_url }} 100 | asset_path: ${{ env.artifact-1_11 }}.zip 101 | asset_name: ${{ env.artifact-1_11 }}.zip 102 | asset_content_type: application/zip 103 | 104 | - name: Upload Asset for SM 1.12 105 | uses: actions/upload-release-asset@v1.0.1 106 | env: 107 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 108 | with: 109 | upload_url: ${{ steps.create_release.outputs.upload_url }} 110 | asset_path: ${{ env.artifact-1_12 }}.zip 111 | asset_name: ${{ env.artifact-1_12 }}.zip 112 | asset_content_type: application/zip 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dat 2 | *.smx 3 | 4 | *.zip 5 | .vscode/ 6 | site/ 7 | /.vs 8 | 9 | *.exe 10 | .gitlab-ci.yml 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | #Install some apt packages needed for spcomp 2 | addons: 3 | apt_packages: 4 | - lib32z1 5 | - lib32stdc++6 6 | 7 | language: c 8 | #Set the build environment 9 | env: 10 | global: 11 | - STEAMWORKS_VERS=SteamWorks-git132 12 | - INCLUDE=addons/sourcemod/scripting/include 13 | - SCRIPTING=addons/sourcemod/scripting 14 | - PLUGINS=addons/sourcemod/plugins 15 | - EXTENSIONS=addons/sourcemod/extensions 16 | matrix: 17 | - SMVERSION=1.10 18 | - SMVERSION=1.11 19 | 20 | matrix: 21 | allow_failures: 22 | - env: SMVERSION=1.11 23 | 24 | install: 25 | # Sourcemod download 26 | - wget --input-file=http://sourcemod.net/smdrop/$SMVERSION/sourcemod-latest-linux 27 | - tar -xzf $(cat sourcemod-latest-linux) 28 | # SteamWorks download 29 | - wget http://users.alliedmods.net/~kyles/builds/SteamWorks/$STEAMWORKS_VERS-linux.tar.gz 30 | - wget http://users.alliedmods.net/~kyles/builds/SteamWorks/$STEAMWORKS_VERS-windows.zip 31 | - tar -xzf $STEAMWORKS_VERS-linux.tar.gz $EXTENSIONS/SteamWorks.ext.so $INCLUDE/SteamWorks.inc 32 | - unzip -j $STEAMWORKS_VERS-windows.zip $EXTENSIONS/SteamWorks.ext.dll -d $EXTENSIONS 33 | before_script: 34 | - chmod +x $SCRIPTING/spcomp 35 | - mkdir $SCRIPTING/compiled 36 | script: $SCRIPTING/spcomp -E -o$SCRIPTING'/compiled/shop' -v0 $SCRIPTING'/shop.sp' 37 | 38 | #Release 39 | before_deploy: 40 | - mkdir shop shop/cfg shop/cfg/shop shop/addons shop/addons/sourcemod shop/addons/sourcemod/extensions shop/addons/sourcemod/plugins shop/addons/sourcemod/scripting shop/addons/sourcemod/scripting/include shop/addons/sourcemod/translations shop/addons/sourcemod/configs 41 | - mv $EXTENSIONS/SteamWorks.ext* shop/$EXTENSIONS 42 | - mv $SCRIPTING/shop.sp shop/$SCRIPTING 43 | - mv $SCRIPTING/shop shop/$SCRIPTING 44 | - mv $SCRIPTING/compiled/* shop/$PLUGINS 45 | - mv $INCLUDE/shop* shop/$INCLUDE 46 | - mv $INCLUDE/SteamWorks.inc shop/$INCLUDE 47 | - rsync -a --prune-empty-dirs --include '*/' --include 'shop*' --exclude '*' addons/sourcemod/translations/ shop/addons/sourcemod/translations/ 48 | - mv addons/sourcemod/configs/shop* shop/addons/sourcemod/configs 49 | - mv cfg/shop/* shop/cfg/shop 50 | - mv LICENSE shop 51 | - zip -rq shop shop 52 | - tar -czf shop.tar.gz shop 53 | deploy: 54 | skip_cleanup: true 55 | provider: releases 56 | api_key: ${GH_TOKEN} 57 | file: 58 | - shop.zip 59 | - shop.tar.gz 60 | on: 61 | tags: true 62 | #Notifications 63 | notifications: 64 | email: false 65 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at tibarification@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /addons/sourcemod/configs/shop/settings.txt: -------------------------------------------------------------------------------- 1 | "Settings" 2 | { 3 | "db_prefix" "shop_" // Tables prefix in database 4 | 5 | "Commands" // Used commands 6 | { 7 | // Admin commands 8 | "Give_Credits" "sm_givecredits" // Admin command for giving credits to player 9 | "Take_Credits" "sm_takecredits" // Admin command for taking credits from player 10 | "Set_Credits" "sm_setcredits" // Admin command for setting fixed amount of credits to player 11 | 12 | // Player commands 13 | "Main_Menu" "sm_shop,sm_store" // Command for shop menu opening, use 'comma' to multiple commands 14 | } 15 | 16 | "Count_Menu" // Menu with amount of credits for giving/setting/taking 17 | { 18 | // "Amount" "Text name" 19 | "0" "0 amount" 20 | "1" "1 amount" 21 | "10" "10 amount" 22 | "100" "Hundred" 23 | "1000" "Thousand" 24 | "10000" "10K" 25 | "100000" "100K" 26 | "1000000" "1M" 27 | // "etc" "etc" 28 | } 29 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop.inc: -------------------------------------------------------------------------------- 1 | /** 2 | Library of the [Shop] Core v3 3 | Author: FrozDark and FD-Forks team 4 | www.hlmod.ru 5 | */ 6 | 7 | #if defined _shop_included 8 | #endinput 9 | #endif 10 | #define _shop_included 11 | 12 | #define SHOP_MAX_STRING_LENGTH 64 13 | 14 | enum CategoryId 15 | { 16 | INVALID_CATEGORY = -1 17 | } 18 | 19 | enum ItemId 20 | { 21 | INVALID_ITEM = 0 22 | } 23 | 24 | enum ItemType 25 | { 26 | Item_None = 0, // For nothing is used. 27 | Item_Finite = 1, // Can only be used, they have quantity. 28 | Item_Togglable = 2, // Can be toggleable, turn on or off. 29 | Item_BuyOnly = 3 // Can only be bought. 30 | } 31 | 32 | enum ToggleState 33 | { 34 | Toggle, // Toggleable in reverse position. 35 | Toggle_On, // Turn on. 36 | Toggle_Off // Turn off. 37 | } 38 | 39 | enum ShopAction 40 | { 41 | Shop_Raw = 0, // Cancel use or toggleable. 42 | Shop_UseOn = 1, // Confirm Item Enablement. 43 | Shop_UseOff = 2 // Confirm item deactivation. 44 | } 45 | 46 | enum ShopMenu 47 | { 48 | Menu_Main, // Main menu (first menu by sm_shop command) 49 | Menu_Buy, // Buy Menu. 50 | Menu_Inventory, // Player Inventory. 51 | Menu_Functions, // Shop menu functions. 52 | Menu_ExtraFunctions, // Extra shop menu functions. 53 | Menu_AdminPanel, // Admin panel in the menu. 54 | Menu_CreditsTransfer, // Credit transfer menu. 55 | Menu_ItemTransfer // Item transfer menu. 56 | } 57 | 58 | #define IGNORE_FORWARD_HOOK -5 //**< Param to set to avoid calling forward hook */ 59 | #define CREDITS_BY_LUCK -4 //**< Credits being processed by item luck */ 60 | #define CREDITS_BY_TRANSFER -3 //**< Credits being processed by credits transfer */ 61 | #define CREDITS_BY_BUY_OR_SELL -2 //**< Credits being processed by buying or selling an item */ 62 | #define CREDITS_BY_NATIVE -1 //**< Credits being processed by native */ 63 | #define CREDITS_BY_COMMAND 0 //**< Credits being processed by server console or rcon command */ 64 | //**< Any higher value is admin index */ 65 | 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | 74 | /** 75 | * Called when the shop is ready to register items. 76 | * 77 | * @noparams 78 | * 79 | * @noreturn 80 | */ 81 | forward void Shop_Started(); 82 | 83 | /** 84 | * Checks whether the shop has been started. 85 | * 86 | * @noparams 87 | * 88 | * @return True if the shop is already started, false otherwise. 89 | */ 90 | native bool Shop_IsStarted(); 91 | 92 | /** 93 | * This must be called on PluginEnd. Fully unregisters the plugin. Unregisters items, categories and removes them from the shop and players' inventory. 94 | * 95 | * @noparams 96 | * 97 | * @noreturn 98 | */ 99 | native void Shop_UnregisterMe(); 100 | 101 | /** 102 | * Get path to the main config folder of the Shop. 103 | * 104 | * @param buffer Buffer to store the path in. 105 | * @param size Max buffer length. 106 | * @param file File to retrieve the path for. 107 | * 108 | * @noreturn 109 | */ 110 | stock void Shop_GetCfgFile(char[] buffer, int size, const char[] file) 111 | { 112 | BuildPath(Path_SM, buffer, size, "configs/shop/%s", file); 113 | } 114 | 115 | public SharedPlugin __pl_shop = 116 | { 117 | name = "shop", 118 | file = "shop.smx", 119 | #if defined REQUIRE_PLUGIN 120 | required = 1, 121 | #else 122 | required = 0, 123 | #endif 124 | }; 125 | 126 | #if !defined REQUIRE_PLUGIN 127 | public void __pl_shop_SetNTVOptional() 128 | { 129 | MarkNativeAsOptional("Shop_IsStarted"); 130 | MarkNativeAsOptional("Shop_UnregisterMe"); 131 | MarkNativeAsOptional("Shop_UnregisterItem"); 132 | MarkNativeAsOptional("Shop_ShowItemPanel"); 133 | MarkNativeAsOptional("Shop_OpenMainMenu"); 134 | MarkNativeAsOptional("Shop_ShowCategory"); 135 | MarkNativeAsOptional("Shop_ShowInventory"); 136 | MarkNativeAsOptional("Shop_ShowItemsOfCategory"); 137 | MarkNativeAsOptional("Shop_GetDatabase"); 138 | MarkNativeAsOptional("Shop_GetDatabasePrefix"); 139 | 140 | MarkNativeAsOptional("Shop_ShowAdminMenu"); 141 | MarkNativeAsOptional("Shop_AddToAdminMenu"); 142 | MarkNativeAsOptional("Shop_RemoveFromAdminMenu"); 143 | 144 | MarkNativeAsOptional("Shop_ShowFunctionsMenu"); 145 | MarkNativeAsOptional("Shop_AddToFunctionsMenu"); 146 | MarkNativeAsOptional("Shop_RemoveFromFunctionsMenu"); 147 | 148 | MarkNativeAsOptional("Shop_RegisterCategory"); 149 | MarkNativeAsOptional("Shop_StartItem"); 150 | MarkNativeAsOptional("Shop_SetInfo"); 151 | MarkNativeAsOptional("Shop_SetLuckChance"); 152 | MarkNativeAsOptional("Shop_SetCallbacks"); 153 | MarkNativeAsOptional("Shop_SetCustomInfo"); 154 | MarkNativeAsOptional("Shop_SetCustomInfoFloat"); 155 | MarkNativeAsOptional("Shop_SetCustomInfoString"); 156 | MarkNativeAsOptional("Shop_KvCopySubKeysCustomInfo"); 157 | MarkNativeAsOptional("Shop_EndItem"); 158 | 159 | MarkNativeAsOptional("Shop_GetItemCustomInfo"); 160 | MarkNativeAsOptional("Shop_SetItemCustomInfo"); 161 | MarkNativeAsOptional("Shop_GetItemCustomInfoFloat"); 162 | MarkNativeAsOptional("Shop_SetItemCustomInfoFloat"); 163 | MarkNativeAsOptional("Shop_GetItemCustomInfoString"); 164 | MarkNativeAsOptional("Shop_SetItemCustomInfoString"); 165 | MarkNativeAsOptional("Shop_KvCopySubKeysItemCustomInfo"); 166 | MarkNativeAsOptional("Shop_GetItemPrice"); 167 | MarkNativeAsOptional("Shop_SetItemPrice"); 168 | MarkNativeAsOptional("Shop_GetItemGoldPrice"); 169 | MarkNativeAsOptional("Shop_SetItemGoldPrice"); 170 | MarkNativeAsOptional("Shop_GetItemSellPrice"); 171 | MarkNativeAsOptional("Shop_SetItemSellPrice"); 172 | MarkNativeAsOptional("Shop_GetItemGoldSellPrice"); 173 | MarkNativeAsOptional("Shop_SetItemGoldSellPrice"); 174 | MarkNativeAsOptional("Shop_GetItemLuckChance"); 175 | MarkNativeAsOptional("Shop_SetItemLuckChance"); 176 | MarkNativeAsOptional("Shop_GetItemValue"); 177 | MarkNativeAsOptional("Shop_SetItemValue"); 178 | MarkNativeAsOptional("Shop_IsItemExists"); 179 | MarkNativeAsOptional("Shop_IsValidCategory"); 180 | MarkNativeAsOptional("Shop_GetItemId"); 181 | MarkNativeAsOptional("Shop_GetItemById"); 182 | MarkNativeAsOptional("Shop_GetItemType"); 183 | MarkNativeAsOptional("Shop_GetItemCategoryId"); 184 | MarkNativeAsOptional("Shop_GetCategoryId"); 185 | MarkNativeAsOptional("Shop_GetCategoryById"); 186 | MarkNativeAsOptional("Shop_GetCategoryNameById"); 187 | MarkNativeAsOptional("Shop_FillArrayByItems"); 188 | MarkNativeAsOptional("Shop_FormatItem"); 189 | MarkNativeAsOptional("Shop_GetClientItems"); 190 | 191 | MarkNativeAsOptional("Shop_GetClientId"); 192 | MarkNativeAsOptional("Shop_SetClientItemTimeleft"); 193 | MarkNativeAsOptional("Shop_GetClientItemTimeleft"); 194 | MarkNativeAsOptional("Shop_GetClientItemSellPrice"); 195 | MarkNativeAsOptional("Shop_IsClientItemToggled"); 196 | MarkNativeAsOptional("Shop_IsClientHasItem"); 197 | MarkNativeAsOptional("Shop_ToggleClientItem"); 198 | MarkNativeAsOptional("Shop_ToggleClientCategoryOff"); 199 | MarkNativeAsOptional("Shop_IsAuthorized"); 200 | MarkNativeAsOptional("Shop_IsAdmin"); 201 | MarkNativeAsOptional("Shop_GiveClientCredits"); 202 | MarkNativeAsOptional("Shop_TakeClientCredits"); 203 | MarkNativeAsOptional("Shop_GetClientCredits"); 204 | MarkNativeAsOptional("Shop_SetClientCredits"); 205 | MarkNativeAsOptional("Shop_GiveClientGold"); 206 | MarkNativeAsOptional("Shop_TakeClientGold"); 207 | MarkNativeAsOptional("Shop_GetClientGold"); 208 | MarkNativeAsOptional("Shop_SetClientGold"); 209 | MarkNativeAsOptional("Shop_GiveClientItem"); 210 | MarkNativeAsOptional("Shop_BuyClientItem"); 211 | MarkNativeAsOptional("Shop_SellClientItem"); 212 | MarkNativeAsOptional("Shop_RemoveClientItem"); 213 | MarkNativeAsOptional("Shop_GetClientItemCount"); 214 | MarkNativeAsOptional("Shop_UseClientItem"); 215 | MarkNativeAsOptional("Shop_SetHide"); 216 | MarkNativeAsOptional("Shop_GetClientItems"); 217 | 218 | MarkNativeAsOptional("CategoryId.CategoryId"); 219 | MarkNativeAsOptional("CategoryId.NewItem"); 220 | MarkNativeAsOptional("CategoryId.GetItemId"); 221 | MarkNativeAsOptional("CategoryId.GetByUnique"); 222 | MarkNativeAsOptional("CategoryId.GetUniqueName"); 223 | MarkNativeAsOptional("CategoryId.GetDisplayName"); 224 | MarkNativeAsOptional("CategoryId.ToggleOff"); 225 | MarkNativeAsOptional("CategoryId.Exist.get"); 226 | 227 | MarkNativeAsOptional("ItemId.GetCustomInfo"); 228 | MarkNativeAsOptional("ItemId.SetCustomInfo"); 229 | MarkNativeAsOptional("ItemId.GetCustomInfoFloat"); 230 | MarkNativeAsOptional("ItemId.SetCustomInfoFloat"); 231 | MarkNativeAsOptional("ItemId.GetCustomInfoString"); 232 | MarkNativeAsOptional("ItemId.SetCustomInfoString"); 233 | MarkNativeAsOptional("ItemId.KvCopyCustomInfo"); 234 | MarkNativeAsOptional("ItemId.GetUniqueName"); 235 | MarkNativeAsOptional("ItemId.GetDisplayName"); 236 | MarkNativeAsOptional("ItemId.Format"); 237 | MarkNativeAsOptional("ItemId.Give"); 238 | MarkNativeAsOptional("ItemId.Buy"); 239 | MarkNativeAsOptional("ItemId.Sell"); 240 | MarkNativeAsOptional("ItemId.Use"); 241 | MarkNativeAsOptional("ItemId.Remove"); 242 | MarkNativeAsOptional("ItemId.GetCount"); 243 | MarkNativeAsOptional("ItemId.SetCount"); 244 | MarkNativeAsOptional("ItemId.SetTimeLeft"); 245 | MarkNativeAsOptional("ItemId.GetTimeLeft"); 246 | MarkNativeAsOptional("ItemId.GetSellPrice"); 247 | MarkNativeAsOptional("ItemId.IsToggled"); 248 | MarkNativeAsOptional("ItemId.IsHas"); 249 | MarkNativeAsOptional("ItemId.Toggle"); 250 | MarkNativeAsOptional("ItemId.CategoryId.get"); 251 | MarkNativeAsOptional("ItemId.Price.get"); 252 | MarkNativeAsOptional("ItemId.Price.set"); 253 | MarkNativeAsOptional("ItemId.SellPrice.get"); 254 | MarkNativeAsOptional("ItemId.SellPrice.set"); 255 | MarkNativeAsOptional("ItemId.Value.get"); 256 | MarkNativeAsOptional("ItemId.Value.set"); 257 | MarkNativeAsOptional("ItemId.LuckChange.get"); 258 | MarkNativeAsOptional("ItemId.LuckChange.set"); 259 | MarkNativeAsOptional("ItemId.Hide.get"); 260 | MarkNativeAsOptional("ItemId.Hide.set"); 261 | MarkNativeAsOptional("ItemId.ItemType.get"); 262 | MarkNativeAsOptional("ItemId.Exist.get"); 263 | 264 | } 265 | #endif 266 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/admin.inc: -------------------------------------------------------------------------------- 1 | /** 2 | * Called when an item from admin panel is being displayed. 3 | * 4 | * @param client Client index an item is being shown to. 5 | * @param buffer Buffer to store display name. 6 | * @param maxlength Max length of the buffer. 7 | * 8 | * @noreturn 9 | */ 10 | typedef Shop_AdminDisplay = function void (int client, char[] buffer, int maxlength); 11 | 12 | /** 13 | * Called when an item from admin panel is being selected. 14 | * 15 | * @param client Client index performing selection. 16 | * 17 | * @return true to allow performing and false to block. 18 | */ 19 | typedef Shop_AdminSelect = function bool (int client); 20 | 21 | /** 22 | * Adds an item to the admin panel. 23 | * 24 | * @param callback_display Callback when the item is being shown. Set display name in the callback. 25 | * @param callback_select Callback when the item is being selected. 26 | * 27 | * @noreturn 28 | */ 29 | native void Shop_AddToAdminMenu(Shop_AdminDisplay callback_display, Shop_AdminSelect callback_select); 30 | 31 | /** 32 | * Removes an item from the admin panel. 33 | * 34 | * @param callback_display Callback to remove. 35 | * @param callback_select Callback to remove. 36 | * 37 | * @return true on success, false otherwise. 38 | */ 39 | native bool Shop_RemoveFromAdminMenu(Shop_AdminDisplay callback_display, Shop_AdminSelect callback_select); 40 | 41 | /** 42 | * Shows admin panel to a player. 43 | * 44 | * @param client Client index to show to. 45 | * @error Invalid player index. 46 | * 47 | * @noreturn 48 | */ 49 | native void Shop_ShowAdminMenu(int client); -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/db.inc: -------------------------------------------------------------------------------- 1 | enum ShopDBType 2 | { 3 | DB_Unknown, 4 | DB_MySQL, 5 | DB_SQLite 6 | } 7 | 8 | /** 9 | * Get the database handle. Must be freed with CloseHandle(). 10 | * 11 | * @noparams 12 | * 13 | * @return Database Handle. 14 | */ 15 | native Database Shop_GetDatabase(); 16 | 17 | /** 18 | * Gets the database type. See ShopDBType enumeration. 19 | * 20 | * @noparams 21 | * 22 | * @return Database type. 23 | */ 24 | native ShopDBType Shop_GetDatabaseType(); 25 | 26 | /** 27 | * Get the database prefix. 28 | * 29 | * @param buffer Buffer to store the prefix in. 30 | * @param maxlength Max buffer length. 31 | * 32 | * @return Number of bytes written. 33 | */ 34 | native int Shop_GetDatabasePrefix(char[] buffer, int maxlength); -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/functions.inc: -------------------------------------------------------------------------------- 1 | /** 2 | * Called when an item from functions menu is being displayed. 3 | * 4 | * @param client Client index an item is being shown to. 5 | * @param buffer Buffer to store display name. 6 | * @param maxlength Max length of the buffer. 7 | * 8 | * @noreturn 9 | */ 10 | typedef Shop_FuncDisplay = function void (int client, char[] buffer, int maxlength); 11 | 12 | /** 13 | * Called when an item from functions menu is being selected. 14 | * 15 | * @param client Client index performing selection. 16 | * 17 | * @return true to allow performing and false to block. 18 | */ 19 | typedef Shop_FuncSelect = function bool (int client); 20 | 21 | /** 22 | * Adds an item to the functions menu. 23 | * 24 | * @param callback_display Callback when the item is being shown. Set display name in the callback. 25 | * @param callback_select Callback when the item is being selected. 26 | * 27 | * @noreturn 28 | */ 29 | native void Shop_AddToFunctionsMenu(Shop_FuncDisplay callback_display, Shop_FuncSelect callback_select); 30 | 31 | /** 32 | * Removes an item from the functions menu. 33 | * 34 | * @param callback_display Callback to remove. 35 | * @param callback_select Callback to remove. 36 | * 37 | * @return true on success, false otherwise. 38 | */ 39 | native bool Shop_RemoveFromFunctionsMenu(Shop_FuncDisplay callback_display, Shop_FuncSelect callback_select); -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/items.inc: -------------------------------------------------------------------------------- 1 | /** 2 | * Called when an item is being drawn. 3 | * 4 | * @param client Client index an item is being drawn to. 5 | * @param menu_action Menu performing this action. 6 | * @param category_id Category id of an item. 7 | * @param item_id Item id of an item. 8 | * @param disable Whether an item should be disabled of to be selected. 9 | * 10 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block an item to shown. Plugin_Continue otherwise. 11 | */ 12 | forward Action Shop_OnItemDraw(int client, ShopMenu menu_action, CategoryId category_id, ItemId item_id, bool &disable); 13 | 14 | /** 15 | * Called when an item is being select. 16 | * 17 | * @param client Client index an item is being select to. 18 | * @param menu_action Menu performing this action. 19 | * @param category_id Category id of an item. 20 | * @param item_id Item id of an item. 21 | * 22 | * @return Plugin_Handled to block an item to select, and show items of category. Plugin_Stop to close menu. Plugin_Continue or Plugin_Changed otherwise. 23 | */ 24 | forward Action Shop_OnItemSelect(int client, ShopMenu menu_action, CategoryId category_id, ItemId item_id); 25 | 26 | /** 27 | * Called when an item is being select. 28 | * 29 | * @param client Client index an item is being select to. 30 | * @param menu_action Menu performing this action. 31 | * @param category_id Category id of an item. 32 | * @param item_id Item id of an item. 33 | * 34 | * @noreturn 35 | */ 36 | forward void Shop_OnItemSelected(int client, ShopMenu menu_action, CategoryId category_id, ItemId item_id); 37 | 38 | /** 39 | * Called when an item is being display. 40 | * 41 | * @param client Client index an item is being displayed to. 42 | * @param menu_action Menu performing this action. 43 | * @param category_id Category id of an item. 44 | * @param item_id Item id of an item. 45 | * @param display Display name being shown. 46 | * @param buffer Buffer to store new display name. 47 | * @param maxlength Max length of the buffer. 48 | * 49 | * @return true to apply new display name, false otherwise. 50 | */ 51 | forward bool Shop_OnItemDisplay(int client, ShopMenu menu_action, CategoryId category_id, ItemId item_id, const char[] display, char[] buffer, int maxlength); 52 | 53 | /** 54 | * Called when an item's description is being display. 55 | * 56 | * @param client Client index an item's description is being displayed to. 57 | * @param menu_action Menu performing this action. 58 | * @param category_id Category id of an item. 59 | * @param item_id Item id of an item. 60 | * @param description Description being shown. 61 | * @param buffer Buffer to store new description. 62 | * @param maxlength Max length of the buffer. 63 | * 64 | * @return true to apply new description, false otherwise. 65 | */ 66 | forward bool Shop_OnItemDescription(int client, ShopMenu menu_action, CategoryId category_id, ItemId item_id, const char[] description, char[] buffer, int maxlength); 67 | 68 | /** 69 | * Called when an item is being bought. 70 | * 71 | * @param client Client index that performing this. 72 | * @param category_id Category id of an item. 73 | * @param category Category unique name. 74 | * @param item_id Item id of an item. 75 | * @param item Item's unique name. 76 | * @param type Item type. 77 | * @param price Price of the item. Set by reference. 78 | * @param sell_price Sell price of the item. Set by reference. 79 | * @param value Count if the item is finite and duration if the item is togglable or non-togglable. Set by reference. 80 | * @param gold_price Gold price of the item. Set by reference. 81 | * @param gold_sell_price Gold sell price of the item. Set by reference. 82 | * 83 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. Plugin_Continue otherwise. 84 | */ 85 | forward Action Shop_OnItemBuy(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int &price, int &sell_price, int &value, int &gold_price, int &gold_sell_price); 86 | 87 | /** 88 | * Called when an item is being bought. 89 | * 90 | * @param client Client index that performing this. 91 | * @param category_id Category id of an item. 92 | * @param category Category unique name. 93 | * @param item_id Item id of an item. 94 | * @param item Item's unique name. 95 | * @param type Item type. 96 | * @param sell_price Sell price of the item. Set by reference. 97 | * @param gold_sell_price Gold sell price of the item. Set by reference. 98 | * 99 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. Plugin_Continue otherwise. 100 | */ 101 | forward Action Shop_OnItemSell(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int &sell_price, int &gold_sell_price); 102 | 103 | /** 104 | * Called when an item has been toggled. 105 | * 106 | * @param client Client index that performing this. 107 | * @param category_id Category id of an item. 108 | * @param category Category unique name. 109 | * @param item_id Item id of an item. 110 | * @param item Item's unique name. 111 | * @param toggle State of the toggle. See ToggleState enum. 112 | * 113 | * @noreturn 114 | */ 115 | forward void Shop_OnItemToggled(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ToggleState toggle); 116 | 117 | /** 118 | * Called when an item has been elapsed. 119 | * 120 | * @param client Client index whose item has been elapsed. 121 | * @param category_id Category id of an item. 122 | * @param category Category unique name. 123 | * @param item_id Item id of an item. 124 | * @param item Item's unique name. 125 | * 126 | * @noreturn 127 | */ 128 | forward void Shop_OnItemElapsed(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item); 129 | 130 | /** 131 | * Called when a player is transferring an item. 132 | * 133 | * @param client Origin player. 134 | * @param target Destination player. 135 | * @param item_id Item id of an item. 136 | * 137 | * @return true to allow transfer and false to block. 138 | */ 139 | forward bool Shop_OnItemTransfer(int client, int target, ItemId item_id); 140 | 141 | /** 142 | * Called when a player has transfered an item. 143 | * 144 | * @param client Origin player. 145 | * @param target Destination player. 146 | * @param item_id Item id of an item. 147 | * 148 | * @noreturn 149 | */ 150 | forward void Shop_OnItemTransfered(int client, int target, ItemId item_id); 151 | 152 | /** 153 | * Gets an item custom info. 154 | * 155 | * @param item_id Item id. 156 | * @param info Info key to get. 157 | * @param defaultvalue Optional default value to use if the key is not found. 158 | * @error Invalid ItemId. 159 | * 160 | * @return Integer value of the key. 161 | */ 162 | native int Shop_GetItemCustomInfo(ItemId item_id, const char[] info, int defaultvalue = 0); 163 | 164 | /** 165 | * Sets an item custom info. 166 | * 167 | * @param item_id Item id. 168 | * @param info Info key to set. 169 | * @param value Value to set. 170 | * @error Invalid ItemId. 171 | * 172 | * @return true on success, false otherwise. 173 | */ 174 | native bool Shop_SetItemCustomInfo(ItemId item_id, const char[] info, int value); 175 | 176 | /** 177 | * Gets an item custom info. 178 | * 179 | * @param item_id Item id. 180 | * @param info Info key to get. 181 | * @param defaultvalue Optional default value to use if the key is not found. 182 | * @error Invalid ItemId. 183 | * 184 | * @return Float value of the key. 185 | */ 186 | native float Shop_GetItemCustomInfoFloat(ItemId item_id, const char[] info, float defaultvalue = 0.0); 187 | 188 | /** 189 | * Sets an item custom info. 190 | * 191 | * @param item_id Item id. 192 | * @param info Info key to set. 193 | * @param value Value to set. 194 | * @error Invalid ItemId. 195 | * 196 | * @return true on success, false otherwise. 197 | */ 198 | native bool Shop_SetItemCustomInfoFloat(ItemId item_id, const char[] info, float value); 199 | 200 | /** 201 | * Gets an item custom info. 202 | * 203 | * @param item_id Item id. 204 | * @param info Info key to get. 205 | * @param buffer Buffer to store the value in. 206 | * @param maxlength Max length of the buffer. 207 | * @param defaultvalue Optional default value to use if the key is not found. 208 | * @error Invalid ItemId. 209 | * 210 | * @return Number of bytes written. 211 | */ 212 | native int Shop_GetItemCustomInfoString(ItemId item_id, const char[] info, char[] buffer, int maxlength, const char[] defaultvalue = ""); 213 | 214 | /** 215 | * Sets an item custom info. 216 | * 217 | * @param item_id Item id. 218 | * @param info Info key to set. 219 | * @param value Value to set. 220 | * @error Invalid ItemId. 221 | * 222 | * @return true on success, false otherwise. 223 | */ 224 | native bool Shop_SetItemCustomInfoString(ItemId item_id, const char[] info, const char[] value); 225 | 226 | /** 227 | * Copies SubKeys of a KeyValue structure to the item info. 228 | * 229 | * @param item_id Item id. 230 | * @param kv KeyValue structure to copy. 231 | * @error Invalid ItemId. 232 | * @error Invalid KeyValues Handle. 233 | * 234 | * @return true on success, false otherwise. 235 | */ 236 | native bool Shop_KvCopySubKeysItemCustomInfo(ItemId item_id, KeyValues kv); 237 | 238 | /** 239 | * Unregisters item, categories and removes them from the shop and players' inventory by ItemId. 240 | * 241 | * @param item_id Item id. 242 | * @error Invalid ItemId. 243 | * 244 | * @noreturn 245 | */ 246 | native void Shop_UnregisterItem(ItemId item_id); 247 | 248 | /** 249 | * Gets an item credits price. 250 | * 251 | * @param item_id Item id. 252 | * @error Invalid ItemId. 253 | * 254 | * @return Price of the item. 255 | */ 256 | native int Shop_GetItemPrice(ItemId item_id); 257 | 258 | /** 259 | * Sets an item credits price. 260 | * 261 | * @param item_id Item id. 262 | * @param price Price to set. 263 | * @error Invalid ItemId. 264 | * 265 | * @noreturn 266 | */ 267 | native void Shop_SetItemPrice(ItemId item_id, int price); 268 | 269 | /** 270 | * Gets an item gold price. 271 | * 272 | * @param item_id Item id. 273 | * @error Invalid ItemId. 274 | * 275 | * @return Price of the item. 276 | */ 277 | native int Shop_GetItemGoldPrice(ItemId item_id); 278 | 279 | /** 280 | * Sets an item gold price. 281 | * 282 | * @param item_id Item id. 283 | * @param price Price to set. 284 | * @error Invalid ItemId. 285 | * 286 | * @noreturn 287 | */ 288 | native void Shop_SetItemGoldPrice(ItemId item_id, int price); 289 | 290 | /** 291 | * Gets an item luck chance. 292 | * 293 | * @param item_id Item id. 294 | * @error Invalid ItemId. 295 | * 296 | * @return Luck chance of the item. From 0 to 100. 297 | */ 298 | native int Shop_GetItemLuckChance(ItemId item_id); 299 | 300 | /** 301 | * Sets an item luck chance. 302 | * 303 | * @param item_id Item id. 304 | * @param luck_chance Luck chance to set. From 0 to 100. 0 can not be lucked and 100 is always lucked by the general chance set in cvar. Default item chance is 100. 305 | * @error Invalid ItemId. 306 | * 307 | * @noreturn 308 | */ 309 | native void Shop_SetItemLuckChance(ItemId item_id, int luck_chance); 310 | 311 | /** 312 | * Gets an item credits sell price. 313 | * 314 | * @param item_id Item id. 315 | * @error Invalid ItemId. 316 | * 317 | * @return Sell price of the item. 318 | */ 319 | native int Shop_GetItemSellPrice(ItemId item_id); 320 | 321 | /** 322 | * Sets an item credits sell price. 323 | * 324 | * @param item_id Item id. 325 | * @param sell_price Sell price to set. 326 | * @error Invalid ItemId. 327 | * 328 | * @noreturn 329 | */ 330 | native void Shop_SetItemSellPrice(ItemId item_id, int sell_price); 331 | 332 | /** 333 | * Gets an item gold sell price. 334 | * 335 | * @param item_id Item id. 336 | * @error Invalid ItemId. 337 | * 338 | * @return Gold sell price of the item. 339 | */ 340 | native int Shop_GetItemGoldSellPrice(ItemId item_id); 341 | 342 | /** 343 | * Sets an item gold sell price. 344 | * 345 | * @param item_id Item id. 346 | * @param sell_price Gold sell price to set. 347 | * @error Invalid ItemId. 348 | * 349 | * @noreturn 350 | */ 351 | native void Shop_SetItemGoldSellPrice(ItemId item_id, int sell_price); 352 | 353 | /** 354 | * Gets an item count if item is finite and duration if item is togglable or non-togglable (-1 if duration is unlimited). 355 | * 356 | * @param item_id Item id. 357 | * @error Invalid ItemId. 358 | * 359 | * @return Value of the item id. 360 | */ 361 | native int Shop_GetItemValue(ItemId item_id); 362 | 363 | /** 364 | * Sets an item count if item is finite and duration if item is togglable or non-togglable (-1 unlimited). 365 | * 366 | * @param item_id Item id. 367 | * @error Invalid ItemId. 368 | * 369 | * @noreturn 370 | */ 371 | native void Shop_SetItemValue(ItemId item_id, int value); 372 | 373 | /** 374 | * Whether the item is exists (registered). 375 | * 376 | * @param item_id Item id. 377 | * 378 | * @return True if item is exists, false otherwise. 379 | */ 380 | native bool Shop_IsItemExists(ItemId item_id); 381 | 382 | /** 383 | * Whether the category is valid (registered). 384 | * 385 | * @param category_id Category id. 386 | * 387 | * @return True if category is exists, false otherwise. 388 | */ 389 | native bool Shop_IsValidCategory(CategoryId category_id); 390 | 391 | /** 392 | * Gets item id of the item unique name. 393 | * 394 | * @param category_id Category id where the item is registered. 395 | * @param item Item unique name to get for. 396 | * @error Invalid CategoryId. 397 | * 398 | * @return Item id of the item. 399 | */ 400 | native ItemId Shop_GetItemId(CategoryId category_id, const char[] item); 401 | 402 | /** 403 | * Gets the item unique name by its id. 404 | * 405 | * @param item_id Item id to get for. 406 | * @param buffer Buffer to store the unique name. 407 | * @param maxlength Max length of the buffer. 408 | * @error Invalid ItemId. 409 | * 410 | * @return Number of bytes written. 411 | */ 412 | native int Shop_GetItemById(ItemId item_id, char[] buffer, int maxlength); 413 | 414 | /** 415 | * Gets the item type. 416 | * 417 | * @param item_id Item id to get for. 418 | * @error Invalid ItemId. 419 | * 420 | * @return Item type of the item. See ItemType enumeration. 421 | */ 422 | native ItemType Shop_GetItemType(ItemId item_id); 423 | 424 | /** 425 | * Get name of item. 426 | * 427 | * @param item_id Item id to get for. 428 | * @param buffer Buffer to store the name. 429 | * @param maxlength Max length of the buffer. 430 | * @error Invalid ItemId. 431 | * 432 | * @return Number of bytes written. 433 | */ 434 | native int Shop_GetItemNameById(ItemId item_id, char[] buffer, int maxlength); 435 | 436 | /** 437 | * Get is feature "Try luck" enabled. 438 | * 439 | * @param item_id Item id to get for. 440 | * @error Invalid ItemId. 441 | * 442 | * @return true - available, false - restricted. 443 | */ 444 | native bool Shop_GetItemCanLuck(ItemId item_id); 445 | 446 | /** 447 | * Set feature "Try luck". 448 | * 449 | * @param item_id Item id to set for. 450 | * @param bCanLuck true - available, false - restricted. 451 | * @error Invalid ItemId. 452 | * 453 | * @noreturn 454 | */ 455 | native void Shop_SetItemCanLuck(ItemId item_id, bool bCanLuck); 456 | 457 | /** 458 | * Get is feature "Hide" enabled. 459 | * 460 | * @param item_id Item id to get for. 461 | * @error Invalid ItemId. 462 | * 463 | * @return true - item hidden, false - available for buying. 464 | */ 465 | native bool Shop_GetItemHide(ItemId item_id); 466 | 467 | /** 468 | * Set feature "Hide". 469 | * 470 | * @param item_id Item id to set for. 471 | * @param state true - to hide item, false - to show in buyable list. 472 | * @error Invalid ItemId. 473 | * 474 | * @noreturn 475 | */ 476 | native void Shop_SetItemHide(ItemId item_id, bool state); 477 | 478 | /** 479 | * Gets the item's category id. 480 | * 481 | * @param item_id Item id to get category id from. 482 | * @error Invalid ItemId. 483 | * 484 | * @return Category id or INVALID_CATEGORY if category is not set or item id is invalid. 485 | */ 486 | native CategoryId Shop_GetItemCategoryId(ItemId item_id); 487 | 488 | /** 489 | * Gets category id of the category unique name. 490 | * 491 | * @param category Category unique name to get id for. 492 | * 493 | * @return Category id of the category. 494 | */ 495 | native CategoryId Shop_GetCategoryId(const char[] category); 496 | 497 | /** 498 | * Gets the category unique name by its id. 499 | * 500 | * @param category_id Category id to get for. 501 | * @param buffer Buffer to store the unique name. 502 | * @param maxlength Max length of the buffer. 503 | * @error Invalid CategoryId. 504 | * 505 | * @return True on success, false otherwise. 506 | */ 507 | native bool Shop_GetCategoryById(CategoryId category_id, char[] buffer, int maxlength); 508 | 509 | /** 510 | * Gets the category name by its id. 511 | * 512 | * @param category_id Category id to get for. 513 | * @param buffer Buffer to store the name. 514 | * @param maxlength Max length of the buffer. 515 | * @error Invalid CategoryId. 516 | * 517 | * @return True on success, false otherwise. 518 | */ 519 | native bool Shop_GetCategoryNameById(CategoryId category_id, char[] buffer, int maxlength); 520 | 521 | /** 522 | * Fills an adt_array by the item ids. Note that array is cleared before being filled. 523 | * 524 | * @param array ADT array to use. 525 | * @error Invalid ArrayList Handle. 526 | * 527 | * @return Number of bytes that written to ArrayList. 528 | */ 529 | native int Shop_FillArrayByItems(ArrayList array); 530 | 531 | /** 532 | * Formats item display name to use in menu. 533 | * 534 | * @param client Client index to get format for. 535 | * @param item_id Item id to format. 536 | * @param menu Menu to get formatted for. 537 | * @param buffer Buffer to store the result in. 538 | * @param maxlength Max length of the buffer. 539 | * @error Invalid player index. 540 | * @error Item has no callbacks. 541 | * @error Invalid ItemId. 542 | * 543 | * @return True if item formatted, false if param menu is Menu_Inventory and the player has not this item and the item is not formatted. 544 | */ 545 | native bool Shop_FormatItem(int client, ItemId item_id, ShopMenu menu, char[] buffer, int maxlength); 546 | 547 | /** 548 | * Creates and ADT array of item ids. 549 | * 550 | * @param size Optional param to store array size. 551 | * 552 | * @return ArrayList. 553 | */ 554 | stock ArrayList Shop_CreateArrayOfItems(int &size = 0) 555 | { 556 | ArrayList _shop_array = new ArrayList(); 557 | size = Shop_FillArrayByItems(_shop_array); 558 | return _shop_array; 559 | } 560 | 561 | /** 562 | * Retrieves an item id from an array. 563 | * 564 | * @param array Array handle. 565 | * @param index Index in the array. 566 | * @error Invalid ArrayList Handle. 567 | * @error Invalid index. 568 | * 569 | * @return Item id. 570 | */ 571 | stock ItemId Shop_GetArrayItem(ArrayList array, int index) 572 | { 573 | return view_as(array.Get(index)); 574 | } 575 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/methodmaps.inc: -------------------------------------------------------------------------------- 1 | 2 | methodmap CategoryId __nullable__ 3 | { 4 | /** 5 | * Registers new category id. 6 | * 7 | * @param category Category unique name. 8 | * @param name Default category display name. 9 | * @param description Default category description. 10 | * @param cat_display Callback called on category being displayed. 11 | * @param cat_desc Callback called on category's description being displayed. 12 | * @param cat_should Callback called whether the category should be displayed to a player. 13 | * @param cat_select Callback called when a player is trying to select the category. 14 | * 15 | * @return Category id of the category. 16 | */ 17 | public native CategoryId(const char[] category, const char[] name, const char[] description, 18 | Shop_CategoryDisplayCallback cat_display=INVALID_FUNCTION, 19 | Shop_CategoryDescriptionCallback cat_desc=INVALID_FUNCTION, 20 | Shop_CategoryShouldDisplayCallback cat_should=INVALID_FUNCTION, 21 | Shop_CategorySelectCallback cat_select=INVALID_FUNCTION); 22 | 23 | /** 24 | * Starts an item to register. 25 | * 26 | * @param item Item unique name. 27 | * @error Invalid CategoryId. 28 | * 29 | * @return true to success, false otherwise. 30 | */ 31 | public native bool NewItem(const char[] item); 32 | 33 | /** 34 | * Gets item id of the item unique name. 35 | * 36 | * @param item Item unique name to get for. 37 | * @error Invalid CategoryId. 38 | * 39 | * @return Item id of the item. 40 | */ 41 | public native ItemId GetItemId(const char[] item); 42 | 43 | /** 44 | * Gets category id of the category unique name. 45 | * 46 | * @param category Category unique name to get id for. 47 | * 48 | * @return Category id of the category. 49 | */ 50 | public static native CategoryId GetByUnique(char[] category); 51 | 52 | /** 53 | * Gets the category unique name by its id. 54 | * 55 | * @param buffer Buffer to store the unique name. 56 | * @param maxlength Max length of the buffer. 57 | * @error Invalid CategoryId. 58 | * 59 | * @return True on success, false otherwise. 60 | */ 61 | public native bool GetUniqueName(char[] buffer, int maxlength); 62 | 63 | /** 64 | * Gets the category name by its id. 65 | * 66 | * @param buffer Buffer to store the name. 67 | * @param maxlength Max length of the buffer. 68 | * @error Invalid CategoryId. 69 | * 70 | * @return True on success, false otherwise. 71 | */ 72 | public native bool GetDisplayName(char[] buffer, int maxlength); 73 | 74 | /** 75 | * Toggles all items of category off. 76 | * 77 | * @param client Client index. 78 | * @error Invalid player index. 79 | * @error Invalid CategoryId. 80 | * 81 | * @noreturn 82 | */ 83 | public void ToggleOff(int client) { 84 | Shop_ToggleClientCategoryOff(client, this); 85 | } 86 | 87 | /** 88 | * Whether the category is valid (registered). 89 | * @error Invalid CategoryId. 90 | */ 91 | property bool Exist { 92 | public native get(); 93 | } 94 | } 95 | 96 | methodmap ItemId __nullable__ 97 | { 98 | /** 99 | * Gets an item custom info. 100 | * 101 | * @param info Info key to get. 102 | * @param defaultvalue Optional default value to use if the key is not found. 103 | * @error Invalid ItemId. 104 | * 105 | * @return Integer value of the key. 106 | */ 107 | public native int GetCustomInfo(const char[] info, int defaultvalue = 0); 108 | 109 | /** 110 | * Sets an item custom info. 111 | * 112 | * @param info Info key to set. 113 | * @param value Value to set. 114 | * @error Invalid ItemId. 115 | * 116 | * @return true on success, false otherwise. 117 | */ 118 | public native void SetCustomInfo(const char[] info, int value); 119 | 120 | /** 121 | * Gets an item custom info. 122 | * 123 | * @param info Info key to get. 124 | * @param defaultvalue Optional default value to use if the key is not found. 125 | * @error Invalid ItemId. 126 | * 127 | * @return Float value of the key. 128 | */ 129 | public native float GetCustomInfoFloat(const char[] info, float defaultvalue = 0.0); 130 | 131 | /** 132 | * Sets an item custom info. 133 | * 134 | * @param info Info key to set. 135 | * @param value Value to set. 136 | * @error Invalid ItemId. 137 | * 138 | * @return true on success, false otherwise. 139 | */ 140 | public native void SetCustomInfoFloat(const char[] info, float value); 141 | 142 | /** 143 | * Gets an item custom info. 144 | * 145 | * @param info Info key to get. 146 | * @param buffer Buffer to store the value in. 147 | * @param maxlength Max length of the buffer. 148 | * @param defaultvalue Optional default value to use if the key is not found. 149 | * @error Invalid ItemId. 150 | * 151 | * @return Number of bytes written. 152 | */ 153 | public native int GetCustomInfoString(const char[] info, char[] buffer, int maxlength, const char[] defaultvalue = ""); 154 | 155 | /** 156 | * Sets an item custom info. 157 | * 158 | * @param info Info key to set. 159 | * @param value Value to set. 160 | * @error Invalid ItemId. 161 | * 162 | * @return true on success, false otherwise. 163 | */ 164 | public native void SetCustomInfoString(const char[] info, const char[] value); 165 | 166 | /** 167 | * Copies SubKeys of a KeyValue structure to the item info. 168 | * 169 | * @param kv KeyValue structure to copy. 170 | * @error Invalid ItemId. 171 | * @error Invalid KeyValues Handle. 172 | * 173 | * @return true on success, false otherwise. 174 | */ 175 | public native bool KvCopyCustomInfo(KeyValues kv); 176 | 177 | /** 178 | * Gets the item unique name by its id. 179 | * 180 | * @param buffer Buffer to store the unique name. 181 | * @param maxlength Max length of the buffer. 182 | * @error Invalid ItemId. 183 | * 184 | * @return Number of bytes written. 185 | */ 186 | public native int GetUniqueName(char[] buffer, int maxlength); 187 | 188 | /** 189 | * Get name of item. 190 | * 191 | * @param buffer Buffer to store the name. 192 | * @param maxlength Max length of the buffer. 193 | * @error Invalid ItemId. 194 | * 195 | * @return Number of bytes written. 196 | */ 197 | public native int GetDisplayName(char[] buffer, int maxlength); 198 | 199 | /** 200 | * Formats item display name to use in menu. 201 | * 202 | * @param client Client index to get format for. 203 | * @param menu Menu to get formatted for. 204 | * @param buffer Buffer to store the result in. 205 | * @param maxlength Max length of the buffer. 206 | * @error Invalid player index. 207 | * @error Item has no callbacks. 208 | * @error Invalid ItemId. 209 | * 210 | * @return True if item formatted, false if param menu is Menu_Inventory and the player has not this item and the item is not formatted. 211 | */ 212 | public bool Format(int client, ShopMenu menu, char[] buffer, int maxlength) { 213 | return Shop_FormatItem(client, this, menu, buffer, maxlength); 214 | } 215 | 216 | /** 217 | * Gives the item from the player's inventory. 218 | * 219 | * @param client Client index. 220 | * @param value Count if the item is finite and duration if the item is togglable or non-togglable. 221 | * @error Invalid player index. 222 | * @error Invalid ItemId. 223 | * 224 | * @return True on success, false otherwise. 225 | */ 226 | public bool Give(int client, int value = 1) { 227 | return Shop_GiveClientItem(client, this, value); 228 | } 229 | 230 | /** 231 | * Forces the player to buy the item from the shop. 232 | * 233 | * @param client Client index. 234 | * @error Invalid player index. 235 | * 236 | * @return True if the player successfully bought, false otherwise. 237 | */ 238 | public bool Buy(int client) { 239 | return Shop_BuyClientItem(client, this); 240 | } 241 | 242 | /** 243 | * Forces the player to sell the item from the inventory. 244 | * 245 | * @param client Client index. 246 | * @error Invalid player index. 247 | * @error Invalid ItemId. 248 | * 249 | * @return True if the player successfully sold, false otherwise. 250 | */ 251 | public bool Sell(int client) { 252 | return Shop_SellClientItem(client, this); 253 | } 254 | 255 | /** 256 | * Forces a player to use an item. 257 | * 258 | * @param client Client index to force to. 259 | * @error Invalid player index. 260 | * @error Invalid ItemId. 261 | * 262 | * @return true on success and false otherwise. 263 | */ 264 | public bool Use(int client) { 265 | return Shop_UseClientItem(client, this); 266 | } 267 | 268 | /** 269 | * Remove the item from the player's inventory. 270 | * 271 | * @param client Client index. 272 | * @param count Number of count to remove. 273 | * @error Invalid player index. 274 | * @error Invalid ItemId. 275 | * 276 | * @return True on success, false otherwise. 277 | */ 278 | public bool Remove(int client, int count = 0) { 279 | return Shop_RemoveClientItem(client, this, count); 280 | } 281 | 282 | /** 283 | * Get's count of an item a player has. 284 | * 285 | * @param client Client index. 286 | * @error Invalid player index. 287 | * @error Invalid ItemId. 288 | * 289 | * @return Amount of item that player has. 290 | */ 291 | public int GetCount(int client) { 292 | return Shop_GetClientItemCount(client, this); 293 | } 294 | 295 | /** 296 | * Set count of an item a player has. 297 | * 298 | * @param client Client index. 299 | * @error Invalid player index. 300 | * @error Invalid ItemId. 301 | * 302 | * @noreturn 303 | */ 304 | public void SetCount(int client, int count = 0) { 305 | Shop_SetClientItemCount(client, this, count); 306 | } 307 | 308 | /** 309 | * Sets timeleft for an item. 0 to set no timelimit. 310 | * 311 | * @param client Client index to set to. 312 | * @param timeleft Timeleft to set. 0 to make it forever. 313 | * @param reset_duration Reset duration. 314 | * @error Invalid player index. 315 | * @error Invalid ItemId. 316 | * 317 | * @return True on success and false it client has not this item. 318 | */ 319 | public bool SetTimeLeft(int client, int timeleft, bool reset_duration = true) { 320 | return Shop_SetClientItemTimeleft(client, this, timeleft, reset_duration); 321 | } 322 | 323 | /** 324 | * Gets timeleft for an item. 325 | * 326 | * @param client Client index to get from. 327 | * @error Invalid player index. 328 | * @error Invalid ItemId. 329 | * 330 | * @return item timeleft in seconds. 0 if item has no timelimit. 331 | */ 332 | public int GetTimeLeft(int client) { 333 | return Shop_GetClientItemTimeleft(client, this); 334 | } 335 | 336 | /** 337 | * Gets an absolute sell price for an item a player hold. 338 | * 339 | * @param client Client index to get from. 340 | * @param isGold True to retrieve gold value, false to get credits. 341 | * @error Invalid player index. 342 | * @error Invalid ItemId. 343 | * 344 | * @return sell price of the item. 345 | */ 346 | public int GetSellPrice(int client, bool isGold = false) { 347 | return Shop_GetClientItemSellPrice(client, this, isGold); 348 | } 349 | 350 | /** 351 | * Whether a player has toggled on an item. 352 | * 353 | * @param client Client index to check to. 354 | * @error Invalid player index. 355 | * @error Invalid ItemId. 356 | * 357 | * @return true if player has item toggled on and false otherwise. 358 | */ 359 | public bool IsToggled(int client) { 360 | return Shop_IsClientItemToggled(client, this); 361 | } 362 | 363 | /** 364 | * Whether a player has an item. 365 | * 366 | * @param client Client index to check to. 367 | * @error Invalid player index. 368 | * @error Invalid ItemId. 369 | * 370 | * @return true if player has item and false otherwise. 371 | */ 372 | public bool IsHas(int client) { 373 | return Shop_IsClientHasItem(client, this); 374 | } 375 | 376 | /** 377 | * Toggles a client's item. 378 | * 379 | * @param client Client index. 380 | * @param toggle Toggle state. See ToggleState enum. 381 | * @error Invalid player index. 382 | * @error Invalid ItemId. 383 | * 384 | * @return true on success and false otherwise. 385 | */ 386 | public bool Toggle(int client, ToggleState toggle = Toggle) { 387 | return Shop_ToggleClientItem(client, this, toggle); 388 | } 389 | 390 | /** 391 | * Gets the item's category id. 392 | * @error Invalid ItemId. 393 | */ 394 | property CategoryId CategoryId { 395 | public native get(); 396 | } 397 | 398 | /** 399 | * Get or set an item credits price. 400 | * @error Invalid ItemId. 401 | */ 402 | property int Price { 403 | public native get(); 404 | public native set(int value); 405 | } 406 | 407 | /** 408 | * Get or set an item credits sell price. 409 | * @error Invalid ItemId. 410 | */ 411 | property int SellPrice { 412 | public native get(); 413 | public native set(int value); 414 | } 415 | 416 | /** 417 | * Get or set an item count if item is finite. 418 | * And duration if item is togglable or non-togglable (-1 if duration is unlimited). 419 | * @error Invalid ItemId. 420 | */ 421 | property int Value { 422 | public native get(); 423 | public native set(int value); 424 | } 425 | 426 | /** 427 | * Get or set an item luck chance (0-100). 428 | * @error Invalid ItemId. 429 | */ 430 | property int LuckChange { 431 | public native get(); 432 | public native set(int value); 433 | } 434 | 435 | /** 436 | * Get or set feature "Hide". 437 | * @error Invalid ItemId. 438 | */ 439 | property bool Hide { 440 | public native get(); 441 | public native set(bool value); 442 | } 443 | 444 | /** 445 | * Gets the item type. See ItemType enumeration. 446 | * @error Invalid ItemId. 447 | */ 448 | property ItemType Type { 449 | public native get(); 450 | } 451 | 452 | /** 453 | * Whether the item is exists (registered). 454 | * @error Invalid ItemId. 455 | */ 456 | property bool Exist { 457 | public native get(); 458 | } 459 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/players.inc: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Called when the plugin has loaded the player's data. 4 | * 5 | * @param client Client index. 6 | * 7 | * @noreturn 8 | */ 9 | forward void Shop_OnAuthorized(int client); 10 | 11 | /** 12 | * Called when a menu is being titled. 13 | * 14 | * @param client Client index to whom a menu is being titled. 15 | * @param menu_action Menu that is being titled. 16 | * @param title Current title is being set. 17 | * @param buffer New title to set. 18 | * @param maxlength Maxlength of the title. 19 | * 20 | * @return true to apply new value and false to ignore. 21 | */ 22 | forward bool Shop_OnMenuTitle(int client, ShopMenu menu_action, const char[] title, char[] buffer, int maxlength); 23 | 24 | /** 25 | * Called when credits are being sent to a player. 26 | * 27 | * @param client Client index who is sending credits. 28 | * @param target Client index to whom credits being sent. 29 | * @param amount_give Amount of credits being given to a target player. By reference. 30 | * @param amount_remove Amount of credits being taken from performing player. 31 | * @param amount_commission Amount of credits the commission was set. By reference. 32 | * @param bPercent Whether the commission was set by the percent By reference. 33 | * 34 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 35 | */ 36 | forward Action Shop_OnCreditsTransfer(int client, int target, int &amount_give, int &amount_remove, int &amount_commission, bool bPercent); 37 | 38 | /** 39 | * Called when credits has been sent to a player. 40 | * 41 | * @param client Client index who sent credits. 42 | * @param target Client index to whom credits were sent. 43 | * @param amount_give Amount of credits has been given to a target player. 44 | * @param amount_remove Amount of credits has been taken from a performing player. 45 | * @param amount_commission Amount of credits the commission was set. 46 | * 47 | * @noreturn 48 | */ 49 | forward void Shop_OnCreditsTransfered(int client, int target, int amount_give, int amount_remove, int amount_commission); 50 | 51 | /** 52 | * Called when a player is being set credits to. 53 | * 54 | * @param client Client index who is being set to. 55 | * @param credits Amount of credits a client is being set to. By reference. 56 | * @param by_who See CREDITS_BY_* definitions for more info and any higher value is the admin index. 57 | * 58 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 59 | */ 60 | forward Action Shop_OnCreditsSet(int client, int &credits, int by_who); 61 | 62 | /** 63 | * Called when a player has been set credits. 64 | * 65 | * @param client Client index who is been set. 66 | * @param credits Amount of credits a client is been set. 67 | * @param by_who See CREDITS_BY_* definitions for more info and any higher value is the admin index. 68 | * 69 | * @noreturn 70 | */ 71 | forward void Shop_OnCreditsSet_Post(int client, int credits, int by_who); 72 | 73 | /** 74 | * Called when a player is being given credits to. 75 | * 76 | * @param client Client index who is being given to. 77 | * @param credits Amount of credits a client is being given to. By reference. 78 | * @param by_who See CREDITS_BY_* definitions for more info and any higher values is the admin index. 79 | * 80 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 81 | */ 82 | forward Action Shop_OnCreditsGiven(int client, int &credits, int by_who); 83 | 84 | /** 85 | * Called when a player has been given credits. 86 | * 87 | * @param client Client index who is been given. 88 | * @param credits Amount of credits a client is been given. 89 | * @param by_who See CREDITS_BY_* definitions for more info and any higher values is the admin index. 90 | * 91 | * @noreturn 92 | */ 93 | forward void Shop_OnCreditsGiven_Post(int client, int credits, int by_who); 94 | 95 | /** 96 | * Called when a player is being taken credits from. 97 | * 98 | * @param client Client index who is being taken from. 99 | * @param credits Amount of credits a client is being taken for. By reference. 100 | * @param by_who See CREDITS_BY_* definitions for more info and any higher value is the admin index. 101 | * 102 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 103 | */ 104 | forward Action Shop_OnCreditsTaken(int client, int &credits, int by_who); 105 | 106 | /** 107 | * Called when a player has been taken credits. 108 | * 109 | * @param client Client index who is been taken. 110 | * @param credits Amount of credits a client is been taken. 111 | * @param by_who See CREDITS_BY_* definitions for more info and any higher value is the admin index. 112 | * 113 | * @noreturn 114 | */ 115 | forward void Shop_OnCreditsTaken_Post(int client, int credits, int by_who); 116 | 117 | /** 118 | * Called when a player is being set gold to. 119 | * 120 | * @param client Client index who is being set to. 121 | * @param amount Amount of gold a client is being set to. By reference. 122 | * @param by_who See CREDITS_BY_* definitions for more info and any higher value is the admin index. 123 | * 124 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 125 | */ 126 | forward Action Shop_OnGoldSet(int client, int &amount, int by_who); 127 | 128 | /** 129 | * Called when a player is being given gold to. 130 | * 131 | * @param client Client index who is being given to. 132 | * @param amount Amount of gold a client is being given to. By reference. 133 | * @param by_who See CREDITS_BY_* definitions for more info and any higher values is the admin index. 134 | * 135 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 136 | */ 137 | forward Action Shop_OnGoldGiven(int client, int &amount, int by_who); 138 | 139 | /** 140 | * Called when a player is being taken gold from. 141 | * 142 | * @param client Client index who is being taken from. 143 | * @param amount Amount of gold a client is being taken for. By reference. 144 | * @param by_who See CREDITS_BY_* definitions for more info and any higher value is the admin index. 145 | * 146 | * @return Plugin_Changed to apply new values. >= Plugin_Handled to block. 147 | */ 148 | forward Action Shop_OnGoldTaken(int client, int &amount, int by_who); 149 | 150 | /** 151 | * Called when a player is trying to try a luck. 152 | * 153 | * @param client Client index who is perfroming. 154 | * 155 | * @return true to allow performing and false to block. 156 | */ 157 | forward bool Shop_OnClientLuckProcess(int client); 158 | 159 | /** 160 | * Called when a player is nearly to win an item. 161 | * -. 162 | * @param client client index. 163 | * @param item_id Item id. 164 | * @param luck_chance luck chance (by reference) 165 | * -. 166 | * @return Plugin_Changed to apply custom changes. >= Plugin_Handled to block, Plugin_Continue - to proceed without changes. 167 | */ 168 | forward Action Shop_OnClientShouldLuckItemChance(int client, ItemId item_id, int &luck_chance); 169 | 170 | /** 171 | * Called when a player has won an item. 172 | * 173 | * @param client Client index who has won. 174 | * @param item_id Item id of the item. 175 | * 176 | * @noreturn 177 | */ 178 | forward void Shop_OnClientItemLucked(int client, ItemId item_id); 179 | 180 | /** 181 | * Gets a player's id for the database. 182 | * 183 | * @param client Client index to get for. 184 | * @error Invalid player index. 185 | * 186 | * @return player id in the database or 0 if client doesn't in database. 187 | */ 188 | native int Shop_GetClientId(int client); 189 | 190 | /** 191 | * Sets timeleft for an item. 0 to set no timelimit. 192 | * 193 | * @param client Client index to set to. 194 | * @param item_id Item id to set for. 195 | * @param timeleft Timeleft to set. 0 to make it forever. 196 | * @param reset_duration Reset duration. 197 | * @error Invalid player index. 198 | * @error Invalid ItemId. 199 | * 200 | * @return True on success and false it client has not this item. 201 | */ 202 | native bool Shop_SetClientItemTimeleft(int client, ItemId item_id, int timeleft, bool reset_duration = true); 203 | 204 | /** 205 | * Gets timeleft for an item. 206 | * 207 | * @param client Client index to get from. 208 | * @param item_id Item id to get for. 209 | * @error Invalid player index. 210 | * @error Invalid ItemId. 211 | * 212 | * @return item timeleft in seconds. 0 if item has no timelimit. 213 | */ 214 | native int Shop_GetClientItemTimeleft(int client, ItemId item_id); 215 | 216 | /** 217 | * Gets an absolute sell price for an item a player hold. 218 | * 219 | * @param client Client index to get from. 220 | * @param item_id Item id to get for. 221 | * @param isGold True to retrieve gold value, false to get credits. 222 | * @error Invalid player index. 223 | * @error Invalid ItemId. 224 | * 225 | * @return sell price of the item. 226 | */ 227 | native int Shop_GetClientItemSellPrice(int client, ItemId item_id, bool isGold = false); 228 | 229 | /** 230 | * Whether a player has toggled on an item. 231 | * 232 | * @param client Client index to check to. 233 | * @param item_id Item id to check. 234 | * @error Invalid player index. 235 | * @error Invalid ItemId. 236 | * 237 | * @return true if player has item toggled on and false otherwise. 238 | */ 239 | native bool Shop_IsClientItemToggled(int client, ItemId item_id); 240 | 241 | /** 242 | * Whether a player has an item. 243 | * 244 | * @param client Client index to check to. 245 | * @param item_id Item id to check. 246 | * @error Invalid player index. 247 | * @error Invalid ItemId. 248 | * 249 | * @return true if player has item and false otherwise. 250 | */ 251 | native bool Shop_IsClientHasItem(int client, ItemId item_id); 252 | 253 | /** 254 | * Toggles a client's item. 255 | * 256 | * @param client Client index. 257 | * @param item_id Item id to toggle. 258 | * @param toggle Toggle state. See ToggleState enum. 259 | * @error Invalid player index. 260 | * @error Invalid ItemId. 261 | * 262 | * @return true on success and false otherwise. 263 | */ 264 | native bool Shop_ToggleClientItem(int client, ItemId item_id, ToggleState toggle = Toggle); 265 | 266 | /** 267 | * Toggles all items of category off. 268 | * 269 | * @param client Client index. 270 | * @param category_id The category id. 271 | * @error Invalid player index. 272 | * @error Invalid CategoryId. 273 | * 274 | * @noreturn 275 | */ 276 | native void Shop_ToggleClientCategoryOff(int client, CategoryId category_id); 277 | 278 | /** 279 | * Checks whether the player has been loaded from database. 280 | * 281 | * @param client Client index to check. 282 | * @error Invalid player index. 283 | * 284 | @return True if the player loaded, false otherwise. 285 | */ 286 | native bool Shop_IsAuthorized(int client); 287 | 288 | /** 289 | * Checks whether a player has access to admin panel. 290 | * 291 | * @param client Client index to check. 292 | * @error Invalid player index. 293 | * 294 | @return True if the player has access, false otherwise. 295 | */ 296 | native bool Shop_IsAdmin(int client); 297 | 298 | /** 299 | * Gives certain amount of credits to the player. 300 | * 301 | * @param client Client index. 302 | * @param amount Amount to give. 303 | * @param by_who Optional param to set by who the credits being given from. 304 | * @error Invalid player index. 305 | * 306 | * @return New amount of credits. 307 | */ 308 | native int Shop_GiveClientCredits(int client, int amount, int by_who = CREDITS_BY_NATIVE); 309 | 310 | /** 311 | * Takes certain amount of credits from the player. 312 | * 313 | * @param client Client index. 314 | * @param amount Amount to take. 315 | * @param by_who Optional param to set by who the credits being given from. 316 | * @error Invalid player index. 317 | * 318 | * @return New amount of credits. 319 | */ 320 | native int Shop_TakeClientCredits(int client, int amount, int by_who = CREDITS_BY_NATIVE); 321 | 322 | /** 323 | * Gets the amount of credits of the player. 324 | * 325 | * @param client Client index. 326 | * @error Invalid player index. 327 | * 328 | * @return Amount of credits a player has, -1 on failure. 329 | */ 330 | native int Shop_GetClientCredits(int client); 331 | 332 | /** 333 | * Sets the amount of credits to the player. 334 | * 335 | * @param client Client index. 336 | * @param credits Amount of credits to set. 337 | * @error Invalid player index. 338 | * 339 | * @noreturn 340 | */ 341 | native void Shop_SetClientCredits(int client, int credits); 342 | 343 | /** 344 | * Gives certain amount of gold to the player. 345 | * 346 | * @param client Client index. 347 | * @param amount Amount to give. 348 | * @param by_who Optional param to set by who the gold being given from. 349 | * @error Invalid player index. 350 | * 351 | * @return New amount of gold. 352 | */ 353 | native int Shop_GiveClientGold(int client, int amount, int by_who = CREDITS_BY_NATIVE); 354 | 355 | /** 356 | * Takes certain amount of gold from the player. 357 | * 358 | * @param client Client index. 359 | * @param amount Amount to take. 360 | * @param by_who Optional param to set by who the gold being given from. 361 | * @error Invalid player index. 362 | * 363 | * @return New amount of gold. 364 | */ 365 | native int Shop_TakeClientGold(int client, int amount, int by_who = CREDITS_BY_NATIVE); 366 | 367 | /** 368 | * Gets the amount of gold of the player. 369 | * 370 | * @param client Client index. 371 | * @error Invalid player index. 372 | * 373 | * @return Amount of gold a player has, -1 on failure. 374 | */ 375 | native int Shop_GetClientGold(int client); 376 | 377 | /** 378 | * Sets the amount of gold to the player. 379 | * 380 | * @param client Client index. 381 | * @param amount Amount of gold to set. 382 | * @error Invalid player index. 383 | * 384 | * @noreturn 385 | */ 386 | native void Shop_SetClientGold(int client, int amount); 387 | 388 | /** 389 | * Forces the player to buy the item from the shop. 390 | * 391 | * @param client Client index. 392 | * @param item_id The item id. 393 | * @error Invalid player index. 394 | * 395 | * @return True if the player successfully bought, false otherwise. 396 | */ 397 | native bool Shop_BuyClientItem(int client, ItemId item_id); 398 | 399 | /** 400 | * Forces the player to sell the item from the inventory. 401 | * 402 | * @param client Client index. 403 | * @param item_id The item id. 404 | * @error Invalid player index. 405 | * @error Invalid ItemId. 406 | * 407 | * @return True if the player successfully sold, false otherwise. 408 | */ 409 | native bool Shop_SellClientItem(int client, ItemId item_id); 410 | 411 | /** 412 | * Remove the item from the player's inventory. 413 | * 414 | * @param client Client index. 415 | * @param item_id The item id. 416 | * @param count Number of count to remove. 417 | * @error Invalid player index. 418 | * @error Invalid ItemId. 419 | * 420 | * @return True on success, false otherwise. 421 | */ 422 | native bool Shop_RemoveClientItem(int client, ItemId item_id, int count = 0); 423 | 424 | /** 425 | * Gives the item from the player's inventory. 426 | * 427 | * @param client Client index. 428 | * @param item_id The item id. 429 | * @param value Count if the item is finite and duration if the item is togglable or non-togglable, -1 eternal 430 | * @error Invalid player index. 431 | * @error Invalid ItemId. 432 | * 433 | * @return True on success, false otherwise. 434 | */ 435 | native bool Shop_GiveClientItem(int client, ItemId item_id, int value = 0); 436 | 437 | /** 438 | * Get's count of an item a player has. 439 | * 440 | * @param client Client index. 441 | * @param item_id The item id. 442 | * @error Invalid player index. 443 | * @error Invalid ItemId. 444 | * 445 | * @return Amount of item that player has. 446 | */ 447 | native int Shop_GetClientItemCount(int client, ItemId item_id); 448 | 449 | /** 450 | * Set count of an item a player has. 451 | * 452 | * @param client Client index. 453 | * @param item_id The item id. 454 | * @error Invalid player index. 455 | * @error Invalid ItemId. 456 | * 457 | * @noreturn 458 | */ 459 | native void Shop_SetClientItemCount(int client, ItemId item_id, int count = 0); 460 | 461 | /** 462 | * Forces a player to use an item. 463 | * 464 | * @param client Client index to force to. 465 | * @param item_id Item id to force for. 466 | * @error Invalid player index. 467 | * @error Invalid ItemId. 468 | * 469 | * @return true on success and false otherwise. 470 | */ 471 | native bool Shop_UseClientItem(int client, ItemId item_id); 472 | 473 | /** 474 | * Returns the array with player item ids. 475 | * @note You must close the Handle yourself. 476 | * @note If player has not items - array returned too, but empty. 477 | * 478 | * @param client Client index. 479 | * @error Invalid player index. 480 | * 481 | * @return ArrayList handle with item ids. 482 | */ 483 | native ArrayList Shop_GetClientItems(int client); 484 | 485 | /** 486 | * Shows a player an item's panel. 487 | * 488 | * @param client Client index. 489 | * @param item_id Item id of the item. 490 | * @error Invalid player index. 491 | * @error Invalid ItemId. 492 | * 493 | * @return true if a panel has been shown, false otherwise. 494 | */ 495 | native bool Shop_ShowItemPanel(int client, ItemId item_id); 496 | 497 | /** 498 | * Opens main menu for a player. 499 | * 500 | * @param client Client index. 501 | * @error Invalid player index. 502 | * 503 | * @noreturn 504 | */ 505 | native void Shop_OpenMainMenu(int client); 506 | 507 | /** 508 | * Shows a player categories of the shop. 509 | * 510 | * @param client Client index. 511 | * @error Invalid player index. 512 | * 513 | * @return true if categories has been shown, false otherwise. 514 | */ 515 | native bool Shop_ShowCategory(int client); 516 | 517 | /** 518 | * Shows a player his inventory. 519 | * 520 | * @param client Client index. 521 | * @error Invalid player index. 522 | * 523 | * @return true if the inventory has been shown, false otherwise. 524 | */ 525 | native bool Shop_ShowInventory(int client); 526 | 527 | /** 528 | * Shows a player items of a category. 529 | * 530 | * @param client Client index. 531 | * @param category_id Category id to show. 532 | * @param inventory To show items of his inventory. 533 | * @error Invalid player index. 534 | * @error Invalid CategoryId. 535 | * 536 | * @return true if the items has been shown, false otherwise. 537 | */ 538 | native bool Shop_ShowItemsOfCategory(int client, CategoryId category_id, bool inventory = false); 539 | 540 | /** 541 | * Shows functions menu to a player. 542 | * 543 | * @param client Client index to show to. 544 | * @error Invalid player index. 545 | * 546 | * @noreturn 547 | */ 548 | native void Shop_ShowFunctionsMenu(int client); -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/shop/register.inc: -------------------------------------------------------------------------------- 1 | /** 2 | * Callback before the player is shown the category name in the menu. 3 | * 4 | * @param client Client index. 5 | * @param category_id Category id of an item. 6 | * @param category Category unique name. 7 | * @param name Current display name. 8 | * @param buffer Buffer for new name. 9 | * @param maxlen Maximum buffer length. 10 | * @param menu Menu performing this action. 11 | * 12 | * @return true - apply new display name, false otherwise. 13 | */ 14 | typedef Shop_CategoryDisplayCallback = function bool (int client, CategoryId category_id, const char[] category, const char[] name, char[] buffer, int maxlen, ShopMenu menu); 15 | 16 | /** 17 | * Callback before showing the player the category description in the menu. 18 | * 19 | * @param client Client index. 20 | * @param category_id Category id of an item. 21 | * @param category Category unique name. 22 | * @param description The current description. 23 | * @param buffer Buffer for new description. 24 | * @param maxlen Maximum buffer length. 25 | * @param menu Menu performing this action. 26 | * 27 | * @return true - apply new description, false otherwise. 28 | */ 29 | typedef Shop_CategoryDescriptionCallback = function bool (int client, CategoryId category_id, const char[] category, const char[] description, char[] buffer, int maxlen, ShopMenu menu); 30 | 31 | /** 32 | * Callback before a category is shown to the player in the menu. 33 | * 34 | * @param client Client index. 35 | * @param category_id Category id of an item. 36 | * @param category Category unique name. 37 | * @param menu Menu performing this action. 38 | * 39 | * @return true - show on the menu, false otherwise. 40 | */ 41 | typedef Shop_CategoryShouldDisplayCallback = function bool (int client, CategoryId category_id, const char[] category, ShopMenu menu); 42 | 43 | /** 44 | * Callback before the player selects a category from the menu. 45 | * 46 | * @param client Client index. 47 | * @param category_id Category id of an item. 48 | * @param category Category unique name. 49 | * @param menu Menu performing this action. 50 | * 51 | * @return false - cancel selection, true otherwise. 52 | */ 53 | typedef Shop_CategorySelectCallback = function bool (int client, CategoryId category_id, const char[] category, ShopMenu menu); 54 | 55 | typeset Shop_ItemUseToggleCallback 56 | { 57 | /** 58 | * Callback when an item is used. 59 | * 60 | * @param client Client index. 61 | * @param category_id Category id of an item. 62 | * @param category Category unique name. 63 | * @param item_id Item id of an item. 64 | * @param item Item's unique name. 65 | * 66 | * @return see ShopAction enum. 67 | */ 68 | function ShopAction (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item); 69 | 70 | /** 71 | * Callback when item is toggled. 72 | * 73 | * @param client Client index. 74 | * @param category_id Category id of an item. 75 | * @param category Category unique name. 76 | * @param item_id Item id of an item. 77 | * @param item Item's unique name. 78 | * @param isOn Item state. 79 | * @param elapsed Item elapsed. 80 | * 81 | * @return see ShopAction enum. 82 | */ 83 | function ShopAction (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, bool isOn, bool elapsed); 84 | } 85 | 86 | /** 87 | * Callback to get ItemId. 88 | * 89 | * @param category_id Category id of an item. 90 | * @param category Category unique name. 91 | * @param item_id Item id of an item. 92 | * @param item Item's unique name. 93 | * 94 | * @noreturn 95 | */ 96 | typedef Shop_ItemRegister = function void (CategoryId category_id, const char[] category, const char[] item, ItemId item_id); 97 | 98 | /** 99 | * Callback to display a preview of the element for the player or the element has elapsed. 100 | * 101 | * @param client Client index. 102 | * @param category_id Category id of an item. 103 | * @param category Category unique name. 104 | * @param item_id Item id of an item. 105 | * @param item Item's unique name. 106 | * 107 | * @noreturn 108 | */ 109 | typedef Shop_ItemCommon = function void(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item); 110 | 111 | /** 112 | * Callback before an item is shown to the player in the menu. 113 | * 114 | * @param client Client index. 115 | * @param category_id Category id of an item. 116 | * @param category Category unique name. 117 | * @param item_id Item id of an item. 118 | * @param item Item's unique name. 119 | * @param menu Menu performing this action. 120 | * 121 | * @return true - show on the menu, false otherwise. 122 | */ 123 | typedef Shop_ItemShouldDisplayCallback = function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ShopMenu menu); 124 | 125 | /** 126 | * Callback before the player is shown the item's name in the menu. 127 | * 128 | * @param client Client index. 129 | * @param category_id Category id of an item. 130 | * @param category Category unique name. 131 | * @param item_id Item id of an item. 132 | * @param item Item's unique name. 133 | * @param menu Menu performing this action. 134 | * @param disabled True - make this item not selectable in the menu (ITEMDRAW_DISABLED), false by default. 135 | * @param name Current display name. 136 | * @param buffer Buffer for new name. 137 | * @param maxlen Maximum buffer length. 138 | * 139 | * @return true - apply new display name, false otherwise. 140 | */ 141 | typedef Shop_ItemDisplayCallback = function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ShopMenu menu, bool &disabled, const char[] name, char[] buffer, int maxlen); 142 | 143 | /** 144 | * Callback before showing the player the description of the item in the menu. 145 | * 146 | * @param client Client index. 147 | * @param category_id Category id of an item. 148 | * @param category Category unique name. 149 | * @param item_id Item id of an item. 150 | * @param item Item's unique name. 151 | * @param menu Menu performing this action. 152 | * @param description The current description. 153 | * @param buffer Buffer for new description. 154 | * @param maxlen Maximum buffer length. 155 | * 156 | * @return true - apply new description, false otherwise. 157 | */ 158 | typedef Shop_ItemDescriptionCallback = function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ShopMenu menu, const char[] description, char[] buffer, int maxlen); 159 | 160 | /** 161 | * Callback before the player selects an item from the menu. 162 | * 163 | * @param client Client index. 164 | * @param category_id Category id of an item. 165 | * @param category Category unique name. 166 | * @param item_id Item id of an item. 167 | * @param item Item's unique name. 168 | * @param menu Menu performing this action. 169 | * 170 | * @return false - cancel selection, true otherwise. 171 | */ 172 | typedef Shop_ItemSelectCallBack = function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ShopMenu menu); 173 | 174 | typeset Shop_ItemBuyCallback 175 | { 176 | /** 177 | * Callback before a player buys an item. 178 | * 179 | * @param client Client index. 180 | * @param category_id Category id of an item. 181 | * @param category Category unique name. 182 | * @param item_id Item id of an item. 183 | * @param item Item's unique name. 184 | * @param type Item type. See ItemType enum. 185 | * @param price Item price. Can not be lower than sell_price. 186 | * @param sell_price Item sell price. 0 - free, -1 - not purchasable. 187 | * @param value Quantity - if it's an Item_Finite, duration - if it's an Item_Togglable. 188 | * 189 | * @return true - allow the purchase, false - otherwise. 190 | */ 191 | function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int price, int sell_price, int value); 192 | 193 | /** 194 | * Callback before a player buys an item (with gold). 195 | * 196 | * @param client Client index. 197 | * @param category_id Category id of an item. 198 | * @param category Category unique name. 199 | * @param item_id Item id of an item. 200 | * @param item Item's unique name. 201 | * @param type Item type. See ItemType enum. 202 | * @param price Item price. Can not be lower than sell_price. 203 | * @param sell_price Item sell price. 0 - free, -1 - not purchasable. 204 | * @param value Quantity - if it's an Item_Finite, duration - if it's an Item_Togglable. 205 | * @param gold_price Item price. -1 - not sold for gold. 206 | * @param gold_sell_price Item sell price in Gold. 0 - free, -1 - not purchasable with gold. 207 | * 208 | * @return true - allow the purchase, false - otherwise. 209 | */ 210 | function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int price, int sell_price, int value, int gold_price, int gold_sell_price); 211 | } 212 | 213 | typeset Shop_ItemSellCallback 214 | { 215 | /** 216 | * Callback before a player sells an item. 217 | * 218 | * @param client Client index. 219 | * @param category_id Category id of an item. 220 | * @param category Category unique name. 221 | * @param item_id Item id of an item. 222 | * @param item Item's unique name. 223 | * @param type Item type. See ItemType enum. 224 | * @param sell_price Item sell price. 0 to make item free and -1 to make it unsaleable by credits. Can not be higher than price. 225 | * 226 | * @return true - allow sale, false - otherwise. 227 | */ 228 | function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int sell_price); 229 | 230 | /** 231 | * Callback before a player sells an item (with gold). 232 | * 233 | * @param client Client index. 234 | * @param category_id Category id of an item. 235 | * @param category Category unique name. 236 | * @param item_id Item id of an item. 237 | * @param item Item's unique name. 238 | * @param type Item type. See ItemType enum. 239 | * @param sell_price Item sell price. 0 to make item free and -1 to make it unsaleable by credits. Can not be higher than price. 240 | * @param gold_sell_price Item sell price in Gold. 0 to make item free by gold price and -1 to disable sell by gold. Can not be higher than price. 241 | * 242 | * @return true - allow sale, false - otherwise. 243 | */ 244 | function bool (int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int sell_price, int gold_sell_price); 245 | } 246 | 247 | /** 248 | * Called when category registered at first time. 249 | * That means only once per unique name. 250 | * 251 | * @param category_id CategoryId of category. 252 | * @param name Unique name of category. 253 | * 254 | * @noreturn 255 | */ 256 | forward void Shop_OnCategoryRegistered(CategoryId category_id, const char[] name); 257 | 258 | /** 259 | * Called when item registered at first time. 260 | * That means only once per unique name. 261 | * 262 | * @param category_id CategoryId of category. 263 | * @param category Unique name of category. 264 | * @param item_id ItemId of item. 265 | * @param item Unique name of item. 266 | * 267 | * @noreturn 268 | */ 269 | forward void Shop_OnItemRegistered(CategoryId category_id, const char[] category, ItemId item_id, const char[] item); 270 | 271 | /** 272 | * Registers new category id. 273 | * 274 | * @param category Category unique name. 275 | * @param name Default category display name. 276 | * @param description Default category description. 277 | * @param cat_display Callback called on category being displayed. 278 | * @param cat_desc Callback called on category's description being displayed. 279 | * @param cat_should Callback called whether the category should be displayed to a player. 280 | * @param cat_select Callback called when a player is trying to select the category. 281 | * 282 | * @return Category id of the category. 283 | */ 284 | native CategoryId Shop_RegisterCategory(const char[] category, const char[] name, const char[] description, 285 | Shop_CategoryDisplayCallback cat_display=INVALID_FUNCTION, 286 | Shop_CategoryDescriptionCallback cat_desc=INVALID_FUNCTION, 287 | Shop_CategoryShouldDisplayCallback cat_should=INVALID_FUNCTION, 288 | Shop_CategorySelectCallback cat_select=INVALID_FUNCTION); 289 | 290 | /** 291 | * Starts an item to register. 292 | * 293 | * @param category_id Category id to register an item for. 294 | * @param item Item unique name. 295 | * @error Invalid CategoryId. 296 | * 297 | * @return true to success, false otherwise. 298 | */ 299 | native bool Shop_StartItem(CategoryId category_id, const char[] item); 300 | 301 | /** 302 | * Sets the item information. 303 | * 304 | * @param name Default display name. 305 | * @param description Default description. 306 | * @param price Item price. Can not be lower than sell_price (on gold version can be lower and -1 for disable price by gold) 307 | * @param sell_price Item sell price. 0 to make item free and -1 to make it unsaleable by credits. Can not be higher than price. 308 | * @param type Item type. See ItemType enum. 309 | * @param value Sets count if the item type is finite and sets duration if the item is togglable or non-togglable. 310 | * @param gold_price Item price. Can be -1 to make in unbuyable by gold. 311 | * @param gold_sell_price Item sell price. 0 to make item free by gold price and -1 to disable sell by gold. Can not be higher than price. 312 | * 313 | * @noreturn 314 | */ 315 | native void Shop_SetInfo(const char[] name, const char[] description, int price, int sell_price = -1, ItemType type, int value = 1, int gold_price = -1, int gold_sell_price = -1); 316 | 317 | /** 318 | * Sets the item luck chance. 319 | * 320 | * @param luck_chance Luck chance to set. From 0 to 100. 0 can not be lucked and 100 is always lucked by the general chance set in cvar. Default item chance is 100. 321 | * 322 | * @noreturn 323 | */ 324 | native void Shop_SetLuckChance(int luck_chance); 325 | 326 | /** 327 | * Sets the item callbacks. 328 | * 329 | * @param register Callback called when the item is registered. 330 | * @param use_toggle Callback called when the item is being used. 331 | * @param should Callback called when the item is being displayed. Here you can stop displaying the item. 332 | * @param display Callback called when the item is being displayed. Here you can change item display name. 333 | * @param description Callback called when the item description is being displayed. Here you can change item description. 334 | * @param preview Callback called when the item is previewing. 335 | * @param buy Callback called when the item is being bought. 336 | * @param sell Callback called when the item is being sold. 337 | * @param elapse Callback called when the item is elapsed. 338 | * @param select Callback called when the item is selected in menu. 339 | * 340 | * @noreturn 341 | */ 342 | native void Shop_SetCallbacks(Shop_ItemRegister register=INVALID_FUNCTION, 343 | Shop_ItemUseToggleCallback use_toggle=INVALID_FUNCTION, 344 | Shop_ItemShouldDisplayCallback should=INVALID_FUNCTION, 345 | Shop_ItemDisplayCallback display=INVALID_FUNCTION, 346 | Shop_ItemDescriptionCallback description=INVALID_FUNCTION, 347 | Shop_ItemCommon preview=INVALID_FUNCTION, 348 | Shop_ItemBuyCallback buy=INVALID_FUNCTION, 349 | Shop_ItemSellCallback sell=INVALID_FUNCTION, 350 | Shop_ItemCommon elapse=INVALID_FUNCTION, 351 | Shop_ItemSelectCallBack select=INVALID_FUNCTION); 352 | 353 | /** 354 | * Allows to hide item in buy panel, givable only by native or admin panel. 355 | * 356 | * @param state true - hide, false - show. 357 | * 358 | * @noreturn 359 | */ 360 | native void Shop_SetHide(bool state); 361 | 362 | /** 363 | * Sets item custom info. 364 | * 365 | * @param info Name of the key. 366 | * @param value Value to set. 367 | * 368 | * @noreturn 369 | */ 370 | native void Shop_SetCustomInfo(const char[] info, int value); 371 | 372 | /** 373 | * Sets item custom info. 374 | * 375 | * @param info Name of the key. 376 | * @param value Value to set. 377 | * 378 | * @noreturn 379 | */ 380 | native void Shop_SetCustomInfoFloat(const char[] info, float value); 381 | 382 | /** 383 | * Sets item custom info. 384 | * 385 | * @param info Name of the key. 386 | * @param value Value to set. 387 | * 388 | * @noreturn 389 | */ 390 | native void Shop_SetCustomInfoString(const char[] info, char[] value); 391 | 392 | /** 393 | * Copies sub keys of the given kv structure to the item. 394 | * 395 | * @param info Name of the key. 396 | * @param value Value to set. 397 | * 398 | * @noreturn 399 | */ 400 | native void Shop_KvCopySubKeysCustomInfo(KeyValues kv); 401 | 402 | /** 403 | * Completes the item info structure and start to register. Can not be used before an item has been started to register. 404 | * 405 | * @noparams. 406 | * 407 | * @noreturn 408 | */ 409 | native void Shop_EndItem(); 410 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/admin.sp: -------------------------------------------------------------------------------- 1 | #define GIVE_CREDITS 0 2 | #define TAKE_CREDITS 1 3 | #define SET_CREDITS 2 4 | #define GIVE_ITEMS 3 5 | #define TAKE_ITEMS 4 6 | 7 | enum struct AdminEnum 8 | { 9 | int AdminOption; 10 | int AdminTarget; 11 | int AdminCategory; 12 | } 13 | 14 | AdminEnum g_iOpt[MAXPLAYERS+1]; 15 | 16 | Menu count_menu; 17 | 18 | /** 19 | * For SM 1.10 20 | */ 21 | stock DataPackPos ADMIN_DP_PLUGIN = view_as(0); 22 | stock DataPackPos ADMIN_DP_FUNCDISPLAY = view_as(1); 23 | stock DataPackPos ADMIN_DP_FUNCSELECT = view_as(2); 24 | 25 | ArrayList g_hAdminArray; 26 | 27 | void Admin_CreateNatives() 28 | { 29 | g_hAdminArray = new ArrayList(3); 30 | 31 | CreateNative("Shop_AddToAdminMenu", Admin_AddToMenuNative); 32 | CreateNative("Shop_RemoveFromAdminMenu", Admin_RemoveFromMenuNative); 33 | CreateNative("Shop_ShowAdminMenu", Admin_ShowAdminMenu); 34 | } 35 | 36 | public int Admin_AddToMenuNative(Handle plugin, int numParams) 37 | { 38 | DataPack dp = new DataPack(); 39 | dp.WriteCell(plugin); 40 | dp.WriteFunction(GetNativeFunction(1)); 41 | dp.WriteFunction(GetNativeFunction(2)); 42 | 43 | g_hAdminArray.Push(plugin); 44 | g_hAdminArray.Push(dp); 45 | 46 | return 0; 47 | } 48 | 49 | public int Admin_RemoveFromMenuNative(Handle plugin, int numParams) 50 | { 51 | int index = -1; 52 | DataPack dp; 53 | while ((index = g_hAdminArray.FindValue(plugin)) != -1) 54 | { 55 | dp = g_hAdminArray.Get(index+1); 56 | dp.Position = ADMIN_DP_FUNCDISPLAY; // jump to func display 57 | Function func_disp = dp.ReadFunction(); 58 | Function func_select = dp.ReadFunction(); 59 | if (func_disp == GetNativeFunction(1) && func_select == GetNativeFunction(2)) 60 | { 61 | // double action to delete Handle (plugin) and datapack (plugin, func_disp, func_select) 62 | g_hAdminArray.Erase(index); 63 | g_hAdminArray.Erase(index); 64 | 65 | delete dp; 66 | return true; 67 | } 68 | } 69 | 70 | return false; 71 | } 72 | 73 | public int Admin_ShowAdminMenu(Handle plugin, int numParams) 74 | { 75 | int client = GetNativeCell(1); 76 | 77 | char error[64]; 78 | if (!CheckClient(client, error, sizeof(error))) 79 | ThrowNativeError(SP_ERROR_NATIVE, error); 80 | 81 | Admin_ShowMenu(client); 82 | return 0; 83 | } 84 | 85 | void Admin_UnregisterMe(Handle hPlugin) 86 | { 87 | int index = -1; 88 | while ((index = g_hAdminArray.FindValue(hPlugin)) != -1) 89 | { 90 | delete view_as(g_hAdminArray.Get(index+1)); 91 | 92 | g_hAdminArray.Erase(index); 93 | g_hAdminArray.Erase(index); 94 | } 95 | } 96 | 97 | void Admin_OnSettingsLoad(KeyValues kv) 98 | { 99 | count_menu = new Menu(Admin_MenuCount_Handler, MENU_ACTIONS_DEFAULT|MenuAction_Display); 100 | 101 | if (kv.JumpToKey("Count_Menu", false)) 102 | { 103 | if (kv.GotoFirstSubKey(false)) 104 | { 105 | count_menu.ExitButton = true; 106 | count_menu.ExitBackButton = true; 107 | 108 | char amount[24], buffer[64]; 109 | do 110 | { 111 | if (kv.GetSectionName(amount, sizeof(amount))) 112 | { 113 | kv.GetString(NULL_STRING, buffer, sizeof(buffer)); 114 | if (amount[0] && buffer[0]) 115 | { 116 | count_menu.AddItem(amount, buffer); 117 | } 118 | } 119 | } 120 | while (kv.GotoNextKey(false)); 121 | } 122 | kv.Rewind(); 123 | } 124 | 125 | if (!count_menu.ItemCount) 126 | { 127 | count_menu.AddItem("1", "1 credit"); 128 | count_menu.AddItem("10", "10 credits"); 129 | count_menu.AddItem("100", "Hundred credits"); 130 | count_menu.AddItem("1000", "Thousand credits"); 131 | count_menu.AddItem("10000", "10000 credits"); 132 | count_menu.AddItem("100000", "100000 credits"); 133 | count_menu.AddItem("1000000", "Million credits"); 134 | } 135 | } 136 | 137 | public int Admin_MenuCount_Handler(Menu menu, MenuAction action, int param1, int param2) 138 | { 139 | switch (action) 140 | { 141 | case MenuAction_Display : 142 | { 143 | int target = GetClientOfUserId(g_iOpt[param1].AdminTarget); 144 | 145 | if (!target) 146 | { 147 | return 0; 148 | } 149 | 150 | switch (g_iOpt[param1].AdminOption) 151 | { 152 | case GIVE_CREDITS : 153 | { 154 | menu.SetTitle("%T\n%N (%d)\n ", "give_credits", param1, target, GetCredits(target)); 155 | } 156 | case TAKE_CREDITS : 157 | { 158 | menu.SetTitle("%T\n%N (%d)\n ", "take_credits", param1, target, GetCredits(target)); 159 | } 160 | case SET_CREDITS : 161 | { 162 | menu.SetTitle("%T\n%N (%d)\n ", "set_credits", param1, target, GetCredits(target)); 163 | } 164 | } 165 | } 166 | case MenuAction_Select : 167 | { 168 | int target = GetClientOfUserId(g_iOpt[param1].AdminTarget); 169 | 170 | if (!target) 171 | { 172 | CPrintToChat(param1, "target_left_game"); 173 | Admin_ShowMenu(param1); 174 | return 0; 175 | } 176 | 177 | char info[16]; 178 | menu.GetItem(param2, info, sizeof(info)); 179 | 180 | switch (g_iOpt[param1].AdminOption) 181 | { 182 | case GIVE_CREDITS : 183 | { 184 | GiveCredits(target, StringToInt(info), param1); 185 | Admin_ShowCreditsAmount(param1, GetMenuSelectionPosition()); 186 | } 187 | case TAKE_CREDITS : 188 | { 189 | RemoveCredits(target, StringToInt(info), param1); 190 | Admin_ShowCreditsAmount(param1, GetMenuSelectionPosition()); 191 | } 192 | case SET_CREDITS : 193 | { 194 | SetCredits(target, StringToInt(info), param1); 195 | Admin_ShowMenu(param1); 196 | } 197 | } 198 | } 199 | case MenuAction_Cancel : 200 | { 201 | if (param2 == MenuCancel_ExitBack) 202 | { 203 | Admin_ShowTargetsMenu(param1); 204 | } 205 | } 206 | } 207 | 208 | return 0; 209 | } 210 | 211 | void Admin_ShowMenu(int client, int pos = 0) 212 | { 213 | SetGlobalTransTarget(client); 214 | 215 | Menu menu = new Menu(Admin_Menu_Handler); 216 | 217 | char title[128]; 218 | FormatEx(title, sizeof(title), "%t", "admin_panel"); 219 | OnMenuTitle(client, Menu_AdminPanel, title, title, sizeof(title)); 220 | menu.SetTitle(title); 221 | menu.ExitButton = true; 222 | menu.ExitBackButton = true; 223 | 224 | char buffer[SHOP_MAX_STRING_LENGTH]; 225 | FormatEx(buffer, sizeof(buffer), "%t", "give_credits"); 226 | menu.AddItem("a", buffer); 227 | FormatEx(buffer, sizeof(buffer), "%t", "take_credits"); 228 | menu.AddItem("b", buffer); 229 | FormatEx(buffer, sizeof(buffer), "%t\n ", "set_credits"); 230 | menu.AddItem("c", buffer); 231 | FormatEx(buffer, sizeof(buffer), "%t", "give_items"); 232 | menu.AddItem("d", buffer); 233 | FormatEx(buffer, sizeof(buffer), "%t", "take_items"); 234 | menu.AddItem("e", buffer); 235 | 236 | int size = g_hAdminArray.Length; 237 | 238 | if (size > 0) 239 | { 240 | DataPack dp; 241 | char id[16], display[64]; 242 | 243 | for (int i = 1; i < size; i+=2) 244 | { 245 | dp = g_hAdminArray.Get(i); 246 | 247 | dp.Reset(); 248 | Handle plugin = dp.ReadCell(); 249 | Function func_disp = dp.ReadFunction(); 250 | 251 | display[0] = 0; 252 | if (IsCallValid(plugin, func_disp)) { 253 | Call_StartFunction(plugin, func_disp); 254 | Call_PushCell(client); 255 | Call_PushStringEx(display, sizeof(display), SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); 256 | Call_PushCell(sizeof(display)); 257 | Call_Finish(); 258 | } 259 | 260 | if (!display[0]) 261 | continue; 262 | 263 | IntToString(i, id, sizeof(id)); 264 | 265 | menu.AddItem(id, display); 266 | } 267 | } 268 | 269 | menu.DisplayAt(client, pos, MENU_TIME_FOREVER); 270 | } 271 | 272 | public int Admin_Menu_Handler(Menu menu, MenuAction action, int param1, int param2) 273 | { 274 | switch (action) 275 | { 276 | case MenuAction_Select : 277 | { 278 | char info[16]; 279 | menu.GetItem(param2, info, sizeof(info)); 280 | 281 | switch (info[0]) 282 | { 283 | case 'a' : 284 | { 285 | g_iOpt[param1].AdminOption = GIVE_CREDITS; 286 | } 287 | case 'b' : 288 | { 289 | g_iOpt[param1].AdminOption = TAKE_CREDITS; 290 | } 291 | case 'c' : 292 | { 293 | g_iOpt[param1].AdminOption = SET_CREDITS; 294 | } 295 | case 'd' : 296 | { 297 | g_iOpt[param1].AdminOption = GIVE_ITEMS; 298 | } 299 | case 'e' : 300 | { 301 | g_iOpt[param1].AdminOption = TAKE_ITEMS; 302 | } 303 | default : 304 | { 305 | bool result = false; 306 | 307 | DataPack dp; 308 | dp = g_hAdminArray.Get(StringToInt(info)); 309 | if (dp != null) 310 | { 311 | dp.Reset(); 312 | Handle plugin = dp.ReadCell(); 313 | 314 | dp.Position = ADMIN_DP_FUNCSELECT; // Skip func_diplay 315 | Function func_select = dp.ReadFunction(); 316 | 317 | if (IsCallValid(plugin, func_select)) { 318 | Call_StartFunction(plugin, func_select); 319 | Call_PushCell(param1); 320 | Call_Finish(result); 321 | } 322 | } 323 | 324 | if (!result) 325 | Admin_ShowMenu(param1, GetMenuSelectionPosition()); 326 | 327 | return 0; 328 | } 329 | } 330 | 331 | if (!Admin_ShowTargetsMenu(param1)) 332 | { 333 | CPrintToChat(param1, "no_targets"); 334 | Admin_ShowMenu(param1, GetMenuSelectionPosition()); 335 | } 336 | } 337 | case MenuAction_Cancel : 338 | { 339 | if (param2 == MenuCancel_ExitBack) 340 | { 341 | ShowMainMenu(param1); 342 | } 343 | } 344 | case MenuAction_End : 345 | { 346 | delete menu; 347 | } 348 | } 349 | 350 | return 0; 351 | } 352 | 353 | bool Admin_ShowTargetsMenu(int client, int pos = 0) 354 | { 355 | SetGlobalTransTarget(client); 356 | 357 | Menu menu = new Menu(Admin_TargetsMenu_Handler); 358 | if (!AddTargetsToMenu(menu, client, (g_iOpt[client].AdminOption != GIVE_ITEMS && g_iOpt[client].AdminOption != TAKE_ITEMS))) 359 | { 360 | delete menu; 361 | return false; 362 | } 363 | 364 | menu.SetTitle("%t\n ", "select_target"); 365 | menu.ExitButton = true; 366 | menu.ExitBackButton = true; 367 | 368 | menu.DisplayAt(client, pos, MENU_TIME_FOREVER); 369 | 370 | return true; 371 | } 372 | 373 | public int Admin_TargetsMenu_Handler(Menu menu, MenuAction action, int param1, int param2) 374 | { 375 | switch (action) 376 | { 377 | case MenuAction_Select : 378 | { 379 | char info[16]; 380 | menu.GetItem(param2, info, sizeof(info)); 381 | 382 | int userid = StringToInt(info); 383 | int target = GetClientOfUserId(userid); 384 | 385 | if (!target) 386 | { 387 | CPrintToChat(param1, "target_left_game"); 388 | Admin_ShowTargetsMenu(param1, GetMenuSelectionPosition()); 389 | return 0; 390 | } 391 | 392 | g_iOpt[param1].AdminTarget = userid; 393 | 394 | switch (g_iOpt[param1].AdminOption) 395 | { 396 | case GIVE_CREDITS, TAKE_CREDITS, SET_CREDITS : 397 | { 398 | Admin_ShowCreditsAmount(param1); 399 | } 400 | case GIVE_ITEMS, TAKE_ITEMS : 401 | { 402 | Admin_ShowCategories(param1); 403 | } 404 | } 405 | } 406 | case MenuAction_Cancel : 407 | { 408 | if (param2 == MenuCancel_ExitBack) 409 | { 410 | Admin_ShowMenu(param1); 411 | } 412 | } 413 | case MenuAction_End : 414 | { 415 | delete menu; 416 | } 417 | } 418 | 419 | return 0; 420 | } 421 | 422 | void Admin_ShowCreditsAmount(int client, int pos = 0) 423 | { 424 | count_menu.DisplayAt(client, pos, MENU_TIME_FOREVER); 425 | } 426 | 427 | bool Admin_ShowCategories(int client, int pos = 0) 428 | { 429 | SetGlobalTransTarget(client); 430 | 431 | Menu menu = new Menu(Admin_CategoriesMenu_Handler); 432 | if (!FillCategories(menu, client, Menu_AdminPanel, true)) 433 | { 434 | CPrintToChat(client, "%t", "EmptyShop"); 435 | delete menu; 436 | return false; 437 | } 438 | 439 | menu.SetTitle("%t\n ", "select_category"); 440 | menu.ExitButton = true; 441 | menu.ExitBackButton = true; 442 | 443 | menu.DisplayAt(client, pos, MENU_TIME_FOREVER); 444 | 445 | return true; 446 | } 447 | 448 | public int Admin_CategoriesMenu_Handler(Menu menu, MenuAction action, int param1, int param2) 449 | { 450 | switch (action) 451 | { 452 | case MenuAction_Select : 453 | { 454 | char info[16]; 455 | menu.GetItem(param2, info, sizeof(info)); 456 | 457 | int target = GetClientOfUserId(g_iOpt[param1].AdminTarget); 458 | 459 | if (!target) 460 | { 461 | CPrintToChat(param1, "%t", "target_left_game"); 462 | Admin_ShowTargetsMenu(param1, GetMenuSelectionPosition()); 463 | return 0; 464 | } 465 | 466 | g_iOpt[param1].AdminCategory = StringToInt(info); 467 | 468 | Admin_ShowItemsOfCategory(param1, g_iOpt[param1].AdminCategory); 469 | } 470 | case MenuAction_Cancel : 471 | { 472 | if (param2 == MenuCancel_ExitBack) 473 | { 474 | Admin_ShowTargetsMenu(param1); 475 | } 476 | } 477 | case MenuAction_End : 478 | { 479 | delete menu; 480 | } 481 | } 482 | 483 | return 0; 484 | } 485 | 486 | bool Admin_ShowItemsOfCategory(int client, int category_id, int pos = 0) 487 | { 488 | SetGlobalTransTarget(client); 489 | 490 | Menu menu = new Menu(Admin_ItemsMenu_Handler, MENU_ACTIONS_DEFAULT|MenuAction_Display|MenuAction_DrawItem|MenuAction_DisplayItem); 491 | FillItemsOfCategory(menu, client, client, category_id, Menu_AdminPanel, true); 492 | 493 | menu.ExitButton = true; 494 | menu.ExitBackButton = true; 495 | 496 | menu.DisplayAt(client, pos, MENU_TIME_FOREVER); 497 | 498 | return true; 499 | } 500 | 501 | public int Admin_ItemsMenu_Handler(Menu menu, MenuAction action, int param1, int param2) 502 | { 503 | switch (action) 504 | { 505 | case MenuAction_Display : 506 | { 507 | switch (g_iOpt[param1].AdminOption) 508 | { 509 | case GIVE_ITEMS : 510 | { 511 | menu.SetTitle("%t\n ", "give_items"); 512 | } 513 | case TAKE_ITEMS : 514 | { 515 | menu.SetTitle("%t\n ", "take_items"); 516 | } 517 | } 518 | } 519 | case MenuAction_DrawItem : 520 | { 521 | char info[16]; 522 | int style; 523 | menu.GetItem(param2, info, sizeof(info), style); 524 | 525 | if(!info[0]) 526 | { 527 | return style; 528 | } 529 | 530 | int target = GetClientOfUserId(g_iOpt[param1].AdminTarget); 531 | 532 | ItemType type = GetItemTypeEx(info); 533 | 534 | if (type != Item_Finite && type != Item_BuyOnly) 535 | { 536 | switch (g_iOpt[param1].AdminOption) 537 | { 538 | case GIVE_ITEMS : 539 | { 540 | if (ClientHasItemEx(target, info)) 541 | { 542 | return ITEMDRAW_DISABLED; 543 | } 544 | } 545 | case TAKE_ITEMS : 546 | { 547 | if (!ClientHasItemEx(target, info)) 548 | { 549 | return ITEMDRAW_DISABLED; 550 | } 551 | } 552 | } 553 | } 554 | } 555 | case MenuAction_DisplayItem : 556 | { 557 | char info[16], buffer[SHOP_MAX_STRING_LENGTH]; 558 | menu.GetItem(param2, info, sizeof(info), _, buffer, sizeof(buffer)); 559 | 560 | if(!info[0]) 561 | { 562 | return 0; 563 | } 564 | 565 | ItemType type = GetItemTypeEx(info); 566 | 567 | if (type == Item_BuyOnly) 568 | { 569 | return 0; 570 | } 571 | 572 | int target = GetClientOfUserId(g_iOpt[param1].AdminTarget); 573 | 574 | if (type == Item_Finite) 575 | { 576 | Format(buffer, sizeof(buffer), "%s (%d)", buffer, GetItemCountEx(target, info)); 577 | return RedrawMenuItem(buffer); 578 | } 579 | switch (g_iOpt[param1].AdminOption) 580 | { 581 | case GIVE_ITEMS : 582 | { 583 | if (ClientHasItemEx(target, info)) 584 | { 585 | Format(buffer, sizeof(buffer), "[+] %s", buffer); 586 | return RedrawMenuItem(buffer); 587 | } 588 | } 589 | case TAKE_ITEMS : 590 | { 591 | if (!ClientHasItemEx(target, info)) 592 | { 593 | Format(buffer, sizeof(buffer), "[-] %s", buffer); 594 | return RedrawMenuItem(buffer); 595 | } 596 | } 597 | } 598 | } 599 | case MenuAction_Select : 600 | { 601 | char info[16]; 602 | menu.GetItem(param2, info, sizeof(info)); 603 | 604 | int target = GetClientOfUserId(g_iOpt[param1].AdminTarget); 605 | 606 | if (!target) 607 | { 608 | CPrintToChat(param1, "%t", "target_left_game"); 609 | Admin_ShowMenu(param1); 610 | return 0; 611 | } 612 | 613 | switch (g_iOpt[param1].AdminOption) 614 | { 615 | case GIVE_ITEMS : 616 | { 617 | if (GiveItemEx(target, info)) 618 | { 619 | CPrintToChat(param1, "%t", "give_item_success"); 620 | } 621 | } 622 | case TAKE_ITEMS : 623 | { 624 | if (RemoveItemEx(target, info, (GetItemTypeEx(info) == Item_Finite) ? 1 : -1)) 625 | { 626 | CPrintToChat(param1, "%t", "take_item_success"); 627 | } 628 | } 629 | } 630 | 631 | Admin_ShowItemsOfCategory(param1, g_iOpt[param1].AdminCategory, GetMenuSelectionPosition()); 632 | } 633 | case MenuAction_Cancel : 634 | { 635 | if (param2 == MenuCancel_ExitBack) 636 | { 637 | Admin_ShowCategories(param1); 638 | } 639 | } 640 | case MenuAction_End : 641 | { 642 | delete menu; 643 | } 644 | } 645 | 646 | return 0; 647 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/colors.sp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static bool bProto; 4 | 5 | void InitChat() 6 | { 7 | bProto = (CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf); 8 | } 9 | 10 | void CPrintToChat(int client, const char[] sFormat, any ...) 11 | { 12 | char sMessage[512]; 13 | SetGlobalTransTarget(client); 14 | VFormat(sMessage, sizeof(sMessage), sFormat, 3); 15 | 16 | Format(sMessage, sizeof(sMessage), Engine_Version == Engine_CSGO ? " \x01%s":"\x01%s", sMessage); 17 | 18 | ReplaceString(sMessage, sizeof(sMessage), "\\n", "\n"); 19 | ReplaceString(sMessage, sizeof(sMessage), "{DEFAULT}", "\x01", false); 20 | ReplaceString(sMessage, sizeof(sMessage), "{GREEN}", "\x04", false); 21 | 22 | switch(Engine_Version) 23 | { 24 | case Engine_SourceSDK2006: 25 | { 26 | ReplaceString(sMessage, sizeof(sMessage), "{LIGHTGREEN}", "\x03", false); 27 | int iColor = ReplaceColors(sMessage, sizeof(sMessage)); 28 | switch(iColor) 29 | { 30 | case -1: SayText2(client, 0, sMessage); 31 | case 0: SayText2(client, client, sMessage); 32 | default: 33 | { 34 | SayText2(client, FindPlayerByTeam(iColor), sMessage); 35 | } 36 | } 37 | } 38 | case Engine_CSS, Engine_TF2, Engine_HL2DM, Engine_DODS: 39 | { 40 | ReplaceString(sMessage, sizeof(sMessage), "#", "\x07"); 41 | 42 | static Regex hRegex; 43 | static StringMap hColorsTrie; 44 | 45 | if(!hColorsTrie) 46 | { 47 | hColorsTrie = InitColors(); 48 | } 49 | 50 | if(!hRegex) 51 | { 52 | hRegex = new Regex("{[a-zA-Z0-9]+}"); 53 | } 54 | 55 | int iCursor = 0, iColor; 56 | char sColorName[32], sBuffer[32]; 57 | 58 | while(hRegex.Match(sMessage[iCursor])) 59 | { 60 | hRegex.GetSubString(0, sColorName, sizeof(sColorName)); 61 | iCursor = StrContains(sMessage[iCursor], sColorName, true) + iCursor + 1; 62 | CStrToLower(sColorName); 63 | strcopy(sBuffer, sizeof(sBuffer), sColorName[1]); 64 | sBuffer[strlen(sBuffer)-1] = 0; 65 | 66 | if(hColorsTrie.GetValue(sBuffer, iColor)) 67 | { 68 | FormatEx(sBuffer, sizeof(sBuffer), "\x07%06X", iColor); 69 | ReplaceString(sMessage, sizeof(sMessage), sColorName, sBuffer, false); 70 | } 71 | } 72 | 73 | if(ReplaceString(sMessage, sizeof(sMessage), "{TEAM}", "\x03", false)) 74 | { 75 | SayText2(client, client, sMessage); 76 | } 77 | else 78 | { 79 | ReplaceString(sMessage, sizeof(sMessage), "{LIGHTGREEN}", "\x03", false); 80 | SayText2(client, 0, sMessage); 81 | } 82 | } 83 | case Engine_CSGO: 84 | { 85 | static char sColorName[][] = 86 | { 87 | "{DEFAULT}", 88 | "{RED}", 89 | "{LIGHTPURPLE}", 90 | "{GREEN}", 91 | "{LIME}", 92 | "{LIGHTGREEN}", 93 | "{LIGHTRED}", 94 | "{GRAY}", 95 | "{LIGHTOLIVE}", 96 | "{OLIVE}", 97 | "{LIGHTBLUE}", 98 | "{BLUE}", 99 | "{PURPLE}" 100 | }, 101 | sColorCode[][] = 102 | { 103 | "\x01", 104 | "\x02", 105 | "\x03", 106 | "\x04", 107 | "\x05", 108 | "\x06", 109 | "\x07", 110 | "\x08", 111 | "\x09", 112 | "\x10", 113 | "\x0B", 114 | "\x0C", 115 | "\x0E" 116 | }; 117 | 118 | for(int i = 0; i < sizeof(sColorName); ++i) 119 | { 120 | ReplaceString(sMessage, sizeof(sMessage), sColorName[i], sColorCode[i], false); 121 | } 122 | 123 | if(ReplaceString(sMessage, sizeof(sMessage), "{TEAM}", "\x03", false)) 124 | { 125 | SayText2(client, client, sMessage); 126 | } 127 | else 128 | { 129 | SayText2(client, 0, sMessage); 130 | } 131 | } 132 | default: 133 | { 134 | ReplaceString(sMessage, sizeof(sMessage), "#", "\x07"); 135 | SayText2(client, 0, sMessage); 136 | } 137 | } 138 | } 139 | 140 | void CStrToLower(char[] sBuffer) 141 | { 142 | int iLen, i; 143 | iLen = strlen(sBuffer); 144 | for(i = 0; i < iLen; ++i) 145 | { 146 | sBuffer[i] = CharToLower(sBuffer[i]); 147 | } 148 | } 149 | 150 | int ReplaceColors(char[] sMsg, int iMaxLength) 151 | { 152 | if(ReplaceString(sMsg, iMaxLength, "{TEAM}", "\x03", false)) return 0; 153 | 154 | if(ReplaceString(sMsg, iMaxLength, "{BLUE}", "\x03", false)) return 3; 155 | if(ReplaceString(sMsg, iMaxLength, "{RED}", "\x03", false)) return 2; 156 | if(ReplaceString(sMsg, iMaxLength, "{GRAY}", "\x03", false)) return 1; 157 | 158 | return -1; 159 | } 160 | 161 | int FindPlayerByTeam(int iTeam) 162 | { 163 | for (int i = 1; i <= MaxClients; i++) 164 | { 165 | if (IsClientInGame(i) && GetClientTeam(i) == iTeam) return i; 166 | } 167 | 168 | return 0; 169 | } 170 | 171 | void SayText2(int client, int iAuthor = 0, const char[] sMessage) 172 | { 173 | int[] clients = new int[1]; 174 | clients[0] = client; 175 | 176 | Handle hBuffer; 177 | hBuffer = StartMessage("SayText2", clients, 1, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS); 178 | if(bProto) 179 | { 180 | PbSetInt(hBuffer, "ent_idx", iAuthor); 181 | PbSetBool(hBuffer, "chat", true); 182 | PbSetString(hBuffer, "msg_name", sMessage); 183 | PbAddString(hBuffer, "params", ""); 184 | PbAddString(hBuffer, "params", ""); 185 | PbAddString(hBuffer, "params", ""); 186 | PbAddString(hBuffer, "params", ""); 187 | } 188 | else 189 | { 190 | BfWriteByte(hBuffer, iAuthor); 191 | BfWriteByte(hBuffer, true); 192 | BfWriteString(hBuffer, sMessage); 193 | } 194 | EndMessage(); 195 | } 196 | 197 | StringMap InitColors() 198 | { 199 | StringMap hColorsTrie = new StringMap(); 200 | hColorsTrie.SetValue("aliceblue", 0xF0F8FF); 201 | hColorsTrie.SetValue("allies", 0x4D7942); // same as Allies team in DoD:S 202 | hColorsTrie.SetValue("antiquewhite", 0xFAEBD7); 203 | hColorsTrie.SetValue("aqua", 0x00FFFF); 204 | hColorsTrie.SetValue("aquamarine", 0x7FFFD4); 205 | hColorsTrie.SetValue("axis", 0xFF4040); // same as Axis team in DoD:S 206 | hColorsTrie.SetValue("azure", 0x007FFF); 207 | hColorsTrie.SetValue("beige", 0xF5F5DC); 208 | hColorsTrie.SetValue("bisque", 0xFFE4C4); 209 | hColorsTrie.SetValue("black", 0x000000); 210 | hColorsTrie.SetValue("blanchedalmond", 0xFFEBCD); 211 | hColorsTrie.SetValue("blue", 0x99CCFF); // same as BLU/Counter-Terrorist team color 212 | hColorsTrie.SetValue("blueviolet", 0x8A2BE2); 213 | hColorsTrie.SetValue("brown", 0xA52A2A); 214 | hColorsTrie.SetValue("burlywood", 0xDEB887); 215 | hColorsTrie.SetValue("cadetblue", 0x5F9EA0); 216 | hColorsTrie.SetValue("chartreuse", 0x7FFF00); 217 | hColorsTrie.SetValue("chocolate", 0xD2691E); 218 | hColorsTrie.SetValue("community", 0x70B04A); // same as Community item quality in TF2 219 | hColorsTrie.SetValue("coral", 0xFF7F50); 220 | hColorsTrie.SetValue("cornflowerblue", 0x6495ED); 221 | hColorsTrie.SetValue("cornsilk", 0xFFF8DC); 222 | hColorsTrie.SetValue("crimson", 0xDC143C); 223 | hColorsTrie.SetValue("cyan", 0x00FFFF); 224 | hColorsTrie.SetValue("darkblue", 0x00008B); 225 | hColorsTrie.SetValue("darkcyan", 0x008B8B); 226 | hColorsTrie.SetValue("darkgoldenrod", 0xB8860B); 227 | hColorsTrie.SetValue("darkgray", 0xA9A9A9); 228 | hColorsTrie.SetValue("darkgreen", 0x006400); 229 | hColorsTrie.SetValue("darkkhaki", 0xBDB76B); 230 | hColorsTrie.SetValue("darkmagenta", 0x8B008B); 231 | hColorsTrie.SetValue("darkolivegreen", 0x556B2F); 232 | hColorsTrie.SetValue("darkorange", 0xFF8C00); 233 | hColorsTrie.SetValue("darkorchid", 0x9932CC); 234 | hColorsTrie.SetValue("darkred", 0x8B0000); 235 | hColorsTrie.SetValue("darksalmon", 0xE9967A); 236 | hColorsTrie.SetValue("darkseagreen", 0x8FBC8F); 237 | hColorsTrie.SetValue("darkslateblue", 0x483D8B); 238 | hColorsTrie.SetValue("darkslategray", 0x2F4F4F); 239 | hColorsTrie.SetValue("darkturquoise", 0x00CED1); 240 | hColorsTrie.SetValue("darkviolet", 0x9400D3); 241 | hColorsTrie.SetValue("deeppink", 0xFF1493); 242 | hColorsTrie.SetValue("deepskyblue", 0x00BFFF); 243 | hColorsTrie.SetValue("dimgray", 0x696969); 244 | hColorsTrie.SetValue("dodgerblue", 0x1E90FF); 245 | hColorsTrie.SetValue("firebrick", 0xB22222); 246 | hColorsTrie.SetValue("floralwhite", 0xFFFAF0); 247 | hColorsTrie.SetValue("forestgreen", 0x228B22); 248 | hColorsTrie.SetValue("fuchsia", 0xFF00FF); 249 | hColorsTrie.SetValue("fullblue", 0x0000FF); 250 | hColorsTrie.SetValue("fullred", 0xFF0000); 251 | hColorsTrie.SetValue("gainsboro", 0xDCDCDC); 252 | hColorsTrie.SetValue("genuine", 0x4D7455); // same as Genuine item quality in TF2 253 | hColorsTrie.SetValue("ghostwhite", 0xF8F8FF); 254 | hColorsTrie.SetValue("gold", 0xFFD700); 255 | hColorsTrie.SetValue("goldenrod", 0xDAA520); 256 | hColorsTrie.SetValue("gray", 0xCCCCCC); // same as spectator team color 257 | hColorsTrie.SetValue("grey", 0xCCCCCC); 258 | hColorsTrie.SetValue("green", 0x3EFF3E); 259 | hColorsTrie.SetValue("greenyellow", 0xADFF2F); 260 | hColorsTrie.SetValue("haunted", 0x38F3AB); // same as Haunted item quality in TF2 261 | hColorsTrie.SetValue("honeydew", 0xF0FFF0); 262 | hColorsTrie.SetValue("hotpink", 0xFF69B4); 263 | hColorsTrie.SetValue("indianred", 0xCD5C5C); 264 | hColorsTrie.SetValue("indigo", 0x4B0082); 265 | hColorsTrie.SetValue("ivory", 0xFFFFF0); 266 | hColorsTrie.SetValue("khaki", 0xF0E68C); 267 | hColorsTrie.SetValue("lavender", 0xE6E6FA); 268 | hColorsTrie.SetValue("lavenderblush", 0xFFF0F5); 269 | hColorsTrie.SetValue("lawngreen", 0x7CFC00); 270 | hColorsTrie.SetValue("lemonchiffon", 0xFFFACD); 271 | hColorsTrie.SetValue("lightblue", 0xADD8E6); 272 | hColorsTrie.SetValue("lightcoral", 0xF08080); 273 | hColorsTrie.SetValue("lightcyan", 0xE0FFFF); 274 | hColorsTrie.SetValue("lightgoldenrodyellow", 0xFAFAD2); 275 | hColorsTrie.SetValue("lightgray", 0xD3D3D3); 276 | hColorsTrie.SetValue("lightgreen", 0x99FF99); 277 | hColorsTrie.SetValue("lightpink", 0xFFB6C1); 278 | hColorsTrie.SetValue("lightsalmon", 0xFFA07A); 279 | hColorsTrie.SetValue("lightseagreen", 0x20B2AA); 280 | hColorsTrie.SetValue("lightskyblue", 0x87CEFA); 281 | hColorsTrie.SetValue("lightslategray", 0x778899); 282 | hColorsTrie.SetValue("lightsteelblue", 0xB0C4DE); 283 | hColorsTrie.SetValue("lightyellow", 0xFFFFE0); 284 | hColorsTrie.SetValue("lime", 0x00FF00); 285 | hColorsTrie.SetValue("limegreen", 0x32CD32); 286 | hColorsTrie.SetValue("linen", 0xFAF0E6); 287 | hColorsTrie.SetValue("magenta", 0xFF00FF); 288 | hColorsTrie.SetValue("maroon", 0x800000); 289 | hColorsTrie.SetValue("mediumaquamarine", 0x66CDAA); 290 | hColorsTrie.SetValue("mediumblue", 0x0000CD); 291 | hColorsTrie.SetValue("mediumorchid", 0xBA55D3); 292 | hColorsTrie.SetValue("mediumpurple", 0x9370D8); 293 | hColorsTrie.SetValue("mediumseagreen", 0x3CB371); 294 | hColorsTrie.SetValue("mediumslateblue", 0x7B68EE); 295 | hColorsTrie.SetValue("mediumspringgreen", 0x00FA9A); 296 | hColorsTrie.SetValue("mediumturquoise", 0x48D1CC); 297 | hColorsTrie.SetValue("mediumvioletred", 0xC71585); 298 | hColorsTrie.SetValue("midnightblue", 0x191970); 299 | hColorsTrie.SetValue("mintcream", 0xF5FFFA); 300 | hColorsTrie.SetValue("mistyrose", 0xFFE4E1); 301 | hColorsTrie.SetValue("moccasin", 0xFFE4B5); 302 | hColorsTrie.SetValue("navajowhite", 0xFFDEAD); 303 | hColorsTrie.SetValue("navy", 0x000080); 304 | hColorsTrie.SetValue("normal", 0xB2B2B2); // same as Normal item quality in TF2 305 | hColorsTrie.SetValue("oldlace", 0xFDF5E6); 306 | hColorsTrie.SetValue("olive", 0x9EC34F); 307 | hColorsTrie.SetValue("olivedrab", 0x6B8E23); 308 | hColorsTrie.SetValue("orange", 0xFFA500); 309 | hColorsTrie.SetValue("orangered", 0xFF4500); 310 | hColorsTrie.SetValue("orchid", 0xDA70D6); 311 | hColorsTrie.SetValue("palegoldenrod", 0xEEE8AA); 312 | hColorsTrie.SetValue("palegreen", 0x98FB98); 313 | hColorsTrie.SetValue("paleturquoise", 0xAFEEEE); 314 | hColorsTrie.SetValue("palevioletred", 0xD87093); 315 | hColorsTrie.SetValue("papayawhip", 0xFFEFD5); 316 | hColorsTrie.SetValue("peachpuff", 0xFFDAB9); 317 | hColorsTrie.SetValue("peru", 0xCD853F); 318 | hColorsTrie.SetValue("pink", 0xFFC0CB); 319 | hColorsTrie.SetValue("plum", 0xDDA0DD); 320 | hColorsTrie.SetValue("powderblue", 0xB0E0E6); 321 | hColorsTrie.SetValue("purple", 0x800080); 322 | hColorsTrie.SetValue("red", 0xFF4040); // same as RED/Terrorist team color 323 | hColorsTrie.SetValue("rosybrown", 0xBC8F8F); 324 | hColorsTrie.SetValue("royalblue", 0x4169E1); 325 | hColorsTrie.SetValue("saddlebrown", 0x8B4513); 326 | hColorsTrie.SetValue("salmon", 0xFA8072); 327 | hColorsTrie.SetValue("sandybrown", 0xF4A460); 328 | hColorsTrie.SetValue("seagreen", 0x2E8B57); 329 | hColorsTrie.SetValue("seashell", 0xFFF5EE); 330 | hColorsTrie.SetValue("selfmade", 0x70B04A); // same as Self-Made item quality in TF2 331 | hColorsTrie.SetValue("sienna", 0xA0522D); 332 | hColorsTrie.SetValue("silver", 0xC0C0C0); 333 | hColorsTrie.SetValue("skyblue", 0x87CEEB); 334 | hColorsTrie.SetValue("slateblue", 0x6A5ACD); 335 | hColorsTrie.SetValue("slategray", 0x708090); 336 | hColorsTrie.SetValue("snow", 0xFFFAFA); 337 | hColorsTrie.SetValue("springgreen", 0x00FF7F); 338 | hColorsTrie.SetValue("steelblue", 0x4682B4); 339 | hColorsTrie.SetValue("strange", 0xCF6A32); // same as Strange item quality in TF2 340 | hColorsTrie.SetValue("tan", 0xD2B48C); 341 | hColorsTrie.SetValue("teal", 0x008080); 342 | hColorsTrie.SetValue("thistle", 0xD8BFD8); 343 | hColorsTrie.SetValue("tomato", 0xFF6347); 344 | hColorsTrie.SetValue("turquoise", 0x40E0D0); 345 | hColorsTrie.SetValue("unique", 0xFFD700); // same as Unique item quality in TF2 346 | hColorsTrie.SetValue("unusual", 0x8650AC); // same as Unusual item quality in TF2 347 | hColorsTrie.SetValue("valve", 0xA50F79); // same as Valve item quality in TF2 348 | hColorsTrie.SetValue("vintage", 0x476291); // same as Vintage item quality in TF2 349 | hColorsTrie.SetValue("violet", 0xEE82EE); 350 | hColorsTrie.SetValue("wheat", 0xF5DEB3); 351 | hColorsTrie.SetValue("white", 0xFFFFFF); 352 | hColorsTrie.SetValue("whitesmoke", 0xF5F5F5); 353 | hColorsTrie.SetValue("yellow", 0xFFFF00); 354 | hColorsTrie.SetValue("yellowgreen", 0x9ACD32); 355 | 356 | return hColorsTrie; 357 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/commands.sp: -------------------------------------------------------------------------------- 1 | void Commands_OnSettingsLoad(KeyValues kv) 2 | { 3 | if (kv.JumpToKey("Commands", false)) 4 | { 5 | char buffer[SHOP_MAX_STRING_LENGTH]; 6 | 7 | kv.GetString("Give_Credits", buffer, sizeof(buffer)); 8 | TrimString(buffer); 9 | RegConsoleCmd(buffer, Commands_GiveCredits, "How many credits to give to players"); 10 | 11 | kv.GetString("Take_Credits", buffer, sizeof(buffer)); 12 | TrimString(buffer); 13 | RegConsoleCmd(buffer, Commands_TakeCredits, "How many credits to take from players"); 14 | 15 | kv.GetString("Set_Credits", buffer, sizeof(buffer)); 16 | TrimString(buffer); 17 | RegConsoleCmd(buffer, Commands_SetCredits, "How many credits to set to players"); 18 | 19 | kv.GetString("Main_Menu", buffer, sizeof(buffer)); 20 | TrimString(buffer); 21 | 22 | char part[64]; 23 | int reloc_idx, var2; 24 | int row; 25 | while ((var2 = SplitString(buffer[reloc_idx], ",", part, sizeof(part)))) 26 | { 27 | if (var2 == -1) 28 | strcopy(part, sizeof(part), buffer[reloc_idx]); 29 | else 30 | reloc_idx += var2; 31 | 32 | TrimString(part); 33 | 34 | if (!part[0]) 35 | continue; 36 | 37 | if (!row) 38 | { 39 | int start; 40 | if (!StrContains(part, "sm_", true)) 41 | { 42 | start = 3; 43 | } 44 | strcopy(g_sChatCommand, sizeof(g_sChatCommand), part[start]); 45 | } 46 | 47 | RegConsoleCmd(part, Commands_Shop, "Open up main menu"); 48 | 49 | if (var2 == -1) 50 | break; 51 | 52 | row++; 53 | } 54 | 55 | kv.Rewind(); 56 | } 57 | } 58 | 59 | public Action Commands_Shop(int client, int args) 60 | { 61 | if (!client) 62 | { 63 | return Plugin_Continue; 64 | } 65 | 66 | if (!IsAuthorizedIn(client)) 67 | { 68 | CPrintToChat(client, "%t", "DataLoading"); 69 | return Plugin_Handled; 70 | } 71 | 72 | ShowMainMenu(client); 73 | 74 | return Plugin_Handled; 75 | } 76 | 77 | public Action Commands_GiveCredits(int client, int args) 78 | { 79 | if (client && !(GetUserFlagBits(client) & g_iAdminFlags)) 80 | { 81 | CPrintToChat(client, "%t", "NoAccessToCommand"); 82 | return Plugin_Handled; 83 | } 84 | char buffer[96]; 85 | if (args < 2) 86 | { 87 | GetCmdArg(0, buffer, sizeof(buffer)); 88 | ReplyToCommand(client, "Usage: %s ", buffer); 89 | return Plugin_Handled; 90 | } 91 | 92 | char pattern[96], money[32]; 93 | GetCmdArg(1, pattern, sizeof(pattern)); 94 | GetCmdArg(2, money, sizeof(money)); 95 | 96 | int[] targets = new int[MaxClients]; 97 | bool ml; 98 | 99 | int imoney = StringToInt(money); 100 | 101 | int count = ProcessTargetString(pattern, client, targets, MaxClients, COMMAND_FILTER_NO_BOTS, buffer, sizeof(buffer), ml); 102 | 103 | if (count < 1) 104 | { 105 | if (client) 106 | { 107 | CPrintToChat(client, "%t", "TargetNotFound", pattern); 108 | } 109 | else 110 | { 111 | ReplyToCommand(client, "%t", "TargetNotFound", pattern); 112 | } 113 | } 114 | else 115 | { 116 | for (int i = 0; i < count; i++) 117 | { 118 | if (targets[i] != client && !CanUserTarget(client, targets[i])) continue; 119 | 120 | GiveCredits(targets[i], imoney, client); 121 | } 122 | if (ml) 123 | { 124 | Format(buffer, sizeof(buffer), "%T", buffer, client); 125 | } 126 | if (client) 127 | { 128 | CPrintToChat(client, "%t", "give_credits_success", imoney, buffer); 129 | } 130 | else 131 | { 132 | ReplyToCommand(client, "%t", "give_credits_success", imoney, buffer); 133 | } 134 | } 135 | 136 | return Plugin_Handled; 137 | } 138 | 139 | public Action Commands_TakeCredits(int client, int args) 140 | { 141 | if (client && !(GetUserFlagBits(client) & g_iAdminFlags)) 142 | { 143 | CPrintToChat(client, "%t", "NoAccessToCommand"); 144 | return Plugin_Handled; 145 | } 146 | char buffer[96]; 147 | if (args < 2) 148 | { 149 | GetCmdArg(0, buffer, sizeof(buffer)); 150 | ReplyToCommand(client, "Usage: %s ", buffer); 151 | return Plugin_Handled; 152 | } 153 | 154 | char pattern[96], money[32]; 155 | GetCmdArg(1, pattern, sizeof(pattern)); 156 | GetCmdArg(2, money, sizeof(money)); 157 | 158 | int[] targets = new int[MaxClients]; 159 | bool ml; 160 | 161 | int imoney = StringToInt(money); 162 | 163 | int count = ProcessTargetString(pattern, client, targets, MaxClients, COMMAND_FILTER_NO_BOTS, buffer, sizeof(buffer), ml); 164 | 165 | if (count < 1) 166 | { 167 | if (client) 168 | { 169 | CPrintToChat(client, "%t", "TargetNotFound", pattern); 170 | } 171 | else 172 | { 173 | ReplyToCommand(client, "%t", "TargetNotFound", pattern); 174 | } 175 | } 176 | else 177 | { 178 | for (int i = 0; i < count; i++) 179 | { 180 | if (targets[i] != client && !CanUserTarget(client, targets[i])) continue; 181 | 182 | RemoveCredits(targets[i], imoney, client); 183 | } 184 | if (ml) 185 | { 186 | Format(buffer, sizeof(buffer), "%T", buffer, client); 187 | } 188 | if (client) 189 | { 190 | CPrintToChat(client, "%t", "remove_credits_success", imoney, buffer); 191 | } 192 | else 193 | { 194 | ReplyToCommand(client, "%t", "remove_credits_success", imoney, buffer); 195 | } 196 | } 197 | 198 | return Plugin_Handled; 199 | } 200 | 201 | public Action Commands_SetCredits(int client, int args) 202 | { 203 | if (client && !(GetUserFlagBits(client) & g_iAdminFlags)) 204 | { 205 | CPrintToChat(client, "%t", "NoAccessToCommand"); 206 | return Plugin_Handled; 207 | } 208 | char buffer[96]; 209 | if (args < 2) 210 | { 211 | GetCmdArg(0, buffer, sizeof(buffer)); 212 | ReplyToCommand(client, "Usage: %s ", buffer); 213 | return Plugin_Handled; 214 | } 215 | 216 | char pattern[96], money[32]; 217 | GetCmdArg(1, pattern, sizeof(pattern)); 218 | GetCmdArg(2, money, sizeof(money)); 219 | 220 | int[] targets = new int[MaxClients]; 221 | bool ml; 222 | 223 | int imoney = StringToInt(money); 224 | 225 | int count = ProcessTargetString(pattern, client, targets, MaxClients, COMMAND_FILTER_NO_BOTS, buffer, sizeof(buffer), ml); 226 | 227 | if (count < 1) 228 | { 229 | if (client) 230 | { 231 | CPrintToChat(client, "%t", "TargetNotFound", pattern); 232 | } 233 | else 234 | { 235 | ReplyToCommand(client, "%t", "TargetNotFound", pattern); 236 | } 237 | } 238 | else 239 | { 240 | for (int i = 0; i < count; i++) 241 | { 242 | if (targets[i] != client && !CanUserTarget(client, targets[i])) continue; 243 | 244 | SetCredits(targets[i], imoney, true); 245 | } 246 | if (ml) 247 | { 248 | Format(buffer, sizeof(buffer), "%T", buffer, client); 249 | } 250 | if (client) 251 | { 252 | CPrintToChat(client, "%t", "set_credits_success", imoney, buffer); 253 | } 254 | else 255 | { 256 | ReplyToCommand(client, "%t", "set_credits_success", imoney, buffer); 257 | } 258 | } 259 | 260 | return Plugin_Handled; 261 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/db.sp: -------------------------------------------------------------------------------- 1 | Database h_db; 2 | 3 | ShopDBType db_type; 4 | 5 | enum struct backup_struct { 6 | SQLQueryCallback CallBack; 7 | any Data; 8 | DBPriority Prio; 9 | char QueryBuffer[512]; 10 | } 11 | ArrayList ar_backups; 12 | 13 | int iDays = -1; 14 | 15 | void DB_CreateNatives() 16 | { 17 | CreateNative("Shop_GetDatabase", DB_GetDatabase); 18 | CreateNative("Shop_GetDatabasePrefix", DB_GetDatabasePrefix); 19 | CreateNative("Shop_GetDatabaseType", DB_GetDatabaseType); 20 | } 21 | 22 | public int DB_GetDatabase(Handle plugin, int numParams) 23 | { 24 | return view_as(CloneHandle(h_db, plugin)); 25 | } 26 | 27 | public int DB_GetDatabasePrefix(Handle plugin, int numParams) 28 | { 29 | int bytes; 30 | 31 | SetNativeString(1, g_sDbPrefix, GetNativeCell(2), false, bytes); 32 | 33 | return bytes; 34 | } 35 | 36 | public int DB_GetDatabaseType(Handle plugin, int numParams) 37 | { 38 | return view_as(db_type); 39 | } 40 | 41 | void DB_OnPluginStart() 42 | { 43 | RegServerCmd("sm_shop_clear_db", DB_Command_Clear, "Clears database"); 44 | 45 | ar_backups = new ArrayList(sizeof(backup_struct)); 46 | DB_TryConnect(); 47 | } 48 | 49 | void DB_OnSettingsLoad(KeyValues kv) 50 | { 51 | kv.GetString("db_prefix", g_sDbPrefix, sizeof(g_sDbPrefix), "shop_"); 52 | TrimString(g_sDbPrefix); 53 | } 54 | 55 | void DB_OnMapStart() 56 | { 57 | iDays = -1; 58 | } 59 | 60 | int num_rows; 61 | public Action DB_Command_Clear(int argc) 62 | { 63 | if (h_db == null || !IsStarted()) 64 | { 65 | PrintToServer("[Shop] Database is not ready! Try again later"); 66 | DB_TryConnect(); 67 | 68 | return Plugin_Handled; 69 | } 70 | 71 | if (argc == 0 && iDays == -1) 72 | { 73 | iDays = 0; 74 | 75 | PrintToServer("[Shop] Full database clear. Type sm_shop_clear_db 'ok' to process the query or 'deny' to cancel the process!"); 76 | } 77 | else 78 | { 79 | char sDays[8]; 80 | GetCmdArg(1, sDays, sizeof(sDays)); 81 | 82 | if (iDays != -1) 83 | { 84 | if (StrEqual(sDays, "ok", false)) 85 | { 86 | char s_Query[128]; 87 | if (iDays == 0) 88 | { 89 | if (db_type == DB_MySQL) 90 | { 91 | h_db.Format(s_Query, sizeof(s_Query), "TRUNCATE TABLE `%sboughts`;", g_sDbPrefix); 92 | DB_TQuery(DB_Clear, s_Query, iDays); 93 | 94 | h_db.Format(s_Query, sizeof(s_Query), "TRUNCATE TABLE `%splayers`;", g_sDbPrefix); 95 | DB_TQuery(DB_Clear, s_Query, iDays); 96 | 97 | h_db.Format(s_Query, sizeof(s_Query), "TRUNCATE TABLE `%stoggles`;", g_sDbPrefix); 98 | DB_TQuery(DB_Clear, s_Query, iDays); 99 | } 100 | else 101 | { 102 | h_db.Format(s_Query, sizeof(s_Query), "DELETE FROM `%sboughts`;", g_sDbPrefix); 103 | DB_TQuery(DB_Clear, s_Query, iDays); 104 | 105 | h_db.Format(s_Query, sizeof(s_Query), "DELETE FROM `%splayers`;", g_sDbPrefix); 106 | DB_TQuery(DB_Clear, s_Query, iDays); 107 | 108 | h_db.Format(s_Query, sizeof(s_Query), "DELETE FROM `%stoggles`;", g_sDbPrefix); 109 | DB_TQuery(DB_Clear, s_Query, iDays); 110 | } 111 | 112 | num_rows += 3; 113 | PrintToServer("[Shop] Full clearing database..."); 114 | } 115 | else 116 | { 117 | h_db.Format(s_Query, sizeof(s_Query), "DELETE FROM `%sboughts` WHERE `player_id` IN (SELECT `id` FROM `%splayers` WHERE %d - `lastconnect` > %d);", g_sDbPrefix, g_sDbPrefix, global_timer, iDays*86400); 118 | DB_TQuery(DB_Clear, s_Query, iDays); 119 | 120 | h_db.Format(s_Query, sizeof(s_Query), "DELETE FROM `%stoggles` WHERE `player_id` IN (SELECT `id` FROM `%splayers` WHERE %d - `lastconnect` > %d);", g_sDbPrefix, g_sDbPrefix, global_timer, iDays*86400); 121 | DB_TQuery(DB_Clear, s_Query, iDays); 122 | 123 | h_db.Format(s_Query, sizeof(s_Query), "DELETE FROM `%splayers` WHERE %d - `lastconnect` > %d;", g_sDbPrefix, global_timer, iDays*86400); 124 | DB_TQuery(DB_Clear, s_Query, iDays); 125 | num_rows += 3; 126 | 127 | PrintToServer("[Shop] Clearing database from inactive players for more than %d %s!", iDays, (iDays == 1) ? "day" : "days"); 128 | } 129 | 130 | iDays = -1; 131 | } 132 | else if (StrEqual(sDays, "deny", false)) 133 | { 134 | iDays = -1; 135 | 136 | PrintToServer("[Shop] Database clear canceled!"); 137 | } 138 | else 139 | { 140 | if (iDays == 0) 141 | { 142 | PrintToServer("[Shop] Current clearing option is set to - Full database clear"); 143 | PrintToServer("[Shop] This will also delete all data of players that are currently on the server"); 144 | } 145 | else 146 | { 147 | PrintToServer("[Shop] Current clearing option is set to - Clear from inactive players for more than %d %s!", iDays, (iDays == 1) ? "day" : "days"); 148 | } 149 | PrintToServer("[Shop] Type sm_shop_clear_db 'ok' to process the query or 'deny' to cancel the process!"); 150 | } 151 | 152 | return Plugin_Handled; 153 | } 154 | 155 | int days = StringToInt(sDays); 156 | 157 | if (days < 1) 158 | { 159 | PrintToServer("[Shop] Days can not be less than 1!"); 160 | 161 | return Plugin_Handled; 162 | } 163 | 164 | iDays = days; 165 | PrintToServer("[Shop] Database clear from players that are inactive for more than %d %s!", iDays, (iDays == 1) ? "day" : "days"); 166 | PrintToServer("[Shop] Type sm_shop_clear_db 'ok' to process the query or 'deny' to cancel the process!"); 167 | } 168 | 169 | return Plugin_Handled; 170 | } 171 | 172 | public void DB_Clear(Database db, DBResultSet results, const char[] error, any data) 173 | { 174 | if (num_rows) num_rows--; 175 | if (error[0]) 176 | { 177 | LogError("DB_Clear %d: %s", data, error); 178 | return; 179 | } 180 | 181 | if (num_rows) return; 182 | if (data == 0) 183 | { 184 | DatabaseClear(); 185 | PrintToServer("[Shop] Database is fully cleared!"); 186 | } 187 | else 188 | { 189 | PrintToServer("[Shop] Database is cleared!"); 190 | } 191 | } 192 | 193 | bool isLoading; 194 | void DB_TryConnect() 195 | { 196 | if (isLoading) 197 | { 198 | return; 199 | } 200 | if (h_db != null) 201 | { 202 | isLoading = false; 203 | return; 204 | } 205 | 206 | isLoading = true; 207 | 208 | PrintToServer("[Shop] Trying to connect!"); 209 | 210 | if (SQL_CheckConfig("shop")) 211 | { 212 | Database.Connect(DB_Connect, "shop", 1); 213 | } 214 | else 215 | { 216 | char error[256]; 217 | error[0] = '\0'; 218 | 219 | h_db = SQLite_UseDatabase("shop", error, sizeof(error)); 220 | 221 | DB_Connect(h_db, error, 2); 222 | } 223 | } 224 | 225 | public Action DB_ReconnectTimer(Handle timer) 226 | { 227 | if (h_db == null) 228 | { 229 | DB_TryConnect(); 230 | } 231 | 232 | return Plugin_Continue; 233 | } 234 | 235 | DataPack upgrade_dp; 236 | DataPack insert_dp; 237 | public void DB_Connect(Database db, const char[] error, any data) 238 | { 239 | h_db = db; 240 | 241 | if (h_db == null) 242 | { 243 | LogError("DB_Connect %d: %s", data, error); 244 | CreateTimer(15.0, DB_ReconnectTimer); 245 | isLoading = false; 246 | return; 247 | } 248 | if (error[0]) 249 | { 250 | LogError("DB_Connect %d: %s", data, error); 251 | } 252 | 253 | char driver[16]; 254 | DBDriver dbdriver = db.Driver; 255 | dbdriver.GetIdentifier(driver, sizeof(driver)); 256 | 257 | if (StrEqual(driver, "mysql", false)) 258 | { 259 | db_type = DB_MySQL; 260 | } 261 | else if (StrEqual(driver, "sqlite", false)) 262 | { 263 | db_type = DB_SQLite; 264 | } 265 | else 266 | { 267 | SetFailState("DB_Connect: Driver \"%s\" is not supported!", driver); 268 | } 269 | 270 | char s_Query[256]; 271 | if (db_type == DB_MySQL) 272 | { 273 | DB_TQueryEx("SET NAMES '" ... SHOP_MYSQL_CHARSET ... "'"); 274 | DB_TQueryEx("SET CHARSET '" ... SHOP_MYSQL_CHARSET ... "'"); 275 | 276 | if (GetFeatureStatus(FeatureType_Native, "SQL_SetCharset") == FeatureStatus_Available) 277 | { 278 | h_db.SetCharset(SHOP_MYSQL_CHARSET); 279 | } 280 | 281 | DB_TQuery(DB_GlobalTimer, "SELECT UNIX_TIMESTAMP()", _, DBPrio_High); 282 | 283 | h_db.Format(s_Query, sizeof(s_Query), "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '%sboughts';", g_sDbPrefix); 284 | DB_TQuery(DB_CheckTable, s_Query); 285 | } 286 | else 287 | { 288 | global_timer = GetTime(); 289 | 290 | h_db.Format(s_Query, sizeof(s_Query), "PRAGMA TABLE_INFO(%sboughts);", g_sDbPrefix); 291 | DB_TQuery(DB_CheckTable, s_Query); 292 | } 293 | } 294 | 295 | public void DB_GlobalTimer(Database db, DBResultSet results, const char[] error, any data) 296 | { 297 | if (error[0]) 298 | { 299 | LogError("DB_GlobalTimer: %s", error); 300 | } 301 | 302 | if (results == null || !results.HasResults) 303 | { 304 | DB_TQuery(DB_GlobalTimer, "SELECT UNIX_TIMESTAMP()"); 305 | return; 306 | } 307 | 308 | results.FetchRow(); 309 | global_timer = results.FetchInt(0); 310 | } 311 | 312 | public void DB_CheckTable(Database db, DBResultSet results, const char[] error, any data) 313 | { 314 | if (error[0]) 315 | { 316 | LogError("DB_CheckTable: %s", error); 317 | delete h_db; 318 | h_db = null; 319 | CreateTimer(15.0, DB_ReconnectTimer); 320 | isLoading = false; 321 | return; 322 | } 323 | 324 | char s_Query[256]; 325 | if (db_type == DB_MySQL) 326 | { 327 | if (!results.HasResults || !results.FetchRow() || results.FetchInt(0) < 1) 328 | { 329 | h_db.Format(s_Query, sizeof(s_Query), "SELECT LEFT(TABLE_COLLATION, %d) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '%sitems';", strlen(SHOP_MYSQL_CHARSET), g_sDbPrefix); 330 | DB_TQuery(DB_CheckTable2, s_Query); 331 | 332 | return; 333 | } 334 | } 335 | else if (!results.RowCount) 336 | { 337 | h_db.Format(s_Query, sizeof(s_Query), "PRAGMA TABLE_INFO(%sitems);", g_sDbPrefix); 338 | DB_TQuery(DB_CheckTable2, s_Query); 339 | 340 | return; 341 | } 342 | 343 | DB_RunBackup(); 344 | 345 | // OnReadyToStart(); 346 | DB_CreateTables(); 347 | } 348 | 349 | public void DB_CheckTable2(Database db, DBResultSet results, const char[] error, any data) 350 | { 351 | if (error[0]) 352 | { 353 | LogError("DB_CheckTable2: %s", error); 354 | delete h_db; 355 | h_db = null; 356 | CreateTimer(15.0, DB_ReconnectTimer); 357 | isLoading = false; 358 | return; 359 | } 360 | 361 | if (db_type == DB_MySQL) 362 | { 363 | if (results.RowCount == 0) 364 | { 365 | DB_UpgradeToNewVersion(); 366 | return; 367 | } 368 | 369 | if (results.FetchRow()) 370 | { 371 | char sCollationType[16]; 372 | results.FetchString(0, sCollationType, sizeof(sCollationType)); 373 | if (strcmp(sCollationType, SHOP_MYSQL_CHARSET) != 0) 374 | { 375 | char sQuery[64]; 376 | h_db.Format(sQuery, sizeof(sQuery), "ALTER TABLE `%sitems` CONVERT TO CHARSET " ... SHOP_MYSQL_CHARSET, g_sDbPrefix); 377 | DB_TQueryEx(sQuery); 378 | } 379 | } 380 | 381 | return; 382 | } 383 | else if (results.RowCount == 0) 384 | { 385 | DB_UpgradeToNewVersion(); 386 | return; 387 | } 388 | 389 | DB_CreateTables(); 390 | } 391 | 392 | void DB_CreateTables() 393 | { 394 | char s_Query[512]; 395 | if (db_type == DB_MySQL) 396 | { 397 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%sboughts` (\ 398 | `player_id` int NOT NULL,\ 399 | `item_id` int NOT NULL,\ 400 | `count` int NOT NULL,\ 401 | `duration` int NOT NULL,\ 402 | `timeleft` int NOT NULL,\ 403 | `buy_price` int NOT NULL,\ 404 | `sell_price` int NOT NULL,\ 405 | `buy_time` int\ 406 | ) ENGINE=InnoDB DEFAULT CHARSET=" ... SHOP_MYSQL_CHARSET ... ";", g_sDbPrefix); 407 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 1); 408 | 409 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%sitems` (\ 410 | `id` int NOT NULL AUTO_INCREMENT,\ 411 | `category` varchar(64) NOT NULL,\ 412 | `item` varchar(64) NOT NULL,\ 413 | PRIMARY KEY (`id`)\ 414 | ) ENGINE=MyISAM DEFAULT CHARSET=" ... SHOP_MYSQL_CHARSET ... " AUTO_INCREMENT=1 ;", g_sDbPrefix); 415 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 2); 416 | 417 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%splayers` (\ 418 | `id` int NOT NULL AUTO_INCREMENT,\ 419 | `name` varchar(32) NOT NULL DEFAULT 'unknown',\ 420 | `auth` varchar(22) NOT NULL,\ 421 | `money` int NOT NULL,\ 422 | `lastconnect` int,\ 423 | PRIMARY KEY (`id`), \ 424 | UNIQUE KEY `auth` (`auth`) \ 425 | ) ENGINE=MyISAM DEFAULT CHARSET=" ... SHOP_MYSQL_CHARSET ... " AUTO_INCREMENT=1;", g_sDbPrefix); 426 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 3); 427 | 428 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%stoggles` (\ 429 | `id` int NOT NULL AUTO_INCREMENT,\ 430 | `player_id` int NOT NULL,\ 431 | `item_id` int NOT NULL,\ 432 | `state` tinyint NOT NULL DEFAULT 0,\ 433 | PRIMARY KEY (`id`) \ 434 | ) ENGINE=MyISAM DEFAULT CHARSET=" ... SHOP_MYSQL_CHARSET ... " AUTO_INCREMENT=1;", g_sDbPrefix); 435 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 4); 436 | } 437 | else 438 | { 439 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%sboughts` (\ 440 | `player_id` NUMERIC NOT NULL,\ 441 | `item_id` INTEGER NOT NULL,\ 442 | `count` NUMERIC NOT NULL,\ 443 | `duration` INTEGER NOT NULL,\ 444 | `timeleft` NUMERIC NOT NULL,\ 445 | `buy_price` INTEGER NOT NULL,\ 446 | `sell_price` NUMERIC NOT NULL,\ 447 | `buy_time` NUMERIC NOT NULL);", g_sDbPrefix); 448 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 1); 449 | 450 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%sitems` (\ 451 | `id` INTEGER PRIMARY KEY AUTOINCREMENT,\ 452 | `category` VARCHAR NOT NULL,\ 453 | `item` VARCHAR NOT NULL);", g_sDbPrefix); 454 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 2); 455 | 456 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%splayers` (\ 457 | `id` INTEGER PRIMARY KEY AUTOINCREMENT,\ 458 | `name` VARCHAR DEFAULT 'unknown',\ 459 | `auth` VARCHAR UNIQUE ON CONFLICT IGNORE,\ 460 | `money` NUMERIC DEFAULT '0',\ 461 | `lastconnect` INTEGER NOT NULL);", g_sDbPrefix); 462 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 3); 463 | 464 | h_db.Format(s_Query, sizeof(s_Query), "CREATE TABLE IF NOT EXISTS `%stoggles` (\ 465 | `id` INTEGER PRIMARY KEY AUTOINCREMENT,\ 466 | `player_id` INTEGER NOT NULL,\ 467 | `item_id` INTEGER NOT NULL,\ 468 | `state` INTEGER NOT NULL DEFAULT 0);", g_sDbPrefix); 469 | DB_TQuery(DB_OnPlayersTableLoad, s_Query, 4); 470 | } 471 | 472 | isLoading = false; 473 | } 474 | 475 | public void DB_OnPlayersTableLoad(Database db, DBResultSet results, const char[] error, any data) 476 | { 477 | if (error[0]) 478 | { 479 | LogError("DB_OnPlayersTableLoad %d: %s", data, error); 480 | delete h_db; 481 | h_db = null; 482 | CreateTimer(15.0, DB_ReconnectTimer); 483 | return; 484 | } 485 | 486 | if (data != 4) 487 | { 488 | return; 489 | } 490 | 491 | if (db_type == DB_MySQL) 492 | { 493 | DB_TQueryEx("SET NAMES '" ... SHOP_MYSQL_CHARSET ... "'"); 494 | DB_TQueryEx("SET CHARSET '" ... SHOP_MYSQL_CHARSET ... "'"); 495 | } 496 | 497 | if (upgrade_dp != null) 498 | { 499 | DB_RunUpgrade(); 500 | } 501 | else 502 | { 503 | OnReadyToStart(); 504 | } 505 | } 506 | 507 | stock void DB_FastQuery(const char[] query) 508 | { 509 | if (h_db == null) 510 | { 511 | WriteBackUp(DB_ErrorCheck, query, 0, DBPrio_Normal); 512 | return; 513 | } 514 | 515 | SQL_LockDatabase(h_db); 516 | SQL_FastQuery(h_db, query); 517 | SQL_UnlockDatabase(h_db); 518 | } 519 | 520 | void WriteBackUp(SQLQueryCallback callback, const char[] query, any data = 0, DBPriority prio) 521 | { 522 | backup_struct backup; 523 | 524 | backup.CallBack = callback; 525 | FormatEx(backup.QueryBuffer, sizeof(backup.QueryBuffer), query); 526 | backup.Data = data; 527 | backup.Prio = prio; 528 | 529 | ar_backups.PushArray(backup); 530 | } 531 | 532 | void DB_TQuery(SQLQueryCallback callback, const char[] query, any data = 0, DBPriority prio = DBPrio_Normal) 533 | { 534 | if (h_db == null) 535 | { 536 | WriteBackUp(callback, query, data, prio); 537 | return; 538 | } 539 | 540 | h_db.Query(callback, query, data, prio); 541 | } 542 | 543 | void DB_TQueryEx(const char[] query, DBPriority prio = DBPrio_Normal) 544 | { 545 | if (h_db == null) 546 | { 547 | WriteBackUp(DB_ErrorCheck, query, 0, prio); 548 | return; 549 | } 550 | h_db.Query(DB_ErrorCheck, query, _, prio); 551 | } 552 | 553 | void DB_EscapeString(const char[] string, char[] buffer, int maxlength, int &written=0) 554 | { 555 | h_db.Escape(string, buffer, maxlength, written); 556 | } 557 | 558 | void DB_RunBackup() 559 | { 560 | ArrayList ar = ar_backups.Clone(); 561 | ar_backups.Clear(); 562 | backup_struct backup; 563 | 564 | for(int id, length = ar.Length; id < length; id++) 565 | { 566 | ar.GetArray(id, backup); 567 | DB_TQuery(backup.CallBack, backup.QueryBuffer, backup.Data, backup.Prio); 568 | } 569 | } 570 | 571 | stock bool DB_IsConnected() 572 | { 573 | return (h_db != null); 574 | } 575 | 576 | public void DB_ErrorCheck(Database db, DBResultSet results, const char[] error, any data) 577 | { 578 | if (error[0]) 579 | { 580 | LogError("DB_ErrorCheck: %s", error); 581 | } 582 | } 583 | 584 | void DB_UpgradeToNewVersion() 585 | { 586 | PrintToServer("[Shop] Started upgrading to version 2!"); 587 | 588 | char s_Query[256]; 589 | 590 | if (db_type == DB_MySQL) 591 | { 592 | h_db.Format(s_Query, sizeof(s_Query), "ALTER TABLE `%splayers` ADD `lastconnect` int(10) NOT NULL DEFAULT '0';", g_sDbPrefix); 593 | } 594 | else 595 | { 596 | h_db.Format(s_Query, sizeof(s_Query), "ALTER TABLE `%splayers` ADD `lastconnect` NUMERIC NOT NULL DEFAULT '0'", g_sDbPrefix); 597 | } 598 | DB_TQueryEx(s_Query); 599 | 600 | h_db.Format(s_Query, sizeof(s_Query), "SELECT * FROM `%sitems`;", g_sDbPrefix); 601 | DB_TQuery(DB_UgradeState_1, s_Query); 602 | } 603 | 604 | public void DB_UgradeState_1(Database db, DBResultSet results, const char[] error, any data) 605 | { 606 | if (error[0]) 607 | { 608 | LogError("DB_UgradeState_1: %s", error); 609 | DB_CreateTables(); 610 | return; 611 | } 612 | 613 | PrintToServer("[Shop] Reading old tables..."); 614 | 615 | upgrade_dp = new DataPack(); 616 | insert_dp = new DataPack(); 617 | 618 | bool got_categories; 619 | char category[64], item[64], buffer[2048], part[128]; 620 | int id; 621 | while (results.FetchRow()) 622 | { 623 | id = results.FetchInt(0); 624 | for (int i = 1; i < results.FieldCount; i++) 625 | { 626 | results.FieldNumToName(i, category, sizeof(category)); 627 | 628 | if (!got_categories) 629 | { 630 | SQL_LockDatabase(h_db); 631 | h_db.Format(buffer, sizeof(buffer), "SELECT `item` FROM `%s`;", category); 632 | DBResultSet hQuery = SQL_Query(h_db, buffer); 633 | if (hQuery != null) 634 | { 635 | while (hQuery.FetchRow()) 636 | { 637 | hQuery.FetchString(0, item, sizeof(item)); 638 | 639 | h_db.Format(buffer, sizeof(buffer), "INSERT INTO `%sitems` (`category`, `item`) VALUES ('%s', '%s');", g_sDbPrefix, category, item); 640 | insert_dp.WriteString(buffer); 641 | } 642 | delete hQuery; 643 | } 644 | SQL_UnlockDatabase(h_db); 645 | } 646 | 647 | results.FetchString(i, buffer, sizeof(buffer)); 648 | 649 | int num, item_id; 650 | int itemId[256], count[256], duration[256]; 651 | 652 | int reloc_idx = 0, var2 = 0; 653 | while ((var2 = SplitString(buffer[reloc_idx], ",", part, sizeof(part))) != -1) 654 | { 655 | reloc_idx += var2; 656 | if (!part[0]) continue; 657 | 658 | int ture = FindCharInString(part, '-'); 659 | if (ture != -1) 660 | { 661 | ture++; 662 | strcopy(item, ture, part); 663 | 664 | item_id = StringToInt(item); 665 | duration[item_id] = StringToInt(part[ture]); 666 | } 667 | else 668 | { 669 | item_id = StringToInt(part); 670 | } 671 | if (count[item_id] == 0) 672 | { 673 | itemId[num++] = item_id; 674 | } 675 | count[item_id]++; 676 | } 677 | 678 | for (int x = 0; x < num; x++) 679 | { 680 | h_db.Format(buffer, sizeof(buffer), "INSERT INTO `%sboughts` (`player_id`, `item_id`, `count`, `duration`, `timeleft`, `buy_price`, `sell_price`, `buy_time`) VALUES \ 681 | ('%d', (SELECT `id` FROM `%sitems` WHERE `category` = '%s' AND `item` = (SELECT `item` FROM `%s` WHERE `id` = '%d')), '%d', '%d', '%d', '0', '-1', '%d');", 682 | g_sDbPrefix, id, g_sDbPrefix, category, category, itemId[x], count[itemId[x]], duration[itemId[x]], duration[itemId[x]], global_timer); 683 | upgrade_dp.WriteString(buffer); 684 | } 685 | } 686 | 687 | got_categories = true; 688 | } 689 | 690 | h_db.Format(buffer, sizeof(buffer), "DROP TABLE `%sitems`;", g_sDbPrefix); 691 | DB_TQueryEx(buffer, DBPrio_High); 692 | 693 | DB_CreateTables(); 694 | } 695 | 696 | int num_queries; 697 | void DB_RunUpgrade() 698 | { 699 | PrintToServer("[Shop] Running queries..."); 700 | 701 | char buffer[256]; 702 | 703 | insert_dp.Reset(); 704 | while (IsPackReadable(insert_dp, 1)) 705 | { 706 | insert_dp.ReadString(buffer, sizeof(buffer)); 707 | DB_TQuery(DB_UgradeState_2, buffer); 708 | num_queries++; 709 | } 710 | delete insert_dp; 711 | insert_dp = null; 712 | } 713 | 714 | int num_queries2; 715 | public void DB_UgradeState_2(Database db, DBResultSet results, const char[] error, any data) 716 | { 717 | num_queries--; 718 | 719 | if (error[0]) 720 | { 721 | LogError("DB_UgradeState_2: %s", error); 722 | } 723 | 724 | if (num_queries > 0) 725 | { 726 | return; 727 | } 728 | 729 | char buffer[512]; 730 | 731 | upgrade_dp.Reset(); 732 | 733 | while (IsPackReadable(upgrade_dp, 1)) 734 | { 735 | upgrade_dp.ReadString(buffer, sizeof(buffer)); 736 | DB_TQuery(DB_UgradeState_3, buffer, DBPrio_High); 737 | num_queries2++; 738 | } 739 | 740 | delete upgrade_dp; 741 | upgrade_dp = null; 742 | } 743 | 744 | public void DB_UgradeState_3(Database db, DBResultSet results, const char[] error, any data) 745 | { 746 | num_queries2--; 747 | 748 | if (error[0]) 749 | { 750 | LogError("DB_UgradeState_3: %s", error); 751 | } 752 | 753 | if (num_queries2 > 0) 754 | { 755 | return; 756 | } 757 | 758 | PrintToServer("[Shop] Upgrade to version 2 completed!"); 759 | 760 | OnReadyToStart(); 761 | } 762 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/forwards.sp: -------------------------------------------------------------------------------- 1 | Handle h_fwdOnAuthorized, 2 | h_fwdOnMenuTitle, 3 | h_fwdOnItemDisplay, 4 | h_fwdOnItemDescription, 5 | h_fwdOnItemDraw, 6 | h_fwdOnItemSelect, 7 | h_fwdOnItemSelected, 8 | h_fwdOnItemToggled, 9 | h_fwdOnItemElapsed, 10 | h_fwdOnItemBuy, 11 | h_fwdOnItemSell, 12 | h_fwdOnClientLuckProcess, 13 | h_fwdOnClientShouldLuckItemChance, 14 | h_fwdOnClientItemLucked, 15 | h_fwdOnItemTransfer, 16 | h_fwdOnItemTransfered, 17 | h_fwdOnCreditsTransfer, 18 | h_fwdOnCreditsTransfered, 19 | h_fwdOnCreditsSet, 20 | h_fwdOnCreditsSetPost, 21 | h_fwdOnCreditsGiven, 22 | h_fwdOnCreditsGivenPost, 23 | h_fwdOnCreditsTaken, 24 | h_fwdOnCreditsTakenPost, 25 | h_fwdOnCategoryRegistered, 26 | h_fwdOnItemRegistered; 27 | 28 | void Forward_OnPluginStart() 29 | { 30 | h_fwdOnAuthorized = CreateGlobalForward("Shop_OnAuthorized", ET_Ignore, Param_Cell); 31 | h_fwdOnMenuTitle = CreateGlobalForward("Shop_OnMenuTitle", ET_Hook, Param_Cell, Param_Cell, Param_String, Param_String, Param_Cell); 32 | h_fwdOnItemBuy = CreateGlobalForward("Shop_OnItemBuy", ET_Hook, Param_Cell, Param_Cell, Param_String, Param_Cell, Param_String, Param_Cell, Param_CellByRef, Param_CellByRef, Param_CellByRef); 33 | h_fwdOnItemDraw = CreateGlobalForward("Shop_OnItemDraw", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_CellByRef); 34 | h_fwdOnItemSelect = CreateGlobalForward("Shop_OnItemSelect", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_Cell); 35 | h_fwdOnItemSelected = CreateGlobalForward("Shop_OnItemSelected", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell); 36 | h_fwdOnItemDisplay = CreateGlobalForward("Shop_OnItemDisplay", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_String, Param_String, Param_Cell); 37 | h_fwdOnItemDescription = CreateGlobalForward("Shop_OnItemDescription", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_String, Param_String, Param_Cell); 38 | h_fwdOnItemSell = CreateGlobalForward("Shop_OnItemSell", ET_Hook, Param_Cell, Param_Cell, Param_String, Param_Cell, Param_String, Param_Cell, Param_CellByRef); 39 | h_fwdOnItemToggled = CreateGlobalForward("Shop_OnItemToggled", ET_Ignore, Param_Cell, Param_Cell, Param_String, Param_Cell, Param_String, Param_Cell); 40 | h_fwdOnItemElapsed = CreateGlobalForward("Shop_OnItemElapsed", ET_Ignore, Param_Cell, Param_Cell, Param_String, Param_Cell, Param_String); 41 | h_fwdOnClientLuckProcess = CreateGlobalForward("Shop_OnClientLuckProcess", ET_Hook, Param_Cell); 42 | h_fwdOnClientShouldLuckItemChance = CreateGlobalForward("Shop_OnClientShouldLuckItemChance", ET_Hook, Param_Cell, Param_Cell, Param_CellByRef); 43 | h_fwdOnClientItemLucked = CreateGlobalForward("Shop_OnClientItemLucked", ET_Ignore, Param_Cell, Param_Cell); 44 | h_fwdOnItemTransfer = CreateGlobalForward("Shop_OnItemTransfer", ET_Hook, Param_Cell, Param_Cell, Param_Cell); 45 | h_fwdOnItemTransfered = CreateGlobalForward("Shop_OnItemTransfered", ET_Ignore, Param_Cell, Param_Cell, Param_Cell); 46 | h_fwdOnCreditsTransfer = CreateGlobalForward("Shop_OnCreditsTransfer", ET_Hook, Param_Cell, Param_Cell, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_Cell); 47 | h_fwdOnCreditsTransfered = CreateGlobalForward("Shop_OnCreditsTransfered", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); 48 | h_fwdOnCreditsSet = CreateGlobalForward("Shop_OnCreditsSet", ET_Hook, Param_Cell, Param_CellByRef, Param_Cell); 49 | h_fwdOnCreditsSetPost = CreateGlobalForward("Shop_OnCreditsSet_Post", ET_Ignore, Param_Cell, Param_Cell, Param_Cell); 50 | h_fwdOnCreditsGiven = CreateGlobalForward("Shop_OnCreditsGiven", ET_Hook, Param_Cell, Param_CellByRef, Param_Cell); 51 | h_fwdOnCreditsGivenPost = CreateGlobalForward("Shop_OnCreditsGiven_Post", ET_Ignore, Param_Cell, Param_Cell, Param_Cell); 52 | h_fwdOnCreditsTaken = CreateGlobalForward("Shop_OnCreditsTaken", ET_Hook, Param_Cell, Param_CellByRef, Param_Cell); 53 | h_fwdOnCreditsTakenPost = CreateGlobalForward("Shop_OnCreditsTaken_Post", ET_Ignore, Param_Cell, Param_Cell, Param_Cell); 54 | h_fwdOnCategoryRegistered = CreateGlobalForward("Shop_OnCategoryRegistered", ET_Ignore, Param_Cell, Param_String); 55 | h_fwdOnItemRegistered = CreateGlobalForward("Shop_OnItemRegistered", ET_Ignore, Param_Cell, Param_String, Param_Cell, Param_String); 56 | } 57 | 58 | bool Forward_OnItemTransfer(int client, int target, int item_id) 59 | { 60 | bool result = true; 61 | 62 | Call_StartForward(h_fwdOnItemTransfer); 63 | Call_PushCell(client); 64 | Call_PushCell(target); 65 | Call_PushCell(item_id); 66 | Call_Finish(result); 67 | 68 | return result; 69 | } 70 | 71 | void Forward_OnItemTransfered(int client, int target, int item_id) 72 | { 73 | Call_StartForward(h_fwdOnItemTransfered); 74 | Call_PushCell(client); 75 | Call_PushCell(target); 76 | Call_PushCell(item_id); 77 | Call_Finish(); 78 | } 79 | 80 | Action Forward_OnCreditsTransfer(int client, int target, int &credits_give, int &credits_remove, int &credits_commission, bool bPercent) 81 | { 82 | Action result = Plugin_Continue; 83 | 84 | Call_StartForward(h_fwdOnCreditsTransfer); 85 | Call_PushCell(client); 86 | Call_PushCell(target); 87 | Call_PushCellRef(credits_give); 88 | Call_PushCellRef(credits_remove); 89 | Call_PushCellRef(credits_commission); 90 | Call_PushCell(bPercent); 91 | Call_Finish(result); 92 | 93 | return result; 94 | } 95 | 96 | void Forward_OnCreditsTransfered(int client, int target, int credits_give, int credits_remove, int credits_commission) 97 | { 98 | Call_StartForward(h_fwdOnCreditsTransfered); 99 | Call_PushCell(client); 100 | Call_PushCell(target); 101 | Call_PushCell(credits_give); 102 | Call_PushCell(credits_remove); 103 | Call_PushCell(credits_commission); 104 | Call_Finish(); 105 | } 106 | 107 | bool Forward_OnClientLuckProcess(int client) 108 | { 109 | bool result = true; 110 | 111 | Call_StartForward(h_fwdOnClientLuckProcess); 112 | Call_PushCell(client); 113 | Call_Finish(result); 114 | 115 | return result; 116 | } 117 | 118 | Action Forward_OnClientShouldLuckItemChance(int client, int item_id, int &iLuckChance) 119 | { 120 | Action result = Plugin_Continue; 121 | 122 | Call_StartForward(h_fwdOnClientShouldLuckItemChance); 123 | Call_PushCell(client); 124 | Call_PushCell(item_id); 125 | Call_PushCellRef(iLuckChance); 126 | Call_Finish(result); 127 | 128 | return result; 129 | } 130 | 131 | 132 | void Forward_OnClientItemLucked(int client, int item_id) 133 | { 134 | Call_StartForward(h_fwdOnClientItemLucked); 135 | Call_PushCell(client); 136 | Call_PushCell(item_id); 137 | Call_Finish(); 138 | } 139 | 140 | Action Forward_OnItemDraw(int client, ShopMenu menu_action, int category_id, int item_id, bool &disabled) 141 | { 142 | Action result = Plugin_Continue; 143 | bool call_disable = disabled; 144 | 145 | Call_StartForward(h_fwdOnItemDraw); 146 | Call_PushCell(client); 147 | Call_PushCell(menu_action); 148 | Call_PushCell(category_id); 149 | Call_PushCell(item_id); 150 | Call_PushCellRef(call_disable); 151 | Call_Finish(result); 152 | 153 | if(result == Plugin_Changed) 154 | { 155 | disabled = call_disable; 156 | } 157 | 158 | return result; 159 | } 160 | 161 | Action Forward_OnItemSelect(int client, ShopMenu menu_action, int category_id, int item_id) 162 | { 163 | Action result = Plugin_Continue; 164 | 165 | Call_StartForward(h_fwdOnItemSelect); 166 | Call_PushCell(client); 167 | Call_PushCell(menu_action); 168 | Call_PushCell(category_id); 169 | Call_PushCell(item_id); 170 | Call_Finish(result); 171 | 172 | return result; 173 | } 174 | 175 | void Forward_OnItemSelected(int client, ShopMenu menu_action, int category_id, int item_id) 176 | { 177 | Call_StartForward(h_fwdOnItemSelected); 178 | Call_PushCell(client); 179 | Call_PushCell(menu_action); 180 | Call_PushCell(category_id); 181 | Call_PushCell(item_id); 182 | Call_Finish(); 183 | } 184 | 185 | bool Forward_OnItemDisplay(int client, ShopMenu menu_action, int category_id, int item_id, const char[] display, char[] buffer, int maxlength) 186 | { 187 | bool result = false; 188 | 189 | Call_StartForward(h_fwdOnItemDisplay); 190 | Call_PushCell(client); 191 | Call_PushCell(menu_action); 192 | Call_PushCell(category_id); 193 | Call_PushCell(item_id); 194 | Call_PushString(display); 195 | Call_PushStringEx(buffer, maxlength, SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); 196 | Call_PushCell(maxlength); 197 | Call_Finish(result); 198 | 199 | if (!result) 200 | { 201 | strcopy(buffer, maxlength, display); 202 | } 203 | 204 | return result; 205 | } 206 | 207 | bool Forward_OnItemDescription(int client, ShopMenu menu_action, int category_id, int item_id, const char[] display, char[] buffer, int maxlength) 208 | { 209 | bool result = false; 210 | 211 | Call_StartForward(h_fwdOnItemDescription); 212 | Call_PushCell(client); 213 | Call_PushCell(menu_action); 214 | Call_PushCell(category_id); 215 | Call_PushCell(item_id); 216 | Call_PushString(display); 217 | Call_PushStringEx(buffer, maxlength, SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); 218 | Call_PushCell(maxlength); 219 | Call_Finish(result); 220 | 221 | if (!result) 222 | { 223 | strcopy(buffer, maxlength, display); 224 | } 225 | 226 | return result; 227 | } 228 | 229 | Action Forward_OnCreditsTaken(int client, int &credits, int by_who) 230 | { 231 | Action result = Plugin_Continue; 232 | 233 | Call_StartForward(h_fwdOnCreditsTaken); 234 | Call_PushCell(client); 235 | Call_PushCellRef(credits); 236 | Call_PushCell(by_who); 237 | Call_Finish(result); 238 | 239 | return result; 240 | } 241 | 242 | void Forward_OnCreditsTaken_Post(int client, int credits, int by_who) 243 | { 244 | Call_StartForward(h_fwdOnCreditsTakenPost); 245 | Call_PushCell(client); 246 | Call_PushCell(credits); 247 | Call_PushCell(by_who); 248 | Call_Finish(); 249 | } 250 | 251 | Action Forward_OnCreditsSet(int client, int &credits, int by_who) 252 | { 253 | Action result = Plugin_Continue; 254 | 255 | Call_StartForward(h_fwdOnCreditsSet); 256 | Call_PushCell(client); 257 | Call_PushCellRef(credits); 258 | Call_PushCell(by_who); 259 | Call_Finish(result); 260 | 261 | return result; 262 | } 263 | 264 | void Forward_OnCreditsSet_Post(int client, int credits, int by_who) 265 | { 266 | Call_StartForward(h_fwdOnCreditsSetPost); 267 | Call_PushCell(client); 268 | Call_PushCell(credits); 269 | Call_PushCell(by_who); 270 | Call_Finish(); 271 | } 272 | 273 | Action Forward_OnCreditsGiven(int client, int &credits, int by_who) 274 | { 275 | Action result = Plugin_Continue; 276 | 277 | Call_StartForward(h_fwdOnCreditsGiven); 278 | Call_PushCell(client); 279 | Call_PushCellRef(credits); 280 | Call_PushCell(by_who); 281 | Call_Finish(result); 282 | 283 | return result; 284 | } 285 | 286 | void Forward_OnCreditsGiven_Post(int client, int credits, int by_who) 287 | { 288 | Call_StartForward(h_fwdOnCreditsGivenPost); 289 | Call_PushCell(client); 290 | Call_PushCell(credits); 291 | Call_PushCell(by_who); 292 | Call_Finish(); 293 | } 294 | 295 | void Forward_OnAuthorized(int client) 296 | { 297 | Call_StartForward(h_fwdOnAuthorized); 298 | Call_PushCell(client); 299 | Call_Finish(); 300 | } 301 | 302 | void Forward_OnItemElapsed(int client, int category_id, const char[] category, int item_id, const char[] item) 303 | { 304 | Call_StartForward(h_fwdOnItemElapsed); 305 | Call_PushCell(client); 306 | Call_PushCell(category_id); 307 | Call_PushString(category); 308 | Call_PushCell(item_id); 309 | Call_PushString(item); 310 | Call_Finish(); 311 | } 312 | 313 | void Forward_OnItemToggled(int client, int category_id, const char[] category, int item_id, const char[] item, ToggleState toggle) 314 | { 315 | Call_StartForward(h_fwdOnItemToggled); 316 | Call_PushCell(client); 317 | Call_PushCell(category_id); 318 | Call_PushString(category); 319 | Call_PushCell(item_id); 320 | Call_PushString(item); 321 | Call_PushCell(toggle); 322 | Call_Finish(); 323 | } 324 | 325 | void Forward_NotifyShopLoaded() 326 | { 327 | Handle plugin; 328 | 329 | Handle myhandle = GetMyHandle(); 330 | Handle hIter = GetPluginIterator(); 331 | 332 | while (MorePlugins(hIter)) 333 | { 334 | plugin = ReadPlugin(hIter); 335 | 336 | if (plugin == myhandle || GetPluginStatus(plugin) != Plugin_Running) 337 | { 338 | continue; 339 | } 340 | 341 | Function func = GetFunctionByName(plugin, "Shop_Started"); 342 | 343 | if (IsCallValid(plugin, func)) 344 | { 345 | Call_StartFunction(plugin, func); 346 | Call_Finish(); 347 | } 348 | } 349 | 350 | delete hIter; 351 | } 352 | 353 | void Forward_OnMenuTitle(int client, ShopMenu menu_action, const char[] title, char[] buffer, int maxlength) 354 | { 355 | bool result = false; 356 | 357 | Call_StartForward(h_fwdOnMenuTitle); 358 | Call_PushCell(client); 359 | Call_PushCell(menu_action); 360 | Call_PushString(title); 361 | Call_PushStringEx(buffer, maxlength, SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); 362 | Call_PushCell(maxlength); 363 | Call_Finish(result); 364 | 365 | if (!result) 366 | strcopy(buffer, maxlength, title); 367 | 368 | StrCat(buffer, maxlength, "\n "); 369 | } 370 | 371 | Action Forward_OnItemBuy(int client, int category_id, const char[] category, int item_id, const char[] item, ItemType type, int &price, int &sell_price, int &value) 372 | { 373 | Action result = Plugin_Continue; 374 | 375 | Call_StartForward(h_fwdOnItemBuy); 376 | Call_PushCell(client); 377 | Call_PushCell(category_id); 378 | Call_PushString(category); 379 | Call_PushCell(item_id); 380 | Call_PushString(item); 381 | Call_PushCell(type); 382 | Call_PushCellRef(price); 383 | Call_PushCellRef(sell_price); 384 | Call_PushCellRef(value); 385 | Call_Finish(result); 386 | 387 | return result; 388 | } 389 | 390 | Action Forward_OnItemSell(int client, int category_id, const char[] category, int item_id, const char[] item, ItemType type, int &sell_price) 391 | { 392 | Action result = Plugin_Continue; 393 | 394 | Call_StartForward(h_fwdOnItemSell); 395 | Call_PushCell(client); 396 | Call_PushCell(category_id); 397 | Call_PushString(category); 398 | Call_PushCell(item_id); 399 | Call_PushString(item); 400 | Call_PushCell(type); 401 | Call_PushCellRef(sell_price); 402 | Call_Finish(result); 403 | 404 | return result; 405 | } 406 | 407 | void Forward_OnCategoryRegistered(int category_id, const char[] category) 408 | { 409 | Call_StartForward(h_fwdOnCategoryRegistered); 410 | Call_PushCell(category_id); 411 | Call_PushString(category); 412 | Call_Finish(); 413 | } 414 | 415 | void Forward_OnItemRegistered(int category_id, const char[] category, int item_id, const char[] item) 416 | { 417 | Call_StartForward(h_fwdOnItemRegistered); 418 | Call_PushCell(category_id); 419 | Call_PushString(category); 420 | Call_PushCell(item_id); 421 | Call_PushString(item); 422 | Call_Finish(); 423 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/helpers.sp: -------------------------------------------------------------------------------- 1 | stock bool Helpers_IsPluginValid(Handle plugin) 2 | { 3 | /* Check if the plugin handle is pointing to a valid plugin. */ 4 | Handle hIterator = GetPluginIterator(); 5 | bool bIsValid = false; 6 | 7 | while (MorePlugins(hIterator)) 8 | { 9 | if (plugin == ReadPlugin(hIterator)) 10 | { 11 | bIsValid = (GetPluginStatus(plugin) == Plugin_Running); 12 | break; 13 | } 14 | } 15 | 16 | delete hIterator; 17 | return bIsValid; 18 | } 19 | 20 | stock bool Helpers_CheckClient(int client, char[] error, int length) 21 | { 22 | if (client < 1 || client > MaxClients) 23 | { 24 | FormatEx(error, length, "Client index %i is invalid", client); 25 | return false; 26 | } 27 | else if (!IsClientInGame(client)) 28 | { 29 | FormatEx(error, length, "Client index %i is not in game", client); 30 | return false; 31 | } 32 | else if (IsFakeClient(client)) 33 | { 34 | FormatEx(error, length, "Client index %i is a bot", client); 35 | return false; 36 | } 37 | 38 | error[0] = '\0'; 39 | 40 | return true; 41 | } 42 | 43 | stock void Helpers_GetTimeFromStamp(char[] buffer, int maxlength, int timestamp, int source_client = LANG_SERVER) 44 | { 45 | if (timestamp > 31536000) 46 | { 47 | int years = timestamp / 31536000; 48 | int days = timestamp / 86400 % 365; 49 | if (days > 0) 50 | { 51 | FormatEx(buffer, maxlength, "%d%T %d%T", years, "y.", source_client, days, "d.", source_client); 52 | } 53 | else 54 | { 55 | FormatEx(buffer, maxlength, "%d%T", years, "y."); 56 | } 57 | return; 58 | } 59 | if (timestamp > 86400) 60 | { 61 | int days = timestamp / 86400 % 365; 62 | int hours = (timestamp / 3600) % 24; 63 | if (hours > 0) 64 | { 65 | FormatEx(buffer, maxlength, "%d%T %d%T", days, "d.", source_client, hours, "h.", source_client); 66 | } 67 | else 68 | { 69 | FormatEx(buffer, maxlength, "%d%T", days, "d.", source_client); 70 | } 71 | return; 72 | } 73 | else 74 | { 75 | int Hours = (timestamp / 3600); 76 | int Mins = (timestamp / 60) % 60; 77 | int Secs = timestamp % 60; 78 | 79 | if (Hours > 0) 80 | { 81 | FormatEx(buffer, maxlength, "%02d:%02d:%02d", Hours, Mins, Secs); 82 | } 83 | else 84 | { 85 | FormatEx(buffer, maxlength, "%02d:%02d", Mins, Secs); 86 | } 87 | } 88 | } 89 | 90 | stock bool Helpers_AddTargetsToMenu(Menu menu, int source_client, bool credits = false) 91 | { 92 | bool result = false; 93 | 94 | char userid[9], buffer[MAX_NAME_LENGTH+21]; 95 | for (int i = 1; i <= MaxClients; i++) 96 | { 97 | if (IsAuthorizedIn(i) && (i == source_client || CanUserTarget(source_client, i))) 98 | { 99 | IntToString(GetClientUserId(i), userid, sizeof(userid)); 100 | if (credits) 101 | { 102 | FormatEx(buffer, sizeof(buffer), "%N (%d)", i, GetCredits(i)); 103 | } 104 | else 105 | { 106 | GetClientName(i, buffer, sizeof(buffer)); 107 | } 108 | 109 | menu.AddItem(userid, buffer); 110 | 111 | result = true; 112 | } 113 | } 114 | 115 | return result; 116 | } 117 | 118 | stock int Helpers_GetRandomIntEx(int min, int max) 119 | { 120 | int random = GetURandomInt(); 121 | 122 | if (!random) 123 | random++; 124 | 125 | int number = RoundToCeil(float(random) / (float(2147483647) / float(max - min + 1))) + min - 1; 126 | 127 | return number; 128 | } 129 | 130 | /** 131 | * Makes a negative integer number to a positive integer number. 132 | * This is faster than Sourcemod's native FloatAbs() for integers. 133 | * Use FloatAbs() for Float numbers. 134 | * 135 | * @param number A number that can be positive or negative. 136 | * @return Positive number. 137 | */ 138 | stock int Helpers_Math_Abs(int value) 139 | { 140 | return (value ^ (value >> 31)) - (value >> 31); 141 | } 142 | 143 | /** 144 | * 145 | */ 146 | void Helpers_CloseHandleWithChatReason(Handle hArray, int client, const char[] chatReason) 147 | { 148 | delete hArray; 149 | CPrintToChat(client, "%t", chatReason); 150 | } 151 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/shop/stats.sp: -------------------------------------------------------------------------------- 1 | stock const char API_KEY[] = "e34fa2f3adb922bf76fb7b06807caa3c"; 2 | stock const char URL[] = "http://stats.tibari.dev/api/v1/add_server"; 3 | 4 | /* Stats pusher */ 5 | public void SteamWorks_SteamServersConnected() 6 | { 7 | int iIp[4]; 8 | 9 | // Get ip 10 | if (SteamWorks_GetPublicIP(iIp)) 11 | { 12 | Handle plugin = GetMyHandle(); 13 | if (GetPluginStatus(plugin) == Plugin_Running) 14 | { 15 | char cBuffer[256], cVersion[12]; 16 | GetPluginInfo(plugin, PlInfo_Version, cVersion, sizeof(cVersion)); 17 | FormatEx(cBuffer, sizeof(cBuffer), "%s", URL); 18 | Handle hndl = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, cBuffer); 19 | FormatEx(cBuffer, sizeof(cBuffer), "key=%s&ip=%d.%d.%d.%d&port=%d&version=%s", API_KEY, iIp[0], iIp[1], iIp[2], iIp[3], FindConVar("hostport").IntValue, cVersion); 20 | SteamWorks_SetHTTPRequestRawPostBody(hndl, "application/x-www-form-urlencoded", cBuffer, sizeof(cBuffer)); 21 | SteamWorks_SendHTTPRequest(hndl); 22 | delete hndl; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/pt_p/shop.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | "NoAccessToCommand" 4 | { 5 | "pt_p" "{green}[Loja]{default} Não tens acesso a este comando!" 6 | } 7 | 8 | "TargetNotFound" 9 | { 10 | "#format" "{1:s}" 11 | "pt_p" "{green}[loja]{default} Jogador {green}{1}{default} não encontrado!" 12 | } 13 | 14 | "select_target" 15 | { 16 | "pt_p" "Seleciona o jogador:" 17 | } 18 | 19 | "select_category" 20 | { 21 | "pt_p" "Seleciona a categoria:" 22 | } 23 | 24 | "select_item" 25 | { 26 | "pt_p" "Seleciona o item:" 27 | } 28 | 29 | "no_targets" 30 | { 31 | "pt_p" "{green}[Loja]{default} Sem alvos apropriados!" 32 | } 33 | 34 | "target_left_game" 35 | { 36 | "pt_p" "{green}[Loja]{default} O jogador saiu do jogo!" 37 | } 38 | 39 | "trans_credits_operation" 40 | { 41 | "pt_p" "Escreve a quantidade de créditos para transferir no chat\nou \"cancel\" para cancelar a operação!" 42 | } 43 | 44 | "TransferSuccess" 45 | { 46 | "#format" "{1:i},{2:N}" 47 | "pt_p" "{green}[Loja]{default} Enviaste com sucesso {green}{1}{default} créditos para {green}{2}{default}!" 48 | } 49 | 50 | "ReceiveSuccess" 51 | { 52 | "#format" "{1:i},{2:N}" 53 | "pt_p" "{green}[Loja]{default} Recebeste com sucesso {green}{1}{default} créditos de {green}{2}{default}!" 54 | } 55 | 56 | "ReceiveCommission" 57 | { 58 | "#format" "{1:i}" 59 | "pt_p" "{green}[Loja]{default} Comissão: {green}{1} {default}créditos" 60 | } 61 | 62 | "receive_item" 63 | { 64 | "#format" "{1:N},{2:s},{3:s}" 65 | "pt_p" "{green}[Loja]{default} Recebes-te {green}\"{3}\"{default} para a categoria {green}\"{2}\"{default} de {green}{1}{default}!" 66 | } 67 | 68 | "already_has" 69 | { 70 | "#format" "{1:N}" 71 | "pt_p" "{green}[Loja]{default} O jogador {green}{1}{default} já tem este item!" 72 | } 73 | 74 | "no_item" 75 | { 76 | "pt_p" "{green}[Loja]{default} Não tens este item no teu inventário!" 77 | } 78 | 79 | "IncorrectCredits" 80 | { 81 | "pt_p" "Quantidade insuficiente de créditos!" 82 | } 83 | 84 | "credits_being_transfered" 85 | { 86 | "#format" "{1:i}" 87 | "pt_p" "Quantidade de créditos: {1}" 88 | } 89 | 90 | "credits_to_transfer" 91 | { 92 | "#format" "{1:i}" 93 | "pt_p" "Para enviar: {1}" 94 | } 95 | 96 | "credits_to_transfer_price" 97 | { 98 | "#format" "{1:i}" 99 | "pt_p" "Custo de transferência: {1}" 100 | } 101 | 102 | "credits_to_transfer_commission" 103 | { 104 | "#format" "{1:i}" 105 | "pt_p" "Comissão : {1} créditos" 106 | } 107 | 108 | "transfer_credits_left" 109 | { 110 | "#format" "{1:i}" 111 | "pt_p" "Restantes: {1}" 112 | } 113 | 114 | "need_positive" 115 | { 116 | "#format" "{1:i}" 117 | "pt_p" "Precisas de pelo menos {1} créditos" 118 | } 119 | 120 | "confirm" 121 | { 122 | "pt_p" "Confirmar" 123 | } 124 | 125 | "cancel" 126 | { 127 | "pt_p" "Cancelar" 128 | } 129 | 130 | "transfer" 131 | { 132 | "pt_p" "Transferir" 133 | } 134 | 135 | "ItemTransferMenu" 136 | { 137 | "pt_p" "Transferir item" 138 | } 139 | 140 | "ItemTransferMenu2" 141 | { 142 | "#format" "{1:N}" 143 | "pt_p" "Transferir item\npara {1}" 144 | } 145 | 146 | "give_credits" 147 | { 148 | "pt_p" "Dar créditos" 149 | } 150 | 151 | "take_credits" 152 | { 153 | "pt_p" "Aceitar créditos" 154 | } 155 | 156 | "set_credits" 157 | { 158 | "pt_p" "Definir créditos" 159 | } 160 | 161 | "give_items" 162 | { 163 | "pt_p" "Dar items" 164 | } 165 | 166 | "take_items" 167 | { 168 | "pt_p" "Aceitar items" 169 | } 170 | 171 | "give_item_success" 172 | { 173 | "pt_p" "{green}[Loja]{default} Deste o item com sucesso!" 174 | } 175 | 176 | "take_item_success" 177 | { 178 | "pt_p" "{green}[Loja]{default} Recebeste o item com sucesso!" 179 | } 180 | 181 | "give_credits_success" 182 | { 183 | "#format" "{1:i},{2:s}" 184 | "pt_p" "{green}[Loja]{default} Enviaste {1} créditos para {green}{2}{default}!" 185 | } 186 | 187 | "remove_credits_success" 188 | { 189 | "#format" "{1:i},{2:s}" 190 | "pt_p" "{green}[Loja]{default} Ficaste com {1} créditos de {green}{2}{default}!" 191 | } 192 | 193 | "set_credits_success" 194 | { 195 | "#format" "{1:i},{2:s}" 196 | "pt_p" "{green}[Loja]{default} Enviaste {1} créditos para {green}{2}{default}!" 197 | } 198 | 199 | "set_you_credits" 200 | { 201 | "#format" "{1:i}" 202 | "pt_p" "{green}[Loja]{default} Um STAFF definiu seus créditos para {green}{1}{default}!" 203 | } 204 | 205 | "take_you_credits" 206 | { 207 | "#format" "{1:i}" 208 | "pt_p" "{green}[Loja]{default} Um STAFF ficou com {green}{1}{default} créditos!" 209 | } 210 | 211 | "give_you_credits" 212 | { 213 | "#format" "{1:i}" 214 | "pt_p" "{green}[Loja]{default} Um STAFF deu-te {green}{1}{default} créditos!" 215 | } 216 | 217 | "EmptyInventory" 218 | { 219 | "pt_p" "{green}[Loja]{default} Inventário vazio!" 220 | } 221 | 222 | "EmptyShop" 223 | { 224 | "pt_p" "{green}[Loja]{default} Loja vazia!" 225 | } 226 | 227 | "EmptyCategory" 228 | { 229 | "pt_p" "{green}[Loja]{default} Categoria vazia!" 230 | } 231 | 232 | "MenuEmptyCategory" 233 | { 234 | "pt_p" "Categoria vazia!" 235 | } 236 | 237 | "NothingToLuck" 238 | { 239 | "pt_p" "{green}[Loja]{default} Não há nada que te possa dar sorte!" 240 | } 241 | 242 | "Looser" 243 | { 244 | "pt_p" "{green}[Loja]{default} Tiveste azar! Não ganhas-te nada :(" 245 | } 246 | 247 | "Lucker" 248 | { 249 | "#format" "{1:s},{2:s}" 250 | "pt_p" "{green}[Loja]{default} Tiveste sorte desta vez :). Ganhaste {green}\"{2}\"{default} para a categoria {green}\"{1}\"{default}." 251 | } 252 | 253 | "ItemElapsed" 254 | { 255 | "#format" "{1:s},{2:s}" 256 | "pt_p" "{green}[Loja]{default} O item {green}\"{2}\"{default} da categoria {green}\"{1}\"{default} já não existe!" 257 | } 258 | 259 | "trans_credits" 260 | { 261 | "pt_p" "Transferir créditos" 262 | } 263 | 264 | "trans_credits_commision" 265 | { 266 | "#format" "{1:i}" 267 | "pt_p" "[Comissão: {1}%%]" 268 | } 269 | 270 | "trans_credits_cost" 271 | { 272 | "#format" "{1:i}" 273 | "pt_p" "[Preço: {1}]" 274 | } 275 | 276 | "trans_credits_disabled" 277 | { 278 | "pt_p" "[Desabilitado]" 279 | } 280 | 281 | "luck_disabled" 282 | { 283 | "pt_p" "[Desabilitado]" 284 | } 285 | 286 | "try_luck" 287 | { 288 | "pt_p" "Tenta a tua sorte" 289 | } 290 | 291 | "luck_credits_chance" 292 | { 293 | "#format" "{1:i},{2:i}" 294 | "pt_p" "[Chance: {2}%%|Preço: {1}]" 295 | } 296 | 297 | "Type" 298 | { 299 | "pt_p" "Tipo" 300 | } 301 | 302 | "None" 303 | { 304 | "pt_p" "Nenhum" 305 | } 306 | 307 | "Finite" 308 | { 309 | "pt_p" "Finito" 310 | } 311 | 312 | "Togglable" 313 | { 314 | "pt_p" "Alternável" 315 | } 316 | 317 | "BuyOnly" 318 | { 319 | "pt_p" "Compra apenas" 320 | } 321 | 322 | "Price" 323 | { 324 | "pt_p" "Preço" 325 | } 326 | 327 | "Sell Price" 328 | { 329 | "pt_p" "Preço de venda" 330 | } 331 | 332 | "absolute_sellprice" 333 | { 334 | "pt_p" "Preço no tempo restante" 335 | } 336 | 337 | "Free" 338 | { 339 | "pt_p" "Grátis" 340 | } 341 | 342 | "Unsaleable" 343 | { 344 | "pt_p" "Venda proibida" 345 | } 346 | 347 | "Count" 348 | { 349 | "pt_p" "Conta" 350 | } 351 | 352 | "duration" 353 | { 354 | "pt_p" "Duração" 355 | } 356 | 357 | "forever" 358 | { 359 | "pt_p" "Permanente" 360 | } 361 | 362 | "timeleft" 363 | { 364 | "pt_p" "Tempo restante" 365 | } 366 | 367 | "You have" 368 | { 369 | "pt_p" "Tu tens" 370 | } 371 | 372 | "MainMenuTitle" 373 | { 374 | "pt_p" "Loja" 375 | } 376 | 377 | "Shop" 378 | { 379 | "pt_p" "Loja" 380 | } 381 | 382 | "credits" 383 | { 384 | "#format" "{1:i}" 385 | "pt_p" "Créditos: {1}" 386 | } 387 | 388 | "buy" 389 | { 390 | "pt_p" "Compra" 391 | } 392 | 393 | "buy_not" 394 | { 395 | "pt_p" "Compra [Créditos insuficientes]" 396 | } 397 | 398 | "sell" 399 | { 400 | "pt_p" "Vender" 401 | } 402 | 403 | "inventory" 404 | { 405 | "pt_p" "Inventário" 406 | } 407 | 408 | "use" 409 | { 410 | "pt_p" "Usa" 411 | } 412 | 413 | "ToggleOn" 414 | { 415 | "pt_p" "Ativar" 416 | } 417 | 418 | "ToggleOff" 419 | { 420 | "pt_p" "Desativar" 421 | } 422 | 423 | "preview" 424 | { 425 | "pt_p" "Pré-visualização" 426 | } 427 | 428 | "preview_unavailable" 429 | { 430 | "pt_p" "Pré-visualização indisponível" 431 | } 432 | 433 | "functions" 434 | { 435 | "pt_p" "Funções" 436 | } 437 | 438 | "info" 439 | { 440 | "pt_p" "Info" 441 | } 442 | 443 | "admin_panel" 444 | { 445 | "pt_p" "Painel de Admin" 446 | } 447 | 448 | "Back" 449 | { 450 | "pt_p" "Voltar" 451 | } 452 | 453 | "Exit" 454 | { 455 | "pt_p" "Sair" 456 | } 457 | 458 | "NotEnoughCredits" 459 | { 460 | "pt_p" "{green}[Loja] {default}Créditos insuficientes!" 461 | } 462 | 463 | "PreviewIn" 464 | { 465 | "#format" "{1:i}" 466 | "pt_p" "{green}[Loja]{default} Pré-visualização disponível em {1} sec.!" 467 | } 468 | 469 | "DataLoaded" 470 | { 471 | "#format" "{1:s}" 472 | "pt_p" "{green}[Loja] {default}Os dados da tua Loja foram carregados! Escreve {green}!{1}{default} para abrir a loja!" 473 | } 474 | 475 | "DataLoaded2" 476 | { 477 | "pt_p" "{green}[Loja] {default}Os dados da tua Loja foram carregados!" 478 | } 479 | 480 | "DataLoading" 481 | { 482 | "pt_p" "{green}[Loja] {default}Os teus dados estão a ser carregados!" 483 | } 484 | 485 | "y." 486 | { 487 | "pt_p" "a." 488 | } 489 | 490 | "d." 491 | { 492 | "pt_p" "d." 493 | } 494 | 495 | "h." 496 | { 497 | "pt_p" "h." 498 | } 499 | 500 | "m." 501 | { 502 | "pt_p" "min." 503 | } 504 | 505 | "s." 506 | { 507 | "pt_p" "sec." 508 | } 509 | } 510 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/ru/shop.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | "NoAccessToCommand" 4 | { 5 | "ru" "{green}[Shop]{default} У вас нет доступа к команде!" 6 | } 7 | 8 | "TargetNotFound" 9 | { 10 | "ru" "{green}[Shop]{default} Цель {green}{1}{default} не найдена!" 11 | } 12 | 13 | "select_target" 14 | { 15 | "ru" "Выберите игрока:" 16 | } 17 | 18 | "select_category" 19 | { 20 | "ru" "Выберите категорию:" 21 | } 22 | 23 | "select_item" 24 | { 25 | "ru" "Выберите предмет:" 26 | } 27 | 28 | "no_targets" 29 | { 30 | "ru" "{green}[Shop]{default} Нет подходящих игроков!" 31 | } 32 | 33 | "target_left_game" 34 | { 35 | "ru" "{green}[Shop]{default} Игрок покинул игру!" 36 | } 37 | 38 | "trans_credits_operation" 39 | { 40 | "ru" "Введите в чате количество кредитов для отправки\nили \"cancel\" для отмены!" 41 | } 42 | 43 | "TransferSuccess" 44 | { 45 | "ru" "{green}[Shop]{default} Вы успешно отправили {green}{1}{default} кредит(-ов) игроку {green}{2}{default}!" 46 | } 47 | 48 | "ReceiveSuccess" 49 | { 50 | "ru" "{green}[Shop]{default} Вы успешно получили {green}{1}{default} кредит(-ов) от игрока {green}{2}{default}!" 51 | } 52 | 53 | "ReceiveCommission" 54 | { 55 | "ru" "{green}[Shop]{default} Комиссия составила: {green}{1} {default}кредит(-ов)" 56 | } 57 | 58 | "receive_item" 59 | { 60 | "ru" "{green}[Shop]{default} Вы получили предмет {green}\"{3}\"{default} в категорию {green}\"{2}\"{default} от игрока {green}{1}{default}!" 61 | } 62 | 63 | "already_has" 64 | { 65 | "ru" "{green}[Shop]{default} Игрок {green}{1}{default} уже имеет этот предмет!" 66 | } 67 | 68 | "no_item" 69 | { 70 | "ru" "{green}[Shop]{default} Этот предмет отсутствует в вашем инвентаре!" 71 | } 72 | 73 | "IncorrectCredits" 74 | { 75 | "ru" "Не верное количество кредитов!" 76 | } 77 | 78 | "credits_being_transfered" 79 | { 80 | "ru" "Количество кредитов: {1}" 81 | } 82 | 83 | "credits_to_transfer" 84 | { 85 | "ru" "Будет отправлено: {1}" 86 | } 87 | 88 | "credits_to_transfer_price" 89 | { 90 | "ru" "Цена отправки: {1}" 91 | } 92 | 93 | "credits_to_transfer_commission" 94 | { 95 | "ru" "Комиссия: {1} кредит" 96 | } 97 | 98 | "transfer_credits_left" 99 | { 100 | "ru" "Останется: {1}" 101 | } 102 | 103 | "need_positive" 104 | { 105 | "ru" "Нехватает {1} кредит" 106 | } 107 | 108 | "confirm" 109 | { 110 | "ru" "Подтвердить" 111 | } 112 | 113 | "cancel" 114 | { 115 | "ru" "Отменить" 116 | } 117 | 118 | "transfer" 119 | { 120 | "ru" "Передать" 121 | } 122 | 123 | "ItemTransferMenu" 124 | { 125 | "ru" "Передать предмет" 126 | } 127 | 128 | "ItemTransferMenu2" 129 | { 130 | "ru" "Передать предмет\nигроку {1}" 131 | } 132 | 133 | "give_credits" 134 | { 135 | "ru" "Дать кредиты" 136 | } 137 | 138 | "take_credits" 139 | { 140 | "ru" "Забрать кредиты" 141 | } 142 | 143 | "set_credits" 144 | { 145 | "ru" "Установить кредиты" 146 | } 147 | 148 | "give_items" 149 | { 150 | "ru" "Дать предметы" 151 | } 152 | 153 | "take_items" 154 | { 155 | "ru" "Забрать предметы" 156 | } 157 | 158 | "give_item_success" 159 | { 160 | "ru" "{green}[Shop]{default} Вы успешно дали предмет!" 161 | } 162 | 163 | "take_item_success" 164 | { 165 | "ru" "{green}[Shop]{default} Вы успешно забрали предмет!" 166 | } 167 | 168 | "give_credits_success" 169 | { 170 | "ru" "{green}[Shop]{default} {green}{2}{default} получил(и) {1} кредит!" 171 | } 172 | 173 | "remove_credits_success" 174 | { 175 | "ru" "{green}[Shop]{default} Вы забрали {1} кредит у {green}{2}{default}!" 176 | } 177 | "set_credits_success" 178 | { 179 | "ru" "{green}[Shop]{default} Вы установили {1} кредит игроку {green}{2}{default}!" 180 | } 181 | 182 | "set_you_credits" 183 | { 184 | "ru" "{green}[Shop]{default} Админ установил ваши кредиты на {green}{1}{default}!" 185 | } 186 | 187 | "take_you_credits" 188 | { 189 | "ru" "{green}[Shop]{default} Админ забрал ваши кредиты в количестве {green}{1}{default}!" 190 | } 191 | 192 | "give_you_credits" 193 | { 194 | "ru" "{green}[Shop]{default} Админ дал вам кредиты в количестве {green}{1}{default}!" 195 | } 196 | 197 | "EmptyInventory" 198 | { 199 | "ru" "{green}[Shop]{default} Ваш инвентарь пуст!" 200 | } 201 | 202 | "EmptyShop" 203 | { 204 | "ru" "{green}[Shop]{default} Магазин пустой!" 205 | } 206 | 207 | "EmptyCategory" 208 | { 209 | "ru" "{green}[Shop]{default} Категория пуста!" 210 | } 211 | 212 | "MenuEmptyCategory" 213 | { 214 | "ru" "Категория пуста!" 215 | } 216 | 217 | "NothingToLuck" 218 | { 219 | "ru" "{green}[Shop]{default} Нет ничего, что вы могли бы выйграть!" 220 | } 221 | 222 | "Looser" 223 | { 224 | "ru" "{green}[Shop]{default} Неудача! Вы ничего не получили :(" 225 | } 226 | 227 | "Lucker" 228 | { 229 | "ru" "{green}[Shop]{default} У вас счастливый день :). Вы получили предмет {green}\"{2}\"{default} в категорию {green}\"{1}\"{default}." 230 | } 231 | 232 | "ItemElapsed" 233 | { 234 | "ru" "{green}[Shop]{default} Срок действия {green}\"{2}\"{default} из категории {green}\"{1}\"{default} истекло!" 235 | } 236 | 237 | "trans_credits" 238 | { 239 | "ru" "Передать кредиты" 240 | } 241 | 242 | "trans_credits_commision" 243 | { 244 | "ru" "[Комиссия: {1}%%]" 245 | } 246 | 247 | "trans_credits_cost" 248 | { 249 | "ru" "[Цена: {1}]" 250 | } 251 | 252 | "trans_credits_disabled" 253 | { 254 | "ru" "[Выключен]" 255 | } 256 | 257 | "luck_disabled" 258 | { 259 | "ru" "[Выключен]" 260 | } 261 | "try_luck" 262 | { 263 | "ru" "Испытать удачу" 264 | } 265 | 266 | "luck_credits_chance" 267 | { 268 | "ru" "[Шанс: {2}%%|Цена: {1}]" 269 | } 270 | 271 | "Type" 272 | { 273 | "ru" "Тип" 274 | } 275 | 276 | "None" 277 | { 278 | "ru" "Хранение" 279 | } 280 | 281 | "Finite" 282 | { 283 | "ru" "Количественный" 284 | } 285 | 286 | "Togglable" 287 | { 288 | "ru" "Включаемый" 289 | } 290 | 291 | "BuyOnly" 292 | { 293 | "ru" "Только покупка" 294 | } 295 | 296 | "Price" 297 | { 298 | "ru" "Цена" 299 | } 300 | 301 | "Sell Price" 302 | { 303 | "ru" "Цена продажи" 304 | } 305 | 306 | "absolute_sellprice" 307 | { 308 | "ru" "Цена б/у" 309 | } 310 | 311 | "Free" 312 | { 313 | "ru" "Бесплатно" 314 | } 315 | 316 | "Unsaleable" 317 | { 318 | "ru" "Не продается" 319 | } 320 | 321 | "Count" 322 | { 323 | "ru" "Количество" 324 | } 325 | 326 | "duration" 327 | { 328 | "ru" "Длительность" 329 | } 330 | 331 | "forever" 332 | { 333 | "ru" "Навсегда" 334 | } 335 | 336 | "timeleft" 337 | { 338 | "ru" "Осталось" 339 | } 340 | 341 | "You have" 342 | { 343 | "ru" "У вас" 344 | } 345 | 346 | "MainMenuTitle" 347 | { 348 | "ru" "Магазин" 349 | } 350 | 351 | "Shop" 352 | { 353 | "ru" "Магазин" 354 | } 355 | 356 | "credits" 357 | { 358 | "ru" "Кредитов: {1}" 359 | } 360 | 361 | "buy" 362 | { 363 | "ru" "Купить" 364 | } 365 | 366 | "buy_not" 367 | { 368 | "ru" "Купить [Недостаточно кредитов]" 369 | } 370 | 371 | "sell" 372 | { 373 | "ru" "Продать" 374 | } 375 | 376 | "inventory" 377 | { 378 | "ru" "Инвентарь" 379 | } 380 | 381 | "use" 382 | { 383 | "ru" "Использовать" 384 | } 385 | 386 | "ToggleOn" 387 | { 388 | "ru" "Включить" 389 | } 390 | 391 | "ToggleOff" 392 | { 393 | "ru" "Выключить" 394 | } 395 | 396 | "preview" 397 | { 398 | "ru" "Превью" 399 | } 400 | 401 | "preview_unavailable" 402 | { 403 | "ru" "Превью недоступно" 404 | } 405 | 406 | "functions" 407 | { 408 | "ru" "Функции" 409 | } 410 | 411 | "info" 412 | { 413 | "ru" "Информация" 414 | } 415 | 416 | "admin_panel" 417 | { 418 | "ru" "Панель администратора" 419 | } 420 | 421 | "Back" 422 | { 423 | "ru" "Назад" 424 | } 425 | 426 | "Exit" 427 | { 428 | "ru" "Выход" 429 | } 430 | 431 | "NotEnoughCredits" 432 | { 433 | "ru" "{green}[Shop] {default}Недостаточно кредитов!" 434 | } 435 | 436 | "PreviewIn" 437 | { 438 | "ru" "{green}[Shop] {default}Превью будет доступен через {1} сек.!" 439 | } 440 | 441 | "DataLoaded" 442 | { 443 | "ru" "{green}[Shop] {default}Ваши данные магазина были загружены! Введите в чате {green}!{1}{default} для доступа к магазину!" 444 | } 445 | 446 | "DataLoaded2" 447 | { 448 | "ru" "{green}[Shop] {default}Ваши данные магазина были загружены!" 449 | } 450 | 451 | "DataLoading" 452 | { 453 | "ru" "{green}[Shop] {default}Ваши данные загружаются!" 454 | } 455 | 456 | "You Buy Sure" 457 | { 458 | "ru" "Вы уверены что хотите купить этот предмет?" 459 | } 460 | 461 | "You Sell Sure" 462 | { 463 | "ru" "Вы уверены что хотите продать этот предмет?" 464 | } 465 | 466 | "confirm_luck" 467 | { 468 | "ru" "Вы уверены, что хотите испытать удачу за {1} кредитов?" 469 | } 470 | 471 | "y." 472 | { 473 | "ru" "г." 474 | } 475 | 476 | "d." 477 | { 478 | "ru" "д." 479 | } 480 | 481 | "h." 482 | { 483 | "ru" "ч." 484 | } 485 | 486 | "m." 487 | { 488 | "ru" "мин." 489 | } 490 | 491 | "s." 492 | { 493 | "ru" "сек." 494 | } 495 | } 496 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/shop.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | "NoAccessToCommand" 4 | { 5 | "en" "{green}[Shop]{default} You have no access to this command!" 6 | } 7 | 8 | "TargetNotFound" 9 | { 10 | "#format" "{1:s}" 11 | "en" "{green}[Shop]{default} Target {green}{1}{default} not found!" 12 | } 13 | 14 | "select_target" 15 | { 16 | "en" "Select player:" 17 | } 18 | 19 | "select_category" 20 | { 21 | "en" "Select category:" 22 | } 23 | 24 | "select_item" 25 | { 26 | "en" "Select item:" 27 | } 28 | 29 | "no_targets" 30 | { 31 | "en" "{green}[Shop]{default} No appropriate targets!" 32 | } 33 | 34 | "target_left_game" 35 | { 36 | "en" "{green}[Shop]{default} Player has left the game!" 37 | } 38 | 39 | "trans_credits_operation" 40 | { 41 | "en" "Type amount of credits to transfer in the chat\nor \"cancel\" to cancel the operation!" 42 | } 43 | 44 | "TransferSuccess" 45 | { 46 | "#format" "{1:i},{2:N}" 47 | "en" "{green}[Shop]{default} You have successfully sent {green}{1}{default} credits to {green}{2}{default}!" 48 | } 49 | 50 | "ReceiveSuccess" 51 | { 52 | "#format" "{1:i},{2:N}" 53 | "en" "{green}[Shop]{default} You have successfully received {green}{1}{default} credits from {green}{2}{default}!" 54 | } 55 | 56 | "ReceiveCommission" 57 | { 58 | "#format" "{1:i}" 59 | "en" "{green}[Shop]{default} Withholding fee: {green}{1} {default}credits" 60 | } 61 | 62 | "receive_item" 63 | { 64 | "#format" "{1:N},{2:s},{3:s}" 65 | "en" "{green}[Shop]{default} You have received {green}\"{3}\"{default} to the category {green}\"{2}\"{default} from {green}{1}{default}!" 66 | } 67 | 68 | "already_has" 69 | { 70 | "#format" "{1:N}" 71 | "en" "{green}[Shop]{default} Player {green}{1}{default} already has the item!" 72 | } 73 | 74 | "no_item" 75 | { 76 | "en" "{green}[Shop]{default} The item isn't exists in your inventory!" 77 | } 78 | 79 | "IncorrectCredits" 80 | { 81 | "en" "Not faithful amount of credits!" 82 | } 83 | 84 | "credits_being_transfered" 85 | { 86 | "#format" "{1:i}" 87 | "en" "Amount of credits: {1}" 88 | } 89 | 90 | "credits_to_transfer" 91 | { 92 | "#format" "{1:i}" 93 | "en" "Being sent: {1}" 94 | } 95 | 96 | "credits_to_transfer_price" 97 | { 98 | "#format" "{1:i}" 99 | "en" "Transfer cost: {1}" 100 | } 101 | 102 | "credits_to_transfer_commission" 103 | { 104 | "#format" "{1:i}" 105 | "en" "Commission : {1} credits" 106 | } 107 | 108 | "transfer_credits_left" 109 | { 110 | "#format" "{1:i}" 111 | "en" "Remain: {1}" 112 | } 113 | 114 | "need_positive" 115 | { 116 | "#format" "{1:i}" 117 | "en" "Need at least {1} credits" 118 | } 119 | 120 | "confirm" 121 | { 122 | "en" "Confirm" 123 | } 124 | 125 | "cancel" 126 | { 127 | "en" "Cancel" 128 | } 129 | 130 | "transfer" 131 | { 132 | "en" "Transfer" 133 | } 134 | 135 | "ItemTransferMenu" 136 | { 137 | "en" "Transfer item" 138 | } 139 | 140 | "ItemTransferMenu2" 141 | { 142 | "#format" "{1:N}" 143 | "en" "Transfer item\nto {1}" 144 | } 145 | 146 | "give_credits" 147 | { 148 | "en" "Give credits" 149 | } 150 | 151 | "take_credits" 152 | { 153 | "en" "Take credits" 154 | } 155 | 156 | "set_credits" 157 | { 158 | "en" "Set credits" 159 | } 160 | 161 | "give_items" 162 | { 163 | "en" "Give items" 164 | } 165 | 166 | "take_items" 167 | { 168 | "en" "Take items" 169 | } 170 | 171 | "give_item_success" 172 | { 173 | "en" "{green}[Shop]{default} You have successfuly gave the item!" 174 | } 175 | 176 | "take_item_success" 177 | { 178 | "en" "{green}[Shop]{default} You have successfuly took the item!" 179 | } 180 | 181 | "give_credits_success" 182 | { 183 | "#format" "{1:i},{2:s}" 184 | "en" "{green}[Shop]{default} You have sent {1} credits to {green}{2}{default}!" 185 | } 186 | 187 | "remove_credits_success" 188 | { 189 | "#format" "{1:i},{2:s}" 190 | "en" "{green}[Shop]{default} You have took {1} credits from {green}{2}{default}!" 191 | } 192 | 193 | "set_credits_success" 194 | { 195 | "#format" "{1:i},{2:s}" 196 | "en" "{green}[Shop]{default} You have set {1} credits to {green}{2}{default}!" 197 | } 198 | 199 | "set_you_credits" 200 | { 201 | "#format" "{1:i}" 202 | "en" "{green}[Shop]{default} Admin has set your credits to {green}{1}{default}!" 203 | } 204 | 205 | "take_you_credits" 206 | { 207 | "#format" "{1:i}" 208 | "en" "{green}[Shop]{default} Admin has took {green}{1}{default} credits!" 209 | } 210 | 211 | "give_you_credits" 212 | { 213 | "#format" "{1:i}" 214 | "en" "{green}[Shop]{default} Admin has gave you {green}{1}{default} credits!" 215 | } 216 | 217 | "EmptyInventory" 218 | { 219 | "en" "{green}[Shop]{default} Your inventory is empty!" 220 | } 221 | 222 | "EmptyShop" 223 | { 224 | "en" "{green}[Shop]{default} Shop is empty!" 225 | } 226 | 227 | "EmptyCategory" 228 | { 229 | "en" "{green}[Shop]{default} The category is empty!" 230 | } 231 | 232 | "MenuEmptyCategory" 233 | { 234 | "en" "The category is empty!" 235 | } 236 | 237 | "NothingToLuck" 238 | { 239 | "en" "{green}[Shop]{default} There is nothing that you can luck!" 240 | } 241 | 242 | "Looser" 243 | { 244 | "en" "{green}[Shop]{default} No luck! You have got nothing :(" 245 | } 246 | 247 | "Lucker" 248 | { 249 | "#format" "{1:s},{2:s}" 250 | "en" "{green}[Shop]{default} You have a lucky day :). You have got {green}\"{2}\"{default} to the category {green}\"{1}\"{default}." 251 | } 252 | 253 | "ItemElapsed" 254 | { 255 | "#format" "{1:s},{2:s}" 256 | "en" "{green}[Shop]{default} Item {green}\"{2}\"{default} from category {green}\"{1}\"{default} has been elapsed!" 257 | } 258 | 259 | "trans_credits" 260 | { 261 | "en" "Transfer credits" 262 | } 263 | 264 | "trans_credits_commision" 265 | { 266 | "#format" "{1:i}" 267 | "en" "[Commission: {1}%%]" 268 | } 269 | 270 | "trans_credits_cost" 271 | { 272 | "#format" "{1:i}" 273 | "en" "[Price: {1}]" 274 | } 275 | 276 | "trans_credits_disabled" 277 | { 278 | "en" "[Disabled]" 279 | } 280 | 281 | "luck_disabled" 282 | { 283 | "en" "[Disabled]" 284 | } 285 | 286 | "try_luck" 287 | { 288 | "en" "Try a luck" 289 | } 290 | 291 | "luck_credits_chance" 292 | { 293 | "#format" "{1:i},{2:i}" 294 | "en" "[Chance: {2}%%|Price: {1}]" 295 | } 296 | 297 | "Type" 298 | { 299 | "en" "Type" 300 | } 301 | 302 | "None" 303 | { 304 | "en" "None" 305 | } 306 | 307 | "Finite" 308 | { 309 | "en" "Finite" 310 | } 311 | 312 | "Togglable" 313 | { 314 | "en" "Togglable" 315 | } 316 | 317 | "BuyOnly" 318 | { 319 | "en" "Buy only" 320 | } 321 | 322 | "Price" 323 | { 324 | "en" "Price" 325 | } 326 | 327 | "Sell Price" 328 | { 329 | "en" "Sell price" 330 | } 331 | 332 | "absolute_sellprice" 333 | { 334 | "en" "Timeleft's price" 335 | } 336 | 337 | "Free" 338 | { 339 | "en" "Free" 340 | } 341 | 342 | "Unsaleable" 343 | { 344 | "en" "Unsaleable" 345 | } 346 | 347 | "Count" 348 | { 349 | "en" "Count" 350 | } 351 | 352 | "duration" 353 | { 354 | "en" "Duration" 355 | } 356 | 357 | "forever" 358 | { 359 | "en" "Forever" 360 | } 361 | 362 | "timeleft" 363 | { 364 | "en" "Timeleft" 365 | } 366 | 367 | "You have" 368 | { 369 | "en" "You have" 370 | } 371 | 372 | "MainMenuTitle" 373 | { 374 | "en" "Shop" 375 | } 376 | 377 | "Shop" 378 | { 379 | "en" "Shop" 380 | } 381 | 382 | "credits" 383 | { 384 | "#format" "{1:i}" 385 | "en" "Credits: {1}" 386 | } 387 | 388 | "buy" 389 | { 390 | "en" "Buy" 391 | } 392 | 393 | "buy_not" 394 | { 395 | "en" "Buy [Insufficient credits]" 396 | } 397 | 398 | "sell" 399 | { 400 | "en" "Sell" 401 | } 402 | 403 | "inventory" 404 | { 405 | "en" "Inventory" 406 | } 407 | 408 | "use" 409 | { 410 | "en" "Use" 411 | } 412 | 413 | "ToggleOn" 414 | { 415 | "en" "Toggle On" 416 | } 417 | 418 | "ToggleOff" 419 | { 420 | "en" "Toggle Off" 421 | } 422 | 423 | "preview" 424 | { 425 | "en" "Preview" 426 | } 427 | 428 | "preview_unavailable" 429 | { 430 | "en" "Preview unavailable" 431 | } 432 | 433 | "functions" 434 | { 435 | "en" "Functions" 436 | } 437 | 438 | "info" 439 | { 440 | "en" "Info" 441 | } 442 | 443 | "admin_panel" 444 | { 445 | "en" "Admin panel" 446 | } 447 | 448 | "Back" 449 | { 450 | "en" "Back" 451 | } 452 | 453 | "Exit" 454 | { 455 | "en" "Exit" 456 | } 457 | 458 | "NotEnoughCredits" 459 | { 460 | "en" "{green}[Shop] {default}Insufficient credits!" 461 | } 462 | 463 | "PreviewIn" 464 | { 465 | "#format" "{1:i}" 466 | "en" "{green}[Shop] {default}Preview will be available in {1} sec.!" 467 | } 468 | 469 | "DataLoaded" 470 | { 471 | "#format" "{1:s}" 472 | "en" "{green}[Shop] {default}You data of the shop has been loaded! Type {green}!{1}{default} to open the shop!" 473 | } 474 | 475 | "DataLoaded2" 476 | { 477 | "en" "{green}[Shop] {default}You data of the shop has been loaded!" 478 | } 479 | 480 | "DataLoading" 481 | { 482 | "en" "{green}[Shop] {default}Your data is being loaded!" 483 | } 484 | 485 | "You Buy Sure" 486 | { 487 | "en" "Are you sure to purchase this item?" 488 | } 489 | 490 | "You Sell Sure" 491 | { 492 | "en" "Are you sure to sell this item?" 493 | } 494 | 495 | "confirm_luck" 496 | { 497 | "#format" "{1:i}" 498 | "en" "Are you sure to spend {1} credits for Try a Luck?" 499 | } 500 | 501 | "y." 502 | { 503 | "en" "y." 504 | } 505 | 506 | "d." 507 | { 508 | "en" "d." 509 | } 510 | 511 | "h." 512 | { 513 | "en" "h." 514 | } 515 | 516 | "m." 517 | { 518 | "en" "min." 519 | } 520 | 521 | "s." 522 | { 523 | "en" "sec." 524 | } 525 | } 526 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/ua/shop.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | "NoAccessToCommand" 4 | { 5 | "ua" "{green}[Shop]{default} У вас немає доступу до цієї команди" 6 | } 7 | 8 | "TargetNotFound" 9 | { 10 | "ua" "{green}[Shop]{default} Ціль {green}{1}{default} не знайдена!" 11 | } 12 | "select_target" 13 | { 14 | "ua" "Оберіть гравця:" 15 | } 16 | 17 | "select_category" 18 | { 19 | "ua" "Оберіть категорію:" 20 | } 21 | 22 | "select_item" 23 | { 24 | "ua" "Оберіть предмет:" 25 | } 26 | 27 | "no_targets" 28 | { 29 | "ua" "{green}[Shop]{default} Не знайдено відповідних гравців!" 30 | } 31 | 32 | "target_left_game" 33 | { 34 | "ua" "{green}[Shop]{default} Гравець покинув гру!" 35 | } 36 | 37 | "trans_credits_operation" 38 | { 39 | "ua" "Надрукуйте в чаті кількість кредитів для відправки\nабо \"cancel\" для скасування!" 40 | } 41 | 42 | "TransferSuccess" 43 | { 44 | "ua" "{green}[Shop]{default} Ви успішно відправили {green}{1}{default} кредит(-ів) гравцю {green}{2}{default}!" 45 | } 46 | 47 | "ReceiveSuccess" 48 | { 49 | "ua" "{green}[Shop]{default} Ви успішно отримали {green}{1}{default} кредит(-ів) від гравця {green}{2}{default}!" 50 | } 51 | 52 | "ReceiveCommission" 53 | { 54 | "ua" "{green}[Shop]{default} Комісія склала: {green}{1} {default}кредит(-ів)" 55 | } 56 | 57 | "receive_item" 58 | { 59 | "ua" "{green}[Shop]{default} Ви успішно отримали {green}\"{3}\"{default} в категорію {green}\"{2}\"{default} від гравця {green}{1}{default}!" 60 | } 61 | 62 | "already_has" 63 | { 64 | "ua" "{green}[Shop]{default} Гравець {green}{1}{default} вже має цей предмет!" 65 | } 66 | 67 | "no_item" 68 | { 69 | "ua" "{green}[Shop]{default} Цей предмет відсутній в вашому інвентарі!" 70 | } 71 | 72 | "IncorrectCredits" 73 | { 74 | "ua" "Не правильна кількість кредитів!" 75 | } 76 | 77 | "credits_being_transfered" 78 | { 79 | "ua" "Кількість кредитів: {1}" 80 | } 81 | 82 | "credits_to_transfer" 83 | { 84 | "ua" "Буде відправлено: {1}" 85 | } 86 | 87 | "credits_to_transfer_price" 88 | { 89 | "ua" "Ціна відправки: {1}" 90 | } 91 | 92 | "credits_to_transfer_commission" 93 | { 94 | "ua" "Комісія: {1} кредит" 95 | } 96 | 97 | "transfer_credits_left" 98 | { 99 | "ua" "Залишиться: {1}" 100 | } 101 | 102 | "need_positive" 103 | { 104 | "ua" "Не вистачає {1} кредит" 105 | } 106 | 107 | "confirm" 108 | { 109 | "ua" "Підтвердити" 110 | } 111 | 112 | "cancel" 113 | { 114 | "ua" "Скасувати" 115 | } 116 | 117 | "transfer" 118 | { 119 | "ua" "Передати" 120 | } 121 | 122 | "ItemTransferMenu" 123 | { 124 | "ua" "Передати предмет" 125 | } 126 | 127 | "ItemTransferMenu2" 128 | { 129 | "ua" "Передати предмет\nгравцю {1}" 130 | } 131 | 132 | "give_credits" 133 | { 134 | "ua" "Дати кредити" 135 | } 136 | 137 | "take_credits" 138 | { 139 | "ua" "Забрати кредити" 140 | } 141 | 142 | "set_credits" 143 | { 144 | "ua" "Встановити кредити" 145 | } 146 | 147 | "give_items" 148 | { 149 | "ua" "Дати предмети" 150 | } 151 | 152 | "take_items" 153 | { 154 | "ua" "Забрати предмети" 155 | } 156 | 157 | "give_item_success" 158 | { 159 | "ua" "{green}[Shop]{default} Ви успішно дали предмет!" 160 | } 161 | 162 | "take_item_success" 163 | { 164 | "ua" "{green}[Shop]{default} Ви успішно забрали предмет!" 165 | } 166 | 167 | "give_credits_success" 168 | { 169 | "ua" "{green}[Shop]{default} {green}{2}{default} отримав {1} кредит!" 170 | } 171 | 172 | "remove_credits_success" 173 | { 174 | "ua" "{green}[Shop]{default} Ви забрали {1} кредит у {green}{2}{default}!" 175 | } 176 | 177 | "set_credits_success" 178 | { 179 | "ua" "{green}[Shop]{default} Ви встановили {1} кредит гравцеві {green}{2}{default}!" 180 | } 181 | 182 | "set_you_credits" 183 | { 184 | "ua" "{green}[Shop]{default} Адмін встановив ваші кредити на {green}{1}{default}!" 185 | } 186 | 187 | "take_you_credits" 188 | { 189 | "ua" "{green}[Shop]{default} Адмін забрав ваші кредити в кількості {green}{1}{default}!" 190 | } 191 | 192 | "give_you_credits" 193 | { 194 | "ua" "{green}[Shop]{default} Адмін дав вам кредити в кількості {green}{1}{default}!" 195 | } 196 | 197 | "EmptyInventory" 198 | { 199 | "ua" "{green}[Shop]{default} Ваш інвентар порожній!" 200 | } 201 | 202 | "EmptyShop" 203 | { 204 | "ua" "{green}[Shop]{default} Крамниця порожня!" 205 | } 206 | 207 | "EmptyCategory" 208 | { 209 | "ua" "{green}[Shop]{default} Категорія порожня!" 210 | } 211 | 212 | "MenuEmptyCategory" 213 | { 214 | "en" "Категорія порожня!" 215 | } 216 | 217 | "NothingToLuck" 218 | { 219 | "ua" "{green}[Shop]{default} Немає нічого, що ви могли б виграти!" 220 | } 221 | 222 | "Looser" 223 | { 224 | "ua" "{green}[Shop]{default} Невдача! Ви нічого не отримали :(" 225 | } 226 | 227 | "Lucker" 228 | { 229 | "ua" "{green}[Shop]{default} У вас щасливий день :). Ви отримали предмет {green}\"{2}\"{default} в категорію {green}\"{1}\"{default}." 230 | } 231 | 232 | "ItemElapsed" 233 | { 234 | "ua" "{green}[Shop]{default} Термін дії {green}\"{2}\"{default} з категорії {green}\"{1}\"{default} минув!" 235 | } 236 | 237 | "trans_credits" 238 | { 239 | "ua" "Передати кредити" 240 | } 241 | 242 | "trans_credits_commision" 243 | { 244 | "ua" "[Комісія: {1}%%]" 245 | } 246 | 247 | "trans_credits_cost" 248 | { 249 | "ua" "[Ціна: {1}]" 250 | } 251 | 252 | "trans_credits_disabled" 253 | { 254 | "ua" "[Вимкнений]" 255 | } 256 | 257 | "luck_disabled" 258 | { 259 | "ua" "[Вимкнений]" 260 | } 261 | 262 | "try_luck" 263 | { 264 | "ua" "Випробувати вдачу" 265 | } 266 | 267 | "luck_credits_chance" 268 | { 269 | "ua" "[Шанс: {2}%%|Ціна: {1}]" 270 | } 271 | 272 | "Type" 273 | { 274 | "ua" "Тип" 275 | } 276 | 277 | "None" 278 | { 279 | "ua" "Зберігання" 280 | } 281 | 282 | "Finite" 283 | { 284 | "ua" "Кількісний" 285 | } 286 | 287 | "Togglable" 288 | { 289 | "ua" "Що включається" //IDK 290 | } 291 | 292 | "BuyOnly" 293 | { 294 | "ua" "Тільки покупка" 295 | } 296 | 297 | "Price" 298 | { 299 | "ua" "Ціна" 300 | } 301 | 302 | "Sell Price" 303 | { 304 | "ua" "Ціна продажу" 305 | } 306 | 307 | "absolute_sellprice" 308 | { 309 | "ua" "Ціна б/у" 310 | } 311 | 312 | "Free" 313 | { 314 | "ua" "Безкоштовно" 315 | } 316 | 317 | "Unsaleable" 318 | { 319 | "ua" "Не продається" 320 | } 321 | 322 | "Count" 323 | { 324 | "ua" "Кількість" 325 | } 326 | 327 | "duration" 328 | { 329 | "ua" "Тривалість" 330 | } 331 | 332 | "forever" 333 | { 334 | "ua" "Назавжди" 335 | } 336 | 337 | "timeleft" 338 | { 339 | "ua" "Залишилось" 340 | } 341 | 342 | "You have" 343 | { 344 | "ua" "У вас є" 345 | } 346 | 347 | "MainMenuTitle" 348 | { 349 | "ua" "Магазин" 350 | } 351 | 352 | "Shop" 353 | { 354 | "ua" "Магазин" 355 | } 356 | 357 | "credits" 358 | { 359 | "ua" "Кредитів: {1}" 360 | } 361 | 362 | "buy" 363 | { 364 | "ua" "Придбати" 365 | } 366 | 367 | "buy_not" 368 | { 369 | "ua" "Придбати [Недостатньо кредитів]" 370 | } 371 | 372 | "sell" 373 | { 374 | "ua" "Продати" 375 | } 376 | 377 | "inventory" 378 | { 379 | "ua" "Інвентар" 380 | } 381 | 382 | "use" 383 | { 384 | "ua" "Використати" 385 | } 386 | 387 | "ToggleOn" 388 | { 389 | "ua" "Увімкнути" 390 | } 391 | 392 | "ToggleOff" 393 | { 394 | "ua" "Вимкнути" 395 | } 396 | 397 | "preview" 398 | { 399 | "ua" "Прев'ю" 400 | } 401 | 402 | "preview_unavailable" 403 | { 404 | "ua" "Прев'ю недоступне" 405 | } 406 | 407 | "functions" 408 | { 409 | "ua" "Функції" 410 | } 411 | 412 | "info" 413 | { 414 | "ua" "Інформація" 415 | } 416 | 417 | "admin_panel" 418 | { 419 | "ua" "Панель Адміністратора" 420 | } 421 | 422 | "Back" 423 | { 424 | "ua" "Назад" 425 | } 426 | 427 | "Exit" 428 | { 429 | "ua" "Вихід" 430 | } 431 | 432 | "NotEnoughCredits" 433 | { 434 | "ua" "{green}[Shop] {default}Недостатньо кредитів!" 435 | } 436 | 437 | "PreviewIn" 438 | { 439 | "ua" "{green}[Shop] {default}Прев'ю буде доступне через {1} сек.!" 440 | } 441 | 442 | "DataLoaded" 443 | { 444 | "ua" "{green}[Shop] {default}Ваші дані магазину були завантажені! Введіть в чаті {green}!{1}{default} для доступу до магазину!" 445 | } 446 | 447 | "DataLoaded2" 448 | { 449 | "ua" "{green}[Shop] {default}Ваші дані магазину були завантажені!" 450 | } 451 | 452 | "DataLoading" 453 | { 454 | "ua" "{green}[Shop] {default}Ваші дані завантажуються!" 455 | } 456 | 457 | "y." 458 | { 459 | "ua" "р." 460 | } 461 | 462 | "d." 463 | { 464 | "ua" "д." 465 | } 466 | 467 | "h." 468 | { 469 | "ua" "г." 470 | } 471 | 472 | "m." 473 | { 474 | "ua" "хв." 475 | } 476 | 477 | "s." 478 | { 479 | "ua" "сек." 480 | } 481 | } 482 | -------------------------------------------------------------------------------- /cfg/shop/shop.cfg: -------------------------------------------------------------------------------- 1 | // Set flags for admin panel access. Set several flags if necessary. Ex: "abcz" 2 | // - 3 | // Default: "z" 4 | sm_shop_admin_flags "z" 5 | 6 | // How many credits an item transfer cost. Set -1 to disable the feature 7 | // - 8 | // Default: "500" 9 | // Minimum: "-1.000000" 10 | sm_shop_item_transfer_credits "500" 11 | 12 | // How many chance the luck can be succeded 13 | // - 14 | // Default: "20" 15 | // Minimum: "1.000000" 16 | // Maximum: "100.000000" 17 | sm_shop_luck_chance "20" 18 | 19 | // How many credits the luck cost 20 | // - 21 | // Default: "500" 22 | // Minimum: "0.000000" 23 | sm_shop_luck_credits "500" 24 | 25 | // Start credits for a new player 26 | // - 27 | // Default: "0" 28 | // Minimum: "0.000000" 29 | sm_shop_start_credits "0" 30 | 31 | // Timing method to use for timed items. 0 time while using and 1 is real time 32 | // - 33 | // Default: "0" 34 | // Minimum: "0.000000" 35 | // Maximum: "1.000000" 36 | sm_shop_timer_method "0" 37 | 38 | // Use % to make the transfer to cost the commision or without % to make it cost as the cvar set or -1 to disable this feature 39 | // - 40 | // Default: "%5" 41 | // Minimum: "-1.000000" 42 | sm_shop_trans_credits "%5" 43 | 44 | // Hide amount of items in category 45 | // - 46 | // Default: "0" 47 | // Minimum "0" 48 | // Maximum "1" 49 | sm_shop_category_items_hideamount "0" 50 | 51 | // Enable confirm item purchase menu or not, Set this to 0 the client will purchase instantly after press buy button. 52 | // - 53 | // Default: "0" 54 | // Minimum "0" 55 | // Maximum "1" 56 | sm_shop_confirm_buy "1" 57 | 58 | // Enable confirm item selling menu or not, Set this to 0 the client will sell item instantly after press sell button. 59 | // - 60 | // Default: "0" 61 | // Minimum "0" 62 | // Maximum "1" 63 | sm_shop_confirm_sell "1" 64 | 65 | // Enable confirm try luck menu or not, Set this to 0 the client will try a luck instantly after press a button. 66 | // - 67 | // Default: "0" 68 | // Minimum "0" 69 | // Maximum "1" 70 | sm_shop_confirm_tryluck "1" 71 | --------------------------------------------------------------------------------