· 7 years ago · Oct 05, 2018, 05:34 PM
1function onScriptLoad()
2{
3 //==================== Key binds =================================
4 KEY_UP <- BindKey( true, 0x26, 0, 0);
5 KEY_LEFT <- BindKey( true, 0x25, 0, 0 );
6 KEY_RIGHT <- BindKey( true, 0x27, 0, 0 );
7 KEY_DOWN <- BindKey( true, 0x28, 0, 0 );
8 KEY_1 <- BindKey( true, 0x31, 0, 0 );
9 KEY_2 <- BindKey( true, 0x32, 0, 0 );
10 KEY_3 <- BindKey( true, 0x33, 0, 0 );
11 KEY_4 <- BindKey( true, 0x34, 0, 0 );
12 KEY_5 <- BindKey( true, 0x35, 0, 0 );
13 KEY_6 <- BindKey( true, 0x36, 0, 0 );
14 KEY_7 <- BindKey( true, 0x37, 0, 0 );
15 KEY_8 <- BindKey( true, 0x38, 0, 0 );
16 KEY_9 <- BindKey( true, 0x39, 0, 0 );
17 //====================ABCD====================//
18 KEY_A <- BindKey( true, 0x41, 0, 0 );
19 KEY_B <- BindKey( true, 0x42, 0, 0 );
20 KEY_C <- BindKey( true, 0x43, 0, 0 );
21 KEY_D <- BindKey( true, 0x44, 0, 0 );
22 KEY_E <- BindKey( true, 0x45, 0, 0 );
23 KEY_F <- BindKey( true, 0x46, 0, 0 );
24 KEY_G <- BindKey( true, 0x47, 0, 0 );
25 KEY_H <- BindKey( true, 0x48, 0, 0 );
26 KEY_I <- BindKey( true, 0x49, 0, 0 );
27 KEY_J <- BindKey( true, 0x4A, 0, 0 );
28 KEY_K <- BindKey( true, 0x4B, 0, 0 );
29 KEY_L <- BindKey( true, 0x4C, 0, 0 );
30 KEY_M <- BindKey( true, 0x4D, 0, 0 );
31 KEY_N <- BindKey( true, 0x4E, 0, 0 );
32 KEY_O <- BindKey( true, 0x4F, 0, 0 );
33 KEY_P <- BindKey( true, 0x50, 0, 0 );
34 KEY_Q <- BindKey( true, 0x51, 0, 0 );
35 KEY_R <- BindKey( true, 0x52, 0, 0 );
36 KEY_S <- BindKey( true, 0x53, 0, 0 );
37 KEY_T <- BindKey( true, 0x54, 0, 0 );
38 KEY_U <- BindKey( true, 0x55, 0, 0 );
39 KEY_V <- BindKey( true, 0x56, 0, 0 );
40 KEY_W <- BindKey( true, 0x57, 0, 0 )
41 KEY_X <- BindKey( true, 0x58, 0, 0 );
42 KEY_Y <- BindKey( true, 0x59, 0, 0 );
43 KEY_Z <- BindKey( true, 0x5A, 0, 0 );
44 print("Keys binded")
45
46 //==================== Queries ===================================
47 DB <- ConnectSQL( "databases/MainDatabase.db" );
48 QuerySQL( DB, "CREATE TABLE if not exists Accounts ( Name TEXT, LowerName TEXT, Password VARCHAR ( 255 ), Level NUMERIC DEFAULT 1, TimeRegistered VARCHAR ( 255 ) DEFAULT CURRENT_TIMESTAMP, UID VARCHAR ( 255 ), IP VARCHAR ( 255 ), Banned TEXT, Clan VARCHAR ( 255 ), ClanRank VARCHAR ( 255 ), Kills VARCHAR ( 255 ), Deaths VARCHAR ( 255 ), LastJoined VARCHAR ( 255 ), KEY1, KEY2, KEY3, KEY4)");
49 //==================== Arrays/Tables =============================
50 status <- array( GetMaxPlayers(), null );
51 onlinePlrs <- [];
52 intro <- array( GetMaxPlayers(), false );
53 max_ammo <- array( GetMaxPlayers(), 0 );
54 next_mag <- array( GetMaxPlayers(), 0 );
55 regenTimer <- array( GetMaxPlayers(), null );
56 regenTimer2 <- array( GetMaxPlayers(), null );
57 isRegen <- array( GetMaxPlayers(), false );
58 nogoto <- array( GetMaxPlayers(), false );
59 //==================== Misc. =====================================
60 pUpdateTimer <- NewTimer( "Update", 1000/30, 0 );
61 SetPassword( "acclog8194" );
62 SetWastedSettings( 2000, 1000, 2, 2, RGB( 0, 0, 0 ), 1000, 1000 );
63 //=================== Classes ====================================
64 AddClass( 1, RGB( 0, 206, 247 ), 200, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 60, 23, 90, 26, 60 );
65}
66function SaveStats( player )
67{
68 local today = date(), dat = today.month + "/" + today.day + "/" + today.year;
69 QuerySQL( DB, format( @"UPDATE [Accounts] SET
70 [LastJoined] = '%s',
71 [Password] = '%s',
72 [Level] = '%d',
73 [UID] = '%s',
74 [IP] = '%s',
75 [Banned] = '%s',
76 [Kills] = '%d',
77 [Deaths] = '%d'
78 WHERE [Name] = '%s' AND [LowerName] = '%s';",
79 dat.tostring(), status[ player.ID ].Password.tostring(),
80 status[ player.ID ].Level.tointeger(),
81 status[ player.ID ].UID.tostring(),
82 status[ player.ID ].IP.tostring(),
83 status[ player.ID ].Banned.tostring(),
84 status[ player.ID ].Kills.tointeger(),
85 status[ player.ID ].Deaths.tointeger(),
86 player.Name,
87 player.Name.tolower()
88 )
89 );
90 if( status[ player.ID ].Clan != null ) QuerySQL( DB, "UPDATE Accounts SET Clan = '"+ status[ player.ID ].Clan +"', ClanRank = '"+ status[ player.ID ].CRank +"' WHERE Name = '"+ escapeSQLString( player.Name ) +"' AND LowerName = '"+ escapeSQLString( player.Name.tolower() ) +"'" );
91 local pkey = status[player.ID].Primarykey.tointeger(), skey = status[player.ID].Secondrykey.tointeger(), lkey = status[player.ID].Lethalkey.tointeger(), gkey = status[player.ID].Gadgetkey.tointeger();
92 SaveKeys( pkey, player, 1 ), SaveKeys( skey, player, 2 ), SaveKeys( lkey, player, 3 ), SaveKeys( gkey, player, 4 );
93}
94
95function onKeyDown( player, key )
96{
97 if( pCamera[ player.ID ].IsEnabled() == true )
98 {
99 switch( key )
100 {
101 case KEY_W:
102 pCamera[ player.ID ].bMovingForward = true;
103 break;
104 case KEY_A:
105 pCamera[ player.ID ].bMovingLeft = true;
106 break;
107 case KEY_S:
108 pCamera[ player.ID ].bMovingBackward = true;
109 break;
110 case KEY_D:
111 pCamera[ player.ID ].bMovingRight = true;
112 break;
113 case KEY_UP:
114 pCamera[ player.ID ].bRotatingUp = true;
115 break;
116 case KEY_LEFT:
117 pCamera[ player.ID ].bRotatingLeft = true;
118 break;
119 case KEY_DOWN:
120 pCamera[ player.ID ].bRotatingDown = true;
121 break;
122 case KEY_RIGHT:
123 pCamera[ player.ID ].bRotatingRight = true;
124 break;
125 }
126 }
127 else if ( key == status[player.ID].Primarykey )
128 {
129 player.Slot = 6;
130 }
131 else if ( key == status[player.ID].Secondrykey )
132 {
133 player.Slot = 5;
134 }
135 else if ( key == status[player.ID].Lethalkey )
136 {
137 player.Slot = 2
138 }
139 else if ( key == status[player.ID].Gadgetkey )
140 {
141 player.Slot = 4
142 }
143
144}
145
146
147function SetKey( keytype, key, player ) //setting the keys and replacing the previous key
148{
149 local p = status[player.ID].Primarykey.tointeger();
150 local s = status[player.ID].Secondrykey.tointeger();
151 local l = status[player.ID].Lethalkey.tointeger();
152 local g = status[player.ID].Gadgetkey.tointeger();
153 if ( keytype == 1 )
154 {
155 if ( s == gg(key).tointeger() ) status[player.ID].Secondrykey = p.tointeger();
156 else if ( l == gg(key).tointeger()) status[player.ID].Lethalkey = p.tointeger() ;
157 else if ( g == gg(key).tointeger() ) status[player.ID].Gadgetkey = p.tointeger();
158 status[player.ID].Primarykey = gg(key).tointeger();
159 ServerMsg( "Primary key changed to "+key , player )
160 }
161
162 if ( keytype == 2 )
163 {
164 if ( p == gg(key).tointeger() ) status[player.ID].Primarykey = s.tointeger();
165 if ( l == gg(key).tointeger() ) status[player.ID].Lethalkey = s.tointeger();
166 if ( g == gg(key).tointeger() ) status[player.ID].Gadgetkey = s.tointeger();
167 status[player.ID].Secondrykey = gg(key).tointeger();
168 ServerMsg( "Secondry key changed to "+key , player )
169 }
170
171 if ( keytype == 3 )
172 {
173 if ( p == gg(key).tointeger() ) status[player.ID].Primarykey = l.tointeger();
174 if ( s == gg(key).tointeger() ) status[player.ID].Secondrykey = l.tointeger();
175 if ( g == gg(key).tointeger() ) status[player.ID].Gadgetkey = l.tointeger();
176 status[player.ID].Lethalkey = gg(key).tointeger();
177 ServerMsg( "Lethal key changed to "+key , player )
178 }
179
180 if ( keytype == 4 )
181 {
182 if ( p == gg(key).tointeger() ) status[player.ID].Primarykey = g.tointeger();
183 if ( s == gg(key).tointeger() ) status[player.ID].Secondrykey = g.tointeger();
184 if ( l == gg(key).tointeger() ) status[player.ID].Lethalkey = g.tointeger();
185 status[player.ID].Gadgetkey = gg(key).tointeger();
186 ServerMsg( "Gadget key changed to "+key , player )
187 }
188}
189
190
191
192function SaveKeys( key, player, type ) //saving the keys
193{
194 local key = key;
195 if ( type == 1 ) QuerySQL( DB, "UPDATE Accounts SET KEY1 = '"+key+"' WHERE NAME = '"+escapeSQLString(player.Name)+"'");
196 if ( type == 2 ) QuerySQL( DB, "UPDATE Accounts SET KEY2 = '"+key+"' WHERE NAME = '"+escapeSQLString(player.Name)+"'");
197 if ( type == 3 ) QuerySQL( DB, "UPDATE Accounts SET KEY3 = '"+key+"' WHERE NAME = '"+escapeSQLString(player.Name)+"'");
198 if ( type == 4 ) QuerySQL( DB, "UPDATE ACcounts SEt KEY4 = '"+key+"' WHERE NAME = '"+escapeSQLString(player.Name)+"'");
199}
200
201
202
203function gg(key) //Getkey , cause we can not name all the keys 1,2,3 or it will cause inconvineance(rip grammer) in the future
204{
205 if ( key == "1" ) return KEY_1;
206 if ( key == "2" ) return KEY_2;
207 if ( key == "3" ) return KEY_3;
208 if ( key == "4" ) return KEY_4;
209 if ( key == "5" ) return KEY_5;
210 if ( key == "6" ) return KEY_6;
211 if ( key == "7" ) return KEY_7;
212 if ( key == "8" ) return KEY_8;
213 if ( key == "9" ) return KEY_9;
214 if ( key == "10" ) return KEY_10;
215 if ( key == "a" ) return KEY_A;
216 if ( key == "b" ) return KEY_B;
217 if ( key == "c" ) return KEY_C;
218 if ( key == "d" ) return KEY_D;
219 if ( key == "e" ) return KEY_E;
220 if ( key == "f" ) return KEY_F;
221 if ( key == "g" ) return KEY_G;
222 if ( key == "h" ) return KEY_H;
223 if ( key == "i" ) return KEY_I;
224 if ( key == "j" ) return KEY_J;
225 if ( key == "k" ) return KEY_K;
226 if ( key == "l" ) return KEY_L;
227 if ( key == "m" ) return KEY_M;
228 if ( key == "n" ) return KEY_N;
229 if ( key == "o" ) return KEY_O;
230 if ( key == "p" ) return KEY_P;
231 if ( key == "q" ) return KEY_Q;
232 if ( key == "r" ) return KEY_R;
233 if ( key == "s" ) return KEY_S;
234 if ( key == "t" ) return KEY_T;
235 if ( key == "u" ) return KEY_U;
236 if ( key == "v" ) return KEY_V;
237 if ( key == "w" ) return KEY_W;
238 if ( key == "x" ) return KEY_X;
239 if ( key == "y" ) return KEY_Y;
240 if ( key == "z" ) return KEY_Z;
241}
242
243else if ( cmd == "setkey" || cmd == "setkeys" )
244 {
245 if (!text) ServerMsg( "Error: /"+cmd+" <primary, secondry, lethal, gadget> <key>." ,player )
246 else if ( !GetTok( text," ",2) ) ServerMsg( "Error: /"+cmd+" <primary, secondry, lethal, gadget> <key>.", player )
247 else
248 {
249 if ( GetTok( text," ",1).tolower() == "primary" || GetTok( text," ",1).tolower() == "secondry" || GetTok( text," ",1).tolower() == "lethal" || GetTok( text," ",1).tolower() == "gadget" )
250 {
251 if ( GetTok( text," ", 2).len() < 2 )
252 {
253 local key = GetTok( text, " ", 2).tolower();
254 local keytype = GetTok( text, " ", 1 ).tolower();
255 if ( keytype == "primary" ) SetKey( 1, key, player );
256 if ( keytype == "secondry" ) SetKey( 2, key, player );
257 if ( keytype == "lethal" ) SetKey( 3, key, player );
258 if ( keytype == "gadget" ) SetKey( 4, key, player );
259 }
260
261 else ServerMsg( "Error: Key can not be more then one." , player )
262 }
263 else ServerMsg( "Error: /"+cmd+" <primary/secondry/lethal/gadget> <key>." ,player)
264
265 }