Skip to content

Commit 300e758

Browse files
committed
Initial commit.
Trigger Travis CI. yes
0 parents  commit 300e758

File tree

13 files changed

+2258
-0
lines changed

13 files changed

+2258
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto
2+
*.sp diff=sourcepawn
3+
*.cfg diff=astextplain
4+
*.smx binary

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.smx

.travis.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
sudo: false
2+
3+
addons:
4+
apt_packages:
5+
- lib32stdc++6 # needed for spcomp
6+
7+
env:
8+
- SMVERSION=1.8
9+
10+
before_script:
11+
# install smbuilder
12+
- git clone https://github.com/splewis/sm-builder
13+
- cd sm-builder
14+
- pip install --user -r requirements.txt
15+
- python setup.py install --prefix=~/.local
16+
- cd ..
17+
18+
# install the sourcemod compiler
19+
- SMPACKAGE="http://sourcemod.net/latest.php?os=linux&version=${SMVERSION}"
20+
- wget $SMPACKAGE
21+
- tar xfz $(basename $SMPACKAGE)
22+
- cd addons/sourcemod/scripting/
23+
- chmod +x spcomp
24+
- PATH+=":$PWD"
25+
26+
- cp ../../../gameserver/scripting/include/* include/
27+
- cd ../../..
28+
29+
script:
30+
- smbuilder --flags="-E"

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### Build status
2+
[![Build status](https://travis-ci.org/shavitush/smdiscord.svg?branch=master)](https://travis-ci.org/shavitush/smdiscord)
3+
4+
[Download](https://github.com/shavitush/smdiscord/releases)
5+
6+
# SourceMod <-> Discord
7+
Discord chat relay for SourceMod.
8+
9+
The plugin will relay the in-game chat into a Discord channel.
10+
11+
[Mapzones' setup demonstration](https://www.youtube.com/watch?v=oPKso2hoLw0)
12+
13+
# Requirements:
14+
* [SourceMod 1.8 and above](http://www.sourcemod.net/downloads.php)
15+
* [Dynamic](https://github.com/ntoxin66/Dynamic)
16+
* [Chat-Processor](https://forums.alliedmods.net/showthread.php?t=286913)
17+
* [SteamWorks](https://forums.alliedmods.net/showthread.php?t=229556)
18+
19+
# Installation:
20+
21+
### Gameserver to Discord
22+
1. Install the **requirements** above.
23+
2. Copy `smdiscord.cfg` to `addons/sourcemod/configs` and edit as needed.
24+
3. Copy `smdiscord.smx` to `addons/sourcemod/plugins`.
25+
4. Restart server.
26+
27+
### Discord to gameserver
28+
To be added.

gameserver/configs/smdiscord.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"SMDiscord"
2+
{
3+
"WebhookURL" "<INSERT HERE>"
4+
}

gameserver/scripting/include/SteamWorks.inc

Lines changed: 370 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#if defined _chat_processor_included
2+
#endinput
3+
#endif
4+
#define _chat_processor_included
5+
6+
//Globals
7+
#define MAXLENGTH_INPUT 128
8+
#define MAXLENGTH_NAME 64
9+
#define MAXLENGTH_MESSAGE 256
10+
11+
enum eChatFlags
12+
{
13+
ChatFlag_Invalid,
14+
ChatFlag_All,
15+
ChatFlag_Team,
16+
ChatFlag_Spec,
17+
ChatFlag_Dead
18+
}
19+
20+
//Forwards
21+
/**
22+
* Called while sending a chat message before It's sent.
23+
* Limits on the name and message strings can be found above.
24+
*
25+
* param author Author that created the message.
26+
* param recipients Array of clients who will receive the message.
27+
* param flag Determines which type of message is being sent.
28+
* param name Name string of the author to be pushed.
29+
* param message Message string from the author to be pushed.
30+
*
31+
* return types
32+
* - Plugin_Continue Stops the message.
33+
* - Plugin_Stop Stops the message.
34+
* - Plugin_Changed Fires the post-forward below and prints out a message.
35+
* - Plugin_Handled Fires the post-forward below but doesn't print a message.
36+
**/
37+
forward Action OnChatMessage(int& author, ArrayList recipients, eChatFlags& flag, char[] name, char[] message, bool& bProcessColors, bool& bRemoveColors);
38+
39+
/**
40+
* Called after the chat message is sent to the designated clients by the author.
41+
*
42+
* param author Author that sent the message.
43+
* param recipients Array of clients who received the message.
44+
* param flag Determines which type of message was sent.
45+
* param name Name string of the author.
46+
* param message Message string from the author.
47+
*
48+
* noreturn
49+
**/
50+
forward void OnChatMessagePost(int author, ArrayList recipients, eChatFlags flag, const char[] name, const char[] message, bool bProcessColors, bool bRemoveColors);
51+
52+
/**
53+
Shared plugin information
54+
**/
55+
public SharedPlugin _pl_chat_processor =
56+
{
57+
name = "chat-processor",
58+
file = "chat-processor.smx",
59+
#if defined REQUIRE_PLUGIN
60+
required = 1
61+
#else
62+
required = 0
63+
#endif
64+
};
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**
2+
* =============================================================================
3+
* Dynamic for SourceMod (C)2016 Matthew J Dunn. All rights reserved.
4+
* =============================================================================
5+
*
6+
* This program is free software; you can redistribute it and/or modify it under
7+
* the terms of the GNU General Public License, version 3.0, as published by the
8+
* Free Software Foundation.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13+
* details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with
16+
* this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
20+
#if defined _dynamic_basic_included
21+
#endinput
22+
#endif
23+
#define _dynamic_basic_included
24+
25+
/*
26+
This methodmap is based on the Dynamic methodmap while using a StringMap methodmap
27+
for implementation. This methodmap doesn't implement the full features of the Dynamic
28+
methodmap (type conversion, object naming, plugin sharing, ect). This methodmap can
29+
be used for basic storage using the standard Dynamic methodmap Methods.
30+
31+
Please see '\scripting\dynamic\examples\basic\' for an example usage of this methodmap
32+
*/
33+
34+
methodmap Basic < StringMap
35+
{
36+
public Basic()
37+
{
38+
return new StringMap();
39+
}
40+
41+
public void Dispose(bool disposemembers=true)
42+
{
43+
delete this;
44+
}
45+
46+
public int GetInt(const char[] membername, int defaultvalue=-1)
47+
{
48+
int value;
49+
if (this.GetValue(membername, value))
50+
return value;
51+
52+
return defaultvalue;
53+
}
54+
55+
public void SetInt(const char[] membername, int value)
56+
{
57+
this.SetValue(membername, value);
58+
}
59+
60+
public bool GetBool(const char[] membername, bool defaultvalue=false)
61+
{
62+
bool value;
63+
if (this.GetValue(membername, value))
64+
return value;
65+
66+
return defaultvalue;
67+
}
68+
69+
public void SetBool(const char[] membername, bool value)
70+
{
71+
this.SetValue(membername, value);
72+
}
73+
74+
public float GetFloat(const char[] membername, float defaultvalue=-1.0)
75+
{
76+
float value;
77+
if (this.GetValue(membername, value))
78+
return value;
79+
80+
return defaultvalue;
81+
}
82+
83+
public void SetFloat(const char[] membername, float value)
84+
{
85+
this.SetValue(membername, value);
86+
}
87+
88+
public bool GetString(const char[] membername, char[] buffer, int length)
89+
{
90+
return this.GetString(membername, buffer, length);
91+
}
92+
93+
public void SetString(const char[] membername, const char[] value)
94+
{
95+
this.SetString(membername, value);
96+
}
97+
98+
public Dynamic GetObject(const char[] membername)
99+
{
100+
Dynamic value;
101+
if (this.GetValue(membername, value))
102+
return value;
103+
104+
return INVALID_DYNAMIC_OBJECT;
105+
}
106+
107+
public void SetObject(const char[] membername, Dynamic value)
108+
{
109+
this.SetValue(membername, value);
110+
}
111+
112+
public Handle GetHandle(const char[] membername)
113+
{
114+
Handle value;
115+
if (this.GetValue(membername, value))
116+
return value;
117+
118+
return null;
119+
}
120+
121+
public void SetHandle(const char[] membername, Handle value)
122+
{
123+
this.SetValue(membername, value);
124+
}
125+
126+
public bool GetVector(const char[] membername, float[3] vector)
127+
{
128+
return this.GetArray(membername, vector, sizeof(vector));
129+
}
130+
131+
public void SetVector(const char[] membername, const float[3] value)
132+
{
133+
this.SetArray(membername, value, sizeof(value));
134+
}
135+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/**
2+
* =============================================================================
3+
* Dynamic for SourceMod (C)2016 Matthew J Dunn. All rights reserved.
4+
* =============================================================================
5+
*
6+
* This program is free software; you can redistribute it and/or modify it under
7+
* the terms of the GNU General Public License, version 3.0, as published by the
8+
* Free Software Foundation.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13+
* details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with
16+
* this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
20+
#if defined _dynamic_collection_included
21+
#endinput
22+
#endif
23+
#define _dynamic_collection_included
24+
25+
/*
26+
This methodmap is used to store typed collections based on Dynamic methodmaps. Internally
27+
an ArrayList is used for storage. This methodmap can be inherited by your own methodmaps
28+
where you can override the Items method to return your custom methodmap type which MUST
29+
inherit a Dynamic methodmap.
30+
31+
Please see '\scripting\dynamic\examples\collections\' for an example usage of this methodmap
32+
*/
33+
34+
methodmap Collection < ArrayList
35+
{
36+
public Collection()
37+
{
38+
return view_as<Collection>(new ArrayList());
39+
}
40+
41+
public void Clear(bool disposemembers=true)
42+
{
43+
if (disposemembers)
44+
{
45+
int count = this.Length;
46+
Dynamic member;
47+
for (int i = 0; i < count; i++)
48+
{
49+
member = view_as<Dynamic>(i);
50+
if (!member.IsValid)
51+
continue;
52+
53+
member.Dispose();
54+
}
55+
}
56+
57+
this.Clear();
58+
}
59+
60+
public void Dispose(bool disposemembers=true)
61+
{
62+
if (disposemembers)
63+
this.Clear(true);
64+
65+
CloseHandle(this);
66+
}
67+
68+
public Dynamic Items(int index)
69+
{
70+
return this.Get(index);
71+
}
72+
73+
property int Count
74+
{
75+
public get()
76+
{
77+
return this.Length;
78+
}
79+
}
80+
81+
public int AddItem(Dynamic item)
82+
{
83+
this.Push(item);
84+
}
85+
86+
public int FindItem(Dynamic item)
87+
{
88+
int count = this.Length;
89+
for (int i = 0; i < count; i++)
90+
{
91+
if (this.Get(i) == item)
92+
return i;
93+
}
94+
return -1;
95+
}
96+
97+
public void RemoveItem(Dynamic item)
98+
{
99+
int index = this.FindItem(item);
100+
if (index == -1)
101+
return;
102+
103+
this.Erase(index);
104+
}
105+
106+
public void RemoveIndex(int index)
107+
{
108+
this.Erase(index);
109+
}
110+
}

0 commit comments

Comments
 (0)