-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAbyte0_HideNSeekGiver.java
More file actions
209 lines (159 loc) · 5.91 KB
/
Abyte0_HideNSeekGiver.java
File metadata and controls
209 lines (159 loc) · 5.91 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//2021-12-01 - Initial Release by Abyte0
public class Abyte0_HideNSeekGiver extends Abyte0_Script {
// ===== DEFAULT CONFIG ===== //
String reminderText = "@cya@Hide N Seek game! @or3@Be the first to trade me!";
int relogRequiredToAdvertise = 10;
// === END DEFAULT CONFIG === //
boolean isTrading = false;
boolean isSucess = false;
String privateMessageTarget = "Global$";
String yourName = "";
int idToGive = 0;
int amoutToGive = 0;
String prizeDescription = "";
String lastOpponent = "";
int relogCounter = 0;
boolean isInDebug = false;
boolean readyToAdvertise = false;
boolean needToAdvertise = false;
String startTime = "";
boolean startedFirstIteration = false;
@Override
public String[] getRandomQuotes() {
int doubleDice = random(1, 10);
if (doubleDice > 5) {
String[] temp = {""};
return temp;
}
String[] result = {"Where am I?", "Nobody gona know!", "Pisst! I am here!", "5 - 4 - 3 - 2 - 1 Go! Find me!"};
return result;
}
public Abyte0_HideNSeekGiver(Extension e) {
super(e);
}
public void init(String params) {
print("Version 0.2 - Initial Release");
print("param order idToGive,amoutToGive,Prize description no comma,your name");
if (params.equals("debug")) {
isInDebug = true;
idToGive = 10;
amoutToGive = 1;
prizeDescription = "1 coins";
yourName = "Abyte0";
relogRequiredToAdvertise = 2;
privateMessageTarget = "Abytetest";
} else {
String[] str = params.split(",");
if (!params.equals("")) {
idToGive = Integer.parseInt(str[0]);
amoutToGive = Integer.parseInt(str[1]);
prizeDescription = str[2];
yourName = str[3];
if (getInventoryCount(idToGive) < amoutToGive) {
print("invalid quantity, you can't give what is not in your inventory");
stopScript();
return;
}
} else {
print("example of param : 10,100000,100 000 coins,Abyte");
stopScript();
return;
}
}
if (isInDebug)
print("@or2@SET AS DEBUG");
}
public int main() {
if (!startedFirstIteration) {
startTime = getDateTime();
print("Script started on " + startTime);
if ("".equals(yourName))
sendPrivateMessage("@ran@Game Start! : @cya@" + reminderText, privateMessageTarget);
else
sendPrivateMessage("@ran@" + yourName + " just started :@cya@ " + reminderText, privateMessageTarget);
startedFirstIteration = true;
}
if (isInDebug) print("needToAdvertise = " + needToAdvertise);
if (isInDebug) print("readyToAdvertise = " + readyToAdvertise);
if (readyToAdvertise) {
if (isInDebug) print("reminderText = " + reminderText);
if (isInDebug) print("privateMessageTarget = " + privateMessageTarget);
sendPrivateMessage(reminderText, privateMessageTarget);
needToAdvertise = false;
readyToAdvertise = false;
return 1000;
}
if (needToAdvertise) {
if (isInDebug)
print("Scheduling an advertisement in 30 seconds!");
readyToAdvertise = true;
if (isInDebug) print("readyToAdvertise = " + readyToAdvertise);
return 30000;
}
if (isSucess) {
String successText = "@mag@[@gre@" + lastOpponent + "@mag@]@cya@Just won @red@" + prizeDescription + "@cya@ at the Hide N Seek game!";
sendPrivateMessage(successText, privateMessageTarget);
print(getDateTime() + " Stopping script because " + lastOpponent + " won!");
print("it has started on : " + startTime);
setAutoLogin(false);
logout();
stopScript();
}
if (isInTradeOffer()) {
if (getLocalTradeItemCount() > 0) {
acceptTrade();
return 1000;
}
int itemIventoryPosition = getInventoryIndex(idToGive);
offerItemTrade(itemIventoryPosition, amoutToGive);
return 2000;
}
if (isInTradeConfirm()) {
confirmTrade();
return 1000;
}
return 10000;
}
@Override
public void onTradeRequest(String name) {
System.out.println(name + " wishes to trade with you.");
lastOpponent = name;
int[] opDetails = getPlayerByName(name);
Object player = client.getPlayer(opDetails[0]);
if (!isTrading)
sendTradeRequest(client.getMobServerIndex(player));
isTrading = true;
}
@Override
public void onServerMessage(String s) {
if (s.contains("declined trade")) {
isTrading = false;
if (isInDebug) print("isTrading is now false due to decline");
return;
}
if (s.contains("Welcome to ")) {
relogCounter++;
if (isInDebug) print("counter is " + relogCounter + " of " + relogRequiredToAdvertise);
isTrading = false;
if (relogCounter >= relogRequiredToAdvertise) {
needToAdvertise = true;
print("counter going back to zero");
relogCounter = 0;
return;
}
return;
}
if (s.contains("Trade completed ")) {
isSucess = true;
if (isInDebug)
print("isSucess is now true due to trade completed");
return;
}
//if (s.contains("Closing welcome box.")) {
//
//}
//if (s.contains("standing here for 5 mins!")) {
//
//}
}
}