Skip to content

Commit

Permalink
Release no_autopickup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Apr 14, 2024
1 parent e23cb98 commit 5757dfb
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/no_autopickup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: no_autopickup

on:
push:
branches:
- main
paths:
- '.github/workflows/no_autopickup.yaml'
- 'resources/no_autopickup.json'
- 'scripts/mikk/*'
- 'scripts/plugins/no_autopickup.*'

permissions:
contents: write
packages: write
pull-requests: write

env:
APP_NAME: no_autopickup

jobs:

build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Installing Python
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Repack resources
run: python3 build.py ${{ env.APP_NAME }}

- name: Create Release
uses: xresloader/upload-to-github-release@v1.5.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "assets.zip"
default_release_body_path: CHANGELOG.md
overwrite: true
tags: true
draft: false
prerelease: false
tag_name: ${{ env.APP_NAME }}
branches: main
default_release_name: ${{ env.APP_NAME }}
token: ${{ secrets.GITHUB_TOKEN }}
target_owner: Mikk155
target_repo: Sven-Co-op
11 changes: 11 additions & 0 deletions resources/no_autopickup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Include":
[
"shared"
],
"Resources":
[
"scripts/plugins/mikk/no_autopickup.as",
"scripts/plugins/mikk/no_autopickup.json"
]
}
69 changes: 69 additions & 0 deletions scripts/plugins/mikk/no_autopickup.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//==========================================================================================================================================\\
// \\
// Creative Commons Attribution-NonCommercial 4.0 International \\
// https://creativecommons.org/licenses/by-nc/4.0/ \\
// \\
// * You are free to: \\
// * Copy and redistribute the material in any medium or format. \\
// * Remix, transform, and build upon the material. \\
// \\
// * Under the following terms: \\
// * You must give appropriate credit, provide a link to the license, and indicate if changes were made. \\
// * You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. \\
// * You may not use the material for commercial purposes. \\
// * You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. \\
// \\
//==========================================================================================================================================\\

#include '../../mikk/shared'

void PluginInit()
{
g_Module.ScriptInfo.SetAuthor( "Gaftherman" );
g_Module.ScriptInfo.SetContactInfo( Mikk.GetContactInfo() );

g_Hooks.RegisterHook( Hooks::PickupObject::CanCollect, @CanCollect );

pJson.load( 'plugins/mikk/no_autopickup.json' );
pItems = pJson[ 'ItemList', {} ];
}

json pItems;
json pJson;

HookReturnCode CanCollect( CBaseEntity@ pPickup, CBaseEntity@ pOther, bool& out bResult )
{
if( pPickup !is null && pOther !is null && pOther.IsPlayer() )
{
for( uint ui = 0; ui < pItems.length(); ui++ )
{
if( pPickup.GetClassname() == pItems[ui,''] || pItems[ui,''].EndsWith( '*' )
&& pPickup.GetClassname().StartsWith( pItems[ui, ''].SubString( 0, pItems[ui, ''].Length() - 1 ) ) ) {

if( pJson[ 'MessagePlayer', false ] )
{
string name = String::EMPTY_STRING;

array<string> str = pPickup.GetClassname().Split( '_' );

if( str.length() > 2 )
{
for( uint u = 1; u < str.length(); u++ )
{
name += ( u == 1 ? '' : '_' ) + str[u];
}
}
else if( str.length() == 2 )
{
name = str[1];
}

Mikk.Language.Print( cast<CBasePlayer@>( pOther ), pJson[ 'PickMeMessage', {} ], MKLANG::BIND, { { 'item', name } } );
}

bResult = ( ( pOther.pev.button & IN_USE ) != 0 );
}
}
}
return HOOK_CONTINUE;
}
21 changes: 21 additions & 0 deletions scripts/plugins/mikk/no_autopickup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// true = tell players to press E
// false = don't tell ( use less resources )
"MessagePlayer": true,

// List of items this plugin supports. supports ending wildcard as asterisk (*)
"ItemList":
[
"weapon_*",
"item_healthkit",
"item_battery",
"weaponbox",
"ammo_*"
],

"PickMeMessage":
{
"english": "+use pickup $item$",
"spanish": "+use recoger $item$"
}
}

0 comments on commit 5757dfb

Please sign in to comment.