-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e99586b
Showing
17 changed files
with
3,662 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: | ||
import os, sys | ||
|
||
projectName = 'sample' | ||
|
||
# smsdk_ext.cpp will be automatically added later | ||
sourceFiles = [ | ||
'extension.cpp', | ||
'natives.cpp', | ||
] | ||
|
||
############### | ||
# Make sure to edit PackageScript, which copies your files to their appropriate locations | ||
# Simple extensions do not need to modify past this point. | ||
|
||
project = Extension.HL2Project(builder, projectName + '.ext') | ||
|
||
if os.path.isfile(os.path.join(builder.currentSourcePath, 'sdk', 'smsdk_ext.cpp')): | ||
# Use the copy included in the project | ||
project.sources += [os.path.join('sdk', 'smsdk_ext.cpp')] | ||
else: | ||
# Use the copy included with SM 1.6 and newer | ||
project.sources += [os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp')] | ||
|
||
project.sources += sourceFiles | ||
|
||
for sdk_name in Extension.sdks: | ||
sdk = Extension.sdks[sdk_name] | ||
|
||
binary = Extension.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk) | ||
|
||
Extension.extensions = builder.Add(project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: | ||
import os | ||
|
||
# This is where the files will be output to | ||
# package is the default | ||
builder.SetBuildFolder('package') | ||
|
||
# Add any folders you need to this list | ||
folder_list = [ | ||
'addons/sourcemod/extensions', | ||
#'addons/sourcemod/scripting/include', | ||
#'addons/sourcemod/gamedata', | ||
#'addons/sourcemod/configs', | ||
] | ||
|
||
# Create the distribution folder hierarchy. | ||
folder_map = {} | ||
for folder in folder_list: | ||
norm_folder = os.path.normpath(folder) | ||
folder_map[folder] = builder.AddFolder(norm_folder) | ||
|
||
# Do all straight-up file copies from the source tree. | ||
def CopyFiles(src, dest, files): | ||
if not dest: | ||
dest = src | ||
dest_entry = folder_map[dest] | ||
for source_file in files: | ||
source_path = os.path.join(builder.sourcePath, src, source_file) | ||
builder.AddCopy(source_path, dest_entry) | ||
|
||
# Include files | ||
#CopyFiles('include', 'addons/sourcemod/scripting/include', | ||
# [ 'sample.inc', ] | ||
#) | ||
|
||
# GameData files | ||
#CopyFiles('gamedata', 'addons/sourcemod/gamedata', | ||
# [ 'myfile.txt', | ||
# 'file2.txt' | ||
# ] | ||
#) | ||
|
||
# Config Files | ||
#CopyFiles('configs', 'addons/sourcemod/configs', | ||
# [ 'configfile.cfg', | ||
# 'otherconfig.cfg, | ||
# ] | ||
#) | ||
|
||
# Copy binaries. | ||
for cxx_task in Extension.extensions: | ||
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Prepare | ||
- Install all [SDKs, Sourcemod and Metamod:Source](https://wiki.alliedmods.net/Building_SourceMod#Downloading_Source_and_Dependencies) | ||
- Add SDKs, Sourcemod and Metamod:Source to **Enviroments**: | ||
- *HL2SDK* (e.g. `D:\alliedmodders\hl2sdk-episode1`) | ||
- *HL2TF2* (e.g. `D:\alliedmodders\hl2sdk-tf2`) | ||
- e.t.c. | ||
- *SOURCEMOD* (e.g. `D:\alliedmodders\sourcemod`) | ||
- *METAMOD* (e.g. `D:\alliedmodders\metamod-source`) | ||
- Clone template to sourcemod/extensions | ||
- Launch sm-ext-template/msvc/sdk.sln | ||
- Code | ||
|
||
# After | ||
- Install AMBuild | ||
- Create build folder | ||
- Goto build folder and run a command prompt | ||
- Run `python3 ../configure.py` | ||
- Then `ambuild` | ||
|
||
# Afterwords | ||
If you want to add a new **.cpp** file to the project, you need to add a new line in the **AMBuilder** file in the sourceFiles array, as well as your file name | ||
|
||
# Credits | ||
- [Sourcemod](https://github.com/alliedmodders/sourcemod/) | ||
- [Writing Extensions](https://wiki.alliedmods.net/Writing_Extensions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#if defined _sample_included | ||
#endinput | ||
#endif | ||
#define _sample_included | ||
|
||
/** | ||
* Write if extension was been loaded | ||
* | ||
* @noreturn | ||
*/ | ||
native void Sample_Loaded(); | ||
|
||
public Extension __ext_sample = | ||
{ | ||
name = "sample", | ||
file = "sample.ext", | ||
#if defined AUTOLOAD_EXTENSIONS | ||
autoload = 1, | ||
#else | ||
autoload = 0, | ||
#endif | ||
#if defined REQUIRE_EXTENSIONS | ||
required = 1, | ||
#else | ||
required = 0, | ||
#endif | ||
}; | ||
|
||
#if !defined REQUIRE_EXTENSIONS | ||
public void __ext_sample_SetNTVOptional() | ||
{ | ||
MarkNativeAsOptional("Sample_Loaded"); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <sourcemod> | ||
#include <sample> | ||
|
||
public Plugin myinfo = | ||
{ | ||
name = "Sample", | ||
author = "Orange", | ||
description = "Sample plugin for sample extension", | ||
version = "0.0.0.1", | ||
url = "https://github.com/OrangevichHeh" | ||
}; | ||
|
||
public void OnPluginStart() | ||
{ | ||
Sample_Loaded(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# vim: set sts=2 ts=8 sw=2 tw=99 et: | ||
import sys | ||
from ambuild2 import run | ||
|
||
# Simple extensions do not need to modify this file. | ||
|
||
builder = run.PrepareBuild(sourcePath = sys.path[0]) | ||
|
||
builder.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, | ||
help='Root search folder for HL2SDKs') | ||
builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None, | ||
help='Path to Metamod:Source') | ||
builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None, | ||
help='Path to SourceMod') | ||
builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', | ||
help='Enable debugging symbols') | ||
builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', | ||
help='Enable optimization') | ||
builder.options.add_option('-s', '--sdks', default='all', dest='sdks', | ||
help='Build against specified SDKs; valid args are "all", "present", or ' | ||
'comma-delimited list of engine names (default: %default)') | ||
|
||
builder.Configure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* vim: set ts=4 : | ||
* ============================================================================= | ||
* SourceMod Sample Extension | ||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. | ||
* ============================================================================= | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, version 3.0, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* As a special exception, AlliedModders LLC gives you permission to link the | ||
* code of this program (as well as its derivative works) to "Half-Life 2," the | ||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software | ||
* by the Valve Corporation. You must obey the GNU General Public License in | ||
* all respects for all other code used. Additionally, AlliedModders LLC grants | ||
* this exception to all derivative works. AlliedModders LLC defines further | ||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), | ||
* or <http://www.sourcemod.net/license.php>. | ||
* | ||
* Version: $Id$ | ||
*/ | ||
|
||
#include "extension.h" | ||
|
||
/** | ||
* @file extension.cpp | ||
* @brief Implement extension code here. | ||
*/ | ||
|
||
Sample g_Sample; /**< Global singleton for extension's main interface */ | ||
|
||
SMEXT_LINK(&g_Sample); | ||
|
||
bool Sample::SDK_OnLoad(char* error, size_t maxlen, bool late) { | ||
sharesys->AddNatives(myself, g_ExtensionNatives); | ||
return true; | ||
} | ||
|
||
void Sample::SDK_OnUnload() | ||
{ | ||
smutils->LogMessage(myself, "Sample extension has been unloaded."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/** | ||
* vim: set ts=4 : | ||
* ============================================================================= | ||
* SourceMod Sample Extension | ||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. | ||
* ============================================================================= | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, version 3.0, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* As a special exception, AlliedModders LLC gives you permission to link the | ||
* code of this program (as well as its derivative works) to "Half-Life 2," the | ||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software | ||
* by the Valve Corporation. You must obey the GNU General Public License in | ||
* all respects for all other code used. Additionally, AlliedModders LLC grants | ||
* this exception to all derivative works. AlliedModders LLC defines further | ||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), | ||
* or <http://www.sourcemod.net/license.php>. | ||
* | ||
* Version: $Id$ | ||
*/ | ||
|
||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ | ||
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ | ||
|
||
/** | ||
* @file extension.h | ||
* @brief Sample extension code header. | ||
*/ | ||
|
||
#include "smsdk_ext.h" | ||
|
||
|
||
extern const sp_nativeinfo_t g_ExtensionNatives[]; | ||
|
||
/** | ||
* @brief Sample implementation of the SDK Extension. | ||
* Note: Uncomment one of the pre-defined virtual functions in order to use it. | ||
*/ | ||
class Sample : public SDKExtension | ||
{ | ||
public: | ||
/** | ||
* @brief This is called after the initial loading sequence has been processed. | ||
* | ||
* @param error Error message buffer. | ||
* @param maxlen Size of error message buffer. | ||
* @param late Whether or not the module was loaded after map load. | ||
* @return True to succeed loading, false to fail. | ||
*/ | ||
virtual bool SDK_OnLoad(char *error, size_t maxlen, bool late); | ||
|
||
/** | ||
* @brief This is called right before the extension is unloaded. | ||
*/ | ||
virtual void SDK_OnUnload(); | ||
|
||
/** | ||
* @brief This is called once all known extensions have been loaded. | ||
* Note: It is is a good idea to add natives here, if any are provided. | ||
*/ | ||
//virtual void SDK_OnAllLoaded(); | ||
|
||
/** | ||
* @brief Called when the pause state is changed. | ||
*/ | ||
//virtual void SDK_OnPauseChange(bool paused); | ||
|
||
/** | ||
* @brief this is called when Core wants to know if your extension is working. | ||
* | ||
* @param error Error message buffer. | ||
* @param maxlen Size of error message buffer. | ||
* @return True if working, false otherwise. | ||
*/ | ||
//virtual bool QueryRunning(char *error, size_t maxlen); | ||
public: | ||
#if defined SMEXT_CONF_METAMOD | ||
/** | ||
* @brief Called when Metamod is attached, before the extension version is called. | ||
* | ||
* @param error Error buffer. | ||
* @param maxlen Maximum size of error buffer. | ||
* @param late Whether or not Metamod considers this a late load. | ||
* @return True to succeed, false to fail. | ||
*/ | ||
//virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); | ||
|
||
/** | ||
* @brief Called when Metamod is detaching, after the extension version is called. | ||
* NOTE: By default this is blocked unless sent from SourceMod. | ||
* | ||
* @param error Error buffer. | ||
* @param maxlen Maximum size of error buffer. | ||
* @return True to succeed, false to fail. | ||
*/ | ||
//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen); | ||
|
||
/** | ||
* @brief Called when Metamod's pause state is changing. | ||
* NOTE: By default this is blocked unless sent from SourceMod. | ||
* | ||
* @param paused Pause state being set. | ||
* @param error Error buffer. | ||
* @param maxlen Maximum size of error buffer. | ||
* @return True to succeed, false to fail. | ||
*/ | ||
//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen); | ||
#endif | ||
}; | ||
|
||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vs/ | ||
x64/ | ||
Release - TF2/ |
Oops, something went wrong.