-
Notifications
You must be signed in to change notification settings - Fork 0
/
achievements.cs
61 lines (48 loc) · 1.56 KB
/
achievements.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
function gatherAchievements() {
%file = new FileObject();
%file.openForRead("Add-Ons/Gamemode_Falling_Platforms/achievements/achievements.db");
$Platforms::Achievements = "";
while(!%file.isEOF()) {
%line = %file.readLine();
%id = getField(%line, 0);
$Platforms::Achievement[%id] = %line;
$Platforms::Achievements = trim($Platforms::Achievements SPC getField(%line, 0));
}
}
gatherAchievements();
function GameConnection::awardAchievement(%this, %id) {
if(stripos(%this.achievements, %id) != -1) {
return;
}
%ach = $Platforms::Achievement[%id];
if(%ach $= "") {
messageAll('', "Achievement" SPC %id SPC "is not in the database.");
return;
}
%this.achievements = trim(%this.achievements SPC %id);
messageAll('', "<bitmap:base/client/ui/CI/star.png>\c3" SPC %this.name SPC "just achieved\c3" SPC getField(%ach, 1) @ "!");
%this.play2D(rewardSound);
%hat = getField(%ach, 2);
if(%hat !$= "") {
HatMod_addHat(%this, %this.bl_id, %hat, 1);
messageClient(%this, '', "\c6You were awarded with the\c3" SPC %hat SPC "\c6hat.");
}
%this.savePlatformsGame();
}
package PlatformsAchievements {
function GameConnection::autoAdminCheck(%this) {
%date = getSubStr(getDateTime(), 0, 5);
switch$(%date) {
case "10/31":
%this.schedule(200, awardAchievement, "AH0");
case "12/25":
%this.schedule(200, awardAchievement, "AH1");
case "07/04":
%this.schedule(200, awardAchievement, "AH2");
case "01/01":
%this.schedule(200, awardAchievement, "AH3");
}
return parent::autoAdminCheck(%this);
}
};
activatePackage(PlatformsAchievements);