-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
164 lines (135 loc) · 5.69 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System;
using System.IO;
using Terraria;
using TerrariaApi.Server;
using TShockAPI;
/*
* Simple Donation Alerts Integration Plugin
* Plugin for Tshock (Terraria Server Core)
* Made by dxAugust (aka fet1sov)
*
* Hope it will make your streams funnier :)
*/
namespace DonationIntegration
{
[ApiVersion(2, 1)]
public class Plugin : TerrariaPlugin
{
public override string Author => "dxAugust";
public override string Description => "Plugin which integrates DonationAlerts events into Terraria";
public override string Name => "DonationAlerts Integration";
private static Random random;
/* Getting directory of config.ini file */
public static string DirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "ServerPlugins");
public static string FolderPath = Path.Combine(DirectoryPath, "DAIntegration");
public static string FilePath = Path.Combine(FolderPath, "config.ini");
/* =================================== */
public Plugin(Main game) : base(game)
{
}
public override void Initialize()
{
/* Gets the ini config with auth code */
if (Directory.Exists(FolderPath))
{
if (File.Exists(@FilePath))
{
IniParser parser = new IniParser(@FilePath);
Config.authCode = parser.GetSetting("DonationAlerts", "authcode");
DAPI donateAPI = new DAPI(); // Initilization of the DonationAlerts API
random = new Random();
}
} else {
Directory.CreateDirectory(FolderPath);
string path = @FilePath;
string text = "[DonationAlerts]" + Environment.NewLine + "authcode=";
File.WriteAllText(@FilePath, text);
Debugger.errorOutput("You have to install authcode in your config file");
}
/* ================================== */
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
base.Dispose(disposing);
}
/* Donation Event Handler is here */
public static void handleDonate(string name, string currencyCode, int amount)
{
TShock.Utils.Broadcast(string.Format("Донат: от {0} - {1} {2}", name, amount, currencyCode), 255, 255, 0);
/*
1 - Nothing
2 - Selects one player on the server and then spawn Eye of Cthulu on his position
3 - Killing all players on server
4 - Spawns Skeleton Prime to random player position
5 - Sets time to night
6 - Kicks random player from server
7 - Spams to all player "MUHAHAHAHAHAHAHHAHAHAHA"
8 - Spawns 20 zombie near random player
9 - Sets time to day
10 - Spawn 50 bats near random player
*/
int badThings = random.Next(1, 10);
int playerID = random.Next(1, TShock.Players.Length);
int spamCount = 30;
int zombieCount = 30;
int batsCount = 50;
switch (badThings)
{
case 1:
break;
case 2:
NPC eye = TShock.Utils.GetNPCById(4);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(eye.type, name, 1, TShock.Players[playerID].TileX, TShock.Players[playerID].TileY);
break;
case 3:
for (int i = 0; i < TShock.Players.Length; i++)
{
TShock.Players[i].KillPlayer();
}
break;
case 4:
NPC prime = TShock.Utils.GetNPCById(127);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(prime.type, name, 1, TShock.Players[playerID].TileX, TShock.Players[playerID].TileY);
break;
case 5:
TSPlayer.Server.SetTime(false, 0.0);
break;
case 6:
TShock.Players[playerID].Kick("SORRY FOR DONATION :)", false, true);
break;
case 7:
for (int i = 0; i < spamCount; i++)
{
TShock.Utils.Broadcast("MUHHAHAHAHAHA", 255, 0, 0);
}
break;
case 8:
for (int i = 0; i < zombieCount; i++)
{
NPC zombies = TShock.Utils.GetNPCById(3);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(zombies.type, name, 1, TShock.Players[playerID].TileX, TShock.Players[playerID].TileY);
}
break;
case 9:
TSPlayer.Server.SetTime(false, 12.0);
break;
case 10:
for (int i = 0; i < batsCount; i++)
{
NPC zombies = TShock.Utils.GetNPCById(51);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(zombies.type, name, 1, TShock.Players[playerID].TileX, TShock.Players[playerID].TileY);
}
break;
default:
break;
}
}
}
}