· 10 years ago · Sep 27, 2016, 06:10 PM
1/**
2 * Copyright (c) 2015-2016 San Andreas Playground
3 *
4 * This program is free software: you can redistribute it and/or modify it under the terms of the
5 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
6 * License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with this program.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15static mysql;
16
17public OnGameModeInit()
18{
19 UsePlayerPedAnims();
20 SetTimer("announces",80000,1);
21 SetGameModeText("SAP Alpha 6.9 REVO");
22 for(new xduel=0; xduel<MAX_INVITES; xduel++) ResetDuelInvites(xduel);
23 AddPlayerClass(230,2004.7198,1544.6941,13.5908,269.9990,0,0,0,0,0,0); // SPAWN1
24 AddPlayerClass(294,2164.8130,1900.1031,10.8203,138.8320,0,0,0,0,0,0); // SPAWN2
25 AddPlayerClass(3,2162.7280,2162.8359,10.8203,151.2920,0,0,0,0,0,0); // SPAWN3
26 AddPlayerClass(137,2533.3838,2089.9836,10.8203,119.0750,0,0,0,0,0,0); // SPAWN4
27 AddPlayerClass(200,2094.6301,1550.2998,10.8203,123.7136,0,0,0,0,0,0); // SPAWN5
28
29 // Here SOME OBJECTS :D ........
30
31
32 botIDs[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_MAIN_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
33 // Set the connect delay for the first bot to 20 seconds
34 IRC_SetIntData(botIDs[0], E_IRC_CONNECT_DELAY, 2);
35 // Connect the second bot
36 botIDs[1] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_2_MAIN_NICKNAME, BOT_2_REALNAME, BOT_2_USERNAME);
37 // Set the connect delay for the second bot to 30 seconds
38 IRC_SetIntData(botIDs[1], E_IRC_CONNECT_DELAY, 3);
39 // Create a group (the bots will be added to it upon connect)
40 groupID = IRC_CreateGroup();
41
42 // Grey colour shown when radio is idle
43 radioDisplay = TextDrawCreate(271.000000, 21.000000, "SAP RADIO"); // Grey colour
44 TextDrawBackgroundColor(radioDisplay, 255);
45 TextDrawFont(radioDisplay, 2);
46 TextDrawLetterSize(radioDisplay, 0.519999, 1.899999);
47 TextDrawColor(radioDisplay, -1313886209); // OTHER COLOR: -1552346881 (#A37910)
48 TextDrawSetOutline(radioDisplay, 1);
49 TextDrawSetProportional(radioDisplay, 1);
50
51 mysql = mysql_connect(mysql_host, mysql_user, mysql_db, mysql_pass);
52 mysql_log(LOG_ALL);
53 if(mysql_errno(mysql) != 0) print("Admin System: Could not connect to MySQL database.");
54 else print("Admin System: MySQL connection is stable.");
55 // Table creation
56 mysql_tquery(mysql, "CREATE TABLE IF NOT EXISTS `Admins` ( "\
57 "`Username` varchar(24) NOT NULL," \
58 "`AdminLevel` int(1) NOT NULL," \
59 "`IP` varchar(16) NOT NULL," \
60 "`APassword` varchar(256) NOT NULL," \
61 "`ALogin` int(1) NOT NULL," \
62 " PRIMARY KEY (`Username`)" \
63 ") ENGINE = InnoDB DEFAULT CHARSET = latin1");
64 foreach(new i : Player)
65 {
66 if(IsPlayerConnected(i))
67 {
68 new query[128];
69 mysql_format(mysql, query, sizeof(query), "SELECT * FROM `Admins` WHERE `Username`='%e' LIMIT 1", RPN(i));
70 mysql_tquery(mysql, query, "AdminCheck", "i", i);
71 }
72 }
73 if(!fexist("bans.cfg"))
74 {
75 new File:file = fopen("bans.cfg");
76 fclose(file);
77 }
78
79 return 1;
80}
81
82stock SendMessageToRconAdmins(color,const msg[])
83{
84 for (new i=0; i<MAX_PLAYERS; i++)
85 {
86 if (IsPlayerConnected(i) && IsPlayerAdmin(i)) SendClientMessage(i,color,msg);
87 }
88}