~armagetronad-ap/armagetronad/BattleMania

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
<?php
###################################################################
######                     Battle Mania                      ######
###################################################################
######  Script by: LOVER$BOY                                 ######
######  Description: Please leave this header. Thanks!       ######
######  Contact: zodiacsohma1@gmail.com                      ######
###################################################################

define('tAccessLevel_Hoster', -1);
define('tAccessLevel_Owner', 0);
define('tAccessLevel_Admin', 1);
define('tAccessLevel_Moderator', 2);
define('tAccessLevel_3', 3);
define('tAccessLevel_4', 4);
define('tAccessLevel_Armatrator', 5);
define('tAccessLevel_6', 6);
define('tAccessLevel_TeamLeader', 7);
define('tAccessLevel_TeamMember', 8);
define('tAccessLevel_9', 9);
define('tAccessLevel_10', 10);
define('tAccessLevel_11', 11);
define('tAccessLevel_Local', 12);
define('tAccessLevel_13', 13);
define('tAccessLevel_14', 14);
define('tAccessLevel_Remote', 15);
define('tAccessLevel_DefaultAuthenticated', 15);
define('tAccessLevel_FallenFromGrace', 16);
define('tAccessLevel_Shunned', 17);
define('tAccessLevel_18', 18);
define('tAccessLevel_Authenticated', 19);
define('tAccessLevel_Program', 20);

define('tAccessLevel_Default', 20);
define('tAccessLevel_Punished', 21);
define('tAccessLevel_Invalid', 255);

class tAccessLevel
{
    static function GetName($level)
    {
        $str = 'config_accesslevel_'.$level;
        if (hasLanguageCommand($str))
        {
            $msg = getLanguageCommand($str);
            $str = $msg->message;
        }

        return $str;
    }
};


class configBase
{
    var $name  = '';
    var $value = '';
    var $help  = '';

    //  giving the settings access_level the people need to access/change/execute
    var $required = tAccessLevel_Admin;

    //  giving the settings the access_level of owner to change and do anything
    var $set_level = tAccessLevel_Owner;

    static $commands = array();

    function __construct($name, $value, $help = "")
    {
        $this->name = $name;
        $this->value = $value;

        if (Filter($help) == "")
            $this->help = Filter($name)."_help";
        else
            $this->help = $help;

        self::$commands[] = $this;
    }

    function ReadVal(Player $player, $params) {}

    static function Load(Player $player)
    {
        $commandStr = BridgePieces(5, " ");

        pm($player, "0xff0000Script admin command 0xffffffby 0xffff7f".$player->log.": 0x7f7fff".$commandStr);

        $command = "";
        if (isset(Base::$base->pieces[5]))
            $command = trim(Base::$base->pieces[5]);

        if (Filter($command) !== "")
        {
            $commandParams = BridgePieces(6, " ");

            //  executing command if it is found
            $found = false;
            if (count(self::$commands) > 0)
            {
                foreach (self::$commands as $cmd)
                {
                    if (isset($cmd) && $cmd instanceof configBase && (strtolower($cmd->name) == strtolower($command)))
                    {
                        $found = true;

                        if (Base::$base->pieces[4] <= $cmd->required)
                        {
                            $log_script_admin_commands = getSetting("LOG_SCRIPT_ADMIN_COMMANDS");
                            if ($log_script_admin_commands->value)
                                logAdminCommand($player, $commandStr);

                            $cmd->ReadVal($player, $commandParams);
                        }
                        else
                        {
                            customPlayerMessage($player, 'access_level_error', array($cmd->name, tAccessLevel::GetName($cmd->required), tAccessLevel::GetName(Base::$base->pieces[4])));
                        }

                        break;
                    }
                }

                //  if the searching command wasn't found
                if (!$found)
                {
                    customPlayerMessage($player, 'config_command_unknown', array(strtoupper($command)));

                    //  let's try and find out if we can find any similar commands
                    $sim_maxlen = -1;
                    foreach (self::$commands as $cmd)
                    {
                        if (isset($cmd) && $cmd instanceof configBase)
                        {
                            if (contains($cmd->name, $command, false))
                            {
                                if (strlen($cmd->name) > $sim_maxlen)
                                    $sim_maxlen = strlen($cmd->name);
                            }
                        }
                    }

                    //  let's show the user the commands similar to the called command
                    if ($sim_maxlen > 0)
                    {
                        $len = strlen($command);
                        $printMax = 1 + 3 * $len * $len * $len;

                        foreach (self::$commands as $cmd)
                        {
                            if (isset($cmd) && $cmd instanceof configBase && contains($cmd->name, $command, false))
                            {
                                if ($printMax-- > 0)
                                {
                                    $output = "";
                                    $output .= $cmd->name;
                                    //  adjust the position of where help string will begin
                                    setpos($output, $sim_maxlen + 2);
                                    $output .= "(";
                                    $output .= $cmd->help;
                                    $output .= ")";

                                    pm($player, "0xff4c4cRA: 0xRESETT".$output);
                                }
                            }
                        }

                        //  if there are ore more similar commands, then tell the player
                        if ($printMax <= 0)
                        {
                            customPlayerMessage($player, 'config_command_more');
                        }
                    }
                }
            }
        }
    }
};

class tAccessLevelSetter
{
    static function Set(configBase $config, $level)
    {
        $config->required = $level;
    }
};