· 8 years ago · Apr 22, 2018, 01:06 AM
1//==============================================================================
2//------------------------- Server Functions -----------------------------------
3//==============================================================================
4function GetTok(string, separator, n, ...)
5{
6 local m = vargv.len() > 0 ? vargv[0] : n,
7 tokenized = split(string, separator),
8 text = "";
9
10 if (n > tokenized.len() || n < 1) return null;
11 for (; n <= m; n++)
12 {
13 text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
14 }
15 return text;
16}
17
18function NumTok(string, separator)
19{
20 local tokenized = split(string, separator);
21 return tokenized.len();
22}
23
24function Distance(x1, y1, x2, y2)
25{
26local dist = sqrt(((x2 - x1)*(x2 - x1)) + ((y2 - y1)*(y2 - y1)));
27return dist;
28}
29
30function GetPlayer( plr )
31{
32if ( plr )
33{
34if ( IsNum( plr ) )
35{
36plr = FindPlayer( plr.tointeger() );
37if ( plr ) return plr;
38else return false;
39}
40else
41{
42plr = FindPlayer( plr );
43if ( plr ) return plr;
44else return false;
45}
46}
47else return false;
48}
49
50function GetFullTime()
51{
52local t = date();
53return ::format(@"%.2d/%.2d/%d - %.2d:%.2d:%.2d", t.day, t.month, t.year, t.hour, t.min, t.sec);
54}
55
56function CriarTabelas()
57{
58QuerySQL( db, "CREATE TABLE IF NOT EXISTS Contas ( Nome TEXT, IP VARCHAR(20), UID TEXT, Senha VARCHAR(255), Dinheiro NUMERIC, Banco NUMERIC, Level NUMERIC, Data_Reg TEXT, Data_Join TEXT, Matou NUMERIC, Morreu NUMERIC, Nogoto TEXT, SpawnLoc TEXT, Loc TEXT )" );
59QuerySQL( db, "CREATE TABLE IF NOT EXISTS Bans ( Nome TEXT, UID TEXT, Admin TEXT, Motivo TEXT, Data TEXT )" );
60QuerySQL( db, "CREATE TABLE IF NOT EXISTS Locs ( Nome TEXT, Pos TEXT, Criador TEXT, Data TEXT )" );
61QuerySQL( db, "CREATE TABLE IF NOT EXISTS SpawnWep ( Nome TEXT, Wep1 NUMERIC, Wep2 NUMERIC, Wep3 NUMERIC, Wep4 NUMERIC )" );
62QuerySQL( db, "CREATE TABLE IF NOT EXISTS Carros ( ID NUMERIC, Preco NUMERIC, Dono TEXT, Compart TEXT, Modelo NUMERIC, PX FLOAT, PY FLOAT, PZ FLOAT, Angulo FLOAT, Cor1 NUMERIC, Cor2 NUMERIC )" );
63}
64
65function Reload()
66{
67dofile( "scripts/Main.nut" );
68dofile( "scripts/Functions.nut" );
69dofile( "scripts/Cmds.nut" );
70dofile( "scripts/Echo.nut" );
71Message( "[#FF1493][INFO] [#00FF00]Script Recarregado..." );
72EchoMessage( "13[INFO] 3Script Recarregado..." );
73print( "Script Recarregado..." );
74}
75
76function CarregarCarros()
77{
78local i = 0, modelo, x, y, z, angulo, cor1, cor2;
79local q = QuerySQL( db, "SELECT * FROM Carros" );
80
81while ( GetSQLColumnData( q, 0 ) != null )
82{
83modelo = GetSQLColumnData( q, 4 );
84x = GetSQLColumnData( q, 5 );
85y = GetSQLColumnData( q, 6 );
86z = GetSQLColumnData( q, 7 );
87angulo = GetSQLColumnData( q, 8 );
88cor1 = GetSQLColumnData( q, 9 );
89cor2 = GetSQLColumnData( q, 10 );
90CreateVehicle( modelo, 0, Vector( x.tofloat(), y.tofloat(), z.tofloat() ), angulo, cor1, cor2 );
91GetSQLNextRow( q );
92i++;
93}
94FreeSQLQuery( q );
95print( "Veiculos Carregados - " + i );
96}
97
98function IpToCountry( IP )
99{
100local country = geoip_country_name_by_addr( IP );
101if ( IP == "127.0.0.1" ) return "Local-Host";
102else if ( country == null ) return "Nao Encontrado";
103else return country;
104}
105
106function PartReason( reason )
107{
108if ( reason == 0 ) return "Timeout";
109else if ( reason == 1 ) return "Quit";
110else if ( reason == 2 ) return "Kickado";
111else if ( reason == 3 ) return "Crash";
112}
113
114function DeathReason( reason )
115{
116if ( reason == 70 ) return "Suicidio";
117else if ( reason == 39 ) return "Acidente de Carro";
118else if ( reason == 31 ) return "Queimado";
119else if ( reason == 14 ) return "Sufocado";
120else if ( reason == 43 ) return "Afogado";
121else if ( reason == 41 ) return "Explosao";
122else if ( reason == 51 ) return "Explosao";
123else if ( reason == 44 ) return "Caiu";
124else return "Motivo Desconhecido";
125}
126
127function GetBP( part )
128{
129local group = "";
130if ( part == 0 ) group = "Body";
131else if ( part == 1 ) group = "Torso";
132else if ( part == 2 ) group = "Left Arm";
133else if ( part == 3 ) group = "Right Arm";
134else if ( part == 4 ) group = "Left Leg";
135else if ( part == 5 ) group = "Right Leg";
136else if ( part == 6 ) group = "Cabeca";
137return group;
138}
139
140function Configuracao()
141{
142SetUseClasses( true );
143SetDeathMessages( false );
144SetDrivebyEnabled( false );
145SetDriveOnWater( false );
146SetFlyingCars( false );
147SetFriendlyFire( true );
148SetJoinMessages( false );
149SetShowNametags( true );
150SetShowOnRadar( true );
151SetStuntBike( false );
152SetTaxiBoostJump( true );
153SetServerName( Server.Nome );
154SetSpawnPlayerPos( -1437.89, -820.148, 14.8714 );
155SetSpawnCameraPos( -1437.8, -811.572, 14.8713);
156SetSpawnCameraLook( -1437.84, -815.382, 14.8714 );
157SetGameModeName( "BR v" + Server.Versao );
158SetTime( 12, 00 );
159SetTimeRate( 0 );
160Classes();
161print( Server.Nome + " v" + Server.Versao + " criado por " + Server.Desenvolvedor + " iniciado." );
162}
163
164function Classes()
165{
166//================================= Tommy Team =================================
167AddClass( 0, RGB( 30, 144, 255 ), 0, Vector( -378.557, -541.685, 17.2831 ), -0.00544404, 17, 1000 , 21, 1000, 26, 1000 );
168AddClass( 0, RGB( 30, 144, 255 ), 95, Vector( -378.557, -541.685, 17.2831 ), -0.00544404, 17, 1000 , 21, 1000, 26, 1000 );
169//================================== Cop Team ==================================
170AddClass( 1, RGB( 190, 190, 190 ), 1, Vector( -657.341, 762.188, 11.5999 ), 2.441, 17, 1000 , 21, 1000, 26, 1000 );
171AddClass( 1, RGB( 190, 190, 190 ), 3, Vector( -657.341, 762.188, 11.5999 ), 2.441, 17, 1000 , 21, 1000, 26, 1000 );
172//================================== Army Team =================================
173AddClass( 2, RGB( 255, 0, 0 ), 2, Vector( -1721.48, -226.703, 14.8683 ), -3.12018, 17, 1000 , 21, 1000, 26, 1000 );
174AddClass( 2, RGB( 255, 0, 0 ), 4, Vector( -1721.48, -226.703, 14.8683 ), -3.12018, 17, 1000 , 21, 1000, 26, 1000 );
175//================================== Taxi Team =================================
176AddClass( 3, RGB( 255, 165, 0 ), 28, Vector( -995.355, 185.432, 12.434 ), -0.123521, 17, 1000 , 21, 1000, 26, 1000 );
177AddClass( 3, RGB( 255, 165, 0 ), 74, Vector( -995.355, 185.432, 12.434 ), -0.123521, 17, 1000 , 21, 1000, 26, 1000 );
178//================================== Golf Team =================================
179AddClass( 4, RGB( 250, 128, 114 ), 62, Vector( 100.034, 254.158, 21.7719 ), -2.70758, 17, 1000 , 21, 1000, 26, 1000 );
180AddClass( 4, RGB( 250, 128, 114 ), 64, Vector( 100.034, 254.158, 21.7719 ), -2.70758, 17, 1000 , 21, 1000, 26, 1000 );
181//================================== Biker Team ================================
182AddClass( 5, RGB( 160, 32, 240 ), 93, Vector( -603.613, 634.466, 12.2347 ), -1.47827, 17, 1000 , 21, 1000, 26, 1000 );
183AddClass( 5, RGB( 160, 32, 240 ), 94, Vector( -603.613, 634.466, 12.2347 ), -1.47827, 17, 1000 , 21, 1000, 26, 1000 );
184//================================== Pizza Team ================================
185AddClass( 6, RGB( 255, 255, 0 ), 68, Vector( -907.399, 800.637, 11.3918 ), -1.64542, 17, 1000 , 21, 1000, 26, 1000 );
186AddClass( 6, RGB( 255, 255, 0 ), 132, Vector( -907.399, 800.637, 11.3918 ), -1.64542, 17, 1000 , 21, 1000, 26, 1000 );
187//================================== Thug Team =================================
188AddClass( 7, RGB( 0, 139, 139 ), 154, Vector( 85.0716, 1112.38, 18.7597 ), 3.12136, 17, 1000 , 21, 1000, 26, 1000 );
189AddClass( 7, RGB( 0, 139, 139 ), 148, Vector( 85.0716, 1112.38, 18.7597 ), 3.12136, 17, 1000 , 21, 1000, 26, 1000 );
190//================================ Haitian Team ================================
191AddClass( 8, RGB( 0, 255, 255 ), 85, Vector( -965.356, 148.572, 9.39548 ), -1.53778, 17, 1000 , 21, 1000, 26, 1000 );
192AddClass( 8, RGB( 0, 255, 255 ), 86, Vector( -965.356, 148.572, 9.39548 ), -1.53778, 17, 1000 , 21, 1000, 26, 1000 );
193//================================= Cuban Team =================================
194AddClass( 9, RGB( 255, 192, 203 ), 83, Vector( -1167.03, -614.434, 11.8292 ), 1.78367, 17, 1000 , 21, 1000, 26, 1000 );
195AddClass( 9, RGB( 255, 192, 203 ), 84, Vector( -1167.03, -614.434, 11.8292 ), 1.78367, 17, 1000 , 21, 1000, 26, 1000 );
196//================================ Malibu Team =================================
197AddClass( 10, RGB( 127, 255, 212 ), 186, Vector( 465.706, -53.9011, 15.7038 ), -2.37175, 17, 1000 , 21, 1000, 26, 1000 );
198AddClass( 10, RGB( 127, 255, 212 ), 115, Vector( 465.706, -53.9011, 15.7038 ), -2.37175, 17, 1000 , 21, 1000, 26, 1000 );
199//================================= FBI Team ===================================
200AddClass( 11, RGB( 255, 215, 0 ), 97, Vector( -873.145, -684.57, 11.3023 ), -0.649355, 17, 1000 , 21, 1000, 26, 1000 );
201AddClass( 11, RGB( 255, 215, 0 ), 98, Vector( -873.145, -684.57, 11.3023 ), -0.649355, 17, 1000 , 21, 1000, 26, 1000 );
202//================================= Goku Team ===================================
203 AddClass( 12, RGB( 24, 255, 241 ) ,220, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 999 ,1, 1, 25, 255 );
204 AddClass( 12, RGB( 24, 255, 241 ) ,221, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 999 ,1, 1, 25, 255 );
205//================================= Naruto Team =================================
206AddClass( 13, RGB( 24, 255, 241 ) ,210, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 999 ,1, 1, 25, 255 );
207AddClass( 13, RGB( 24, 255, 241 ) ,216, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 999 ,1, 1, 25, 255 );
208}
209
210function GetNameClass( classID )
211{
212local id = classID;
213if ( id == 0 ) return "Tommy's Team";
214else if ( id == 1 ) return "Police Team";
215else if ( id == 2 ) return "Army Team";
216else if ( id == 3 ) return "Taxi Team";
217else if ( id == 4 ) return "Golf Team";
218else if ( id == 5 ) return "Bikers Team";
219else if ( id == 6 ) return "Pizza Team";
220else if ( id == 7 ) return "Thug Team";
221else if ( id == 8 ) return "Haitian Team";
222else if ( id == 9 ) return "Cuban Team";
223else if ( id == 10 ) return "Malibu Team";
224else if ( id == 11 ) return "FBI Team";
225else if ( id == 12 ) return "Goku Team";
226else if ( id == 13 ) return "Naruto Team";
227else return " ";
228}
229
230function S_MSG( text, player ) MessagePlayer( "[#00FF00][SINTAXE][#FFFFFF] " + text, player );
231
232function E_MSG( text, player ) MessagePlayer( "[#FF4500][ERRO][#FF0000] " + text, player );
233
234function I_MSG( text, player ) MessagePlayer( "[#FF00FF][INFO][#FFFFFF] " + text, player );
235
236function A_MSG( text, player )
237{
238MessageAllExcept( "[#FFFFFF]***[#00FFFF] " + text, player );
239EchoMessage( "6***3 " + text );
240}
241
242function MSG( text )
243{
244Message( "[#EEDD82]***[#EEDD82] " + text );
245EchoMessage( "7***7 " + text );
246}
247
248function SalvarTudo()
249{
250for( local i = 0, plr; i < GetMaxPlayers(); i++ )
251{
252plr = FindPlayer( i );
253if ( plr ) SalvarDados( plr );
254}
255}
256
257function CreateBox()
258{
259 Box = CreatePickup( 345 , Vector( -403.665, 900.964, 39.2562 ) );
260}
261
262function Agua( user )
263{
264local player = FindPlayer( user );
265if ( player ) player.Pos = Vector( -597.7496, -1858.9531, 28.1291 );
266}
267
268function Drown( admin, player, motivo )
269{
270if ( player.Vehicle ) player.Eject();
271MSG( "Admin " + admin + " afogou " + player.Name + ". Motivo: " + motivo + "." );
272player.Health = 3;
273NewTimer( "Agua", 700, 1, player.ID );
274}
275
276function Ban( admin, player, motivo )
277{
278QuerySQL( db, "INSERT INTO Bans ( Nome, UID, Admin, Motivo, Data ) VALUES ( '" + player.Name + "', '" + player.UniqueID + "', '" + admin + "', '" + motivo + "', '" + GetFullTime() + "' )" );
279MSG( "Admin " + admin + " baniu " + player.Name + ". Motivo: " + motivo + "." );
280KickPlayer( player );
281}
282
283function Kick( admin, player, motivo )
284{
285MSG( "Admin " + admin + " kickou " + player.Name + ". Motivo: " + motivo + "." );
286KickPlayer( player );
287}
288
289function GetVehInfo( veh, opcao )
290{
291local opcao = opcao.tolower();
292if ( veh )
293{
294local q = QuerySQL( db, "SELECT * FROM Carros WHERE ID='" + veh.ID + "'" );
295if ( opcao == "preco" ) return GetSQLColumnData( q, 1 ).tointeger();
296else if ( opcao == "dono" ) return GetSQLColumnData( q, 2 );
297else if ( opcao == "compart" ) return GetSQLColumnData( q, 3 );
298else return "Informacao nao encontrada";
299}
300}
301
302
303
304function DonoCompartVeh( player, veh )
305{
306if ( GetVehInfo( veh, "dono" ) == player.Name || GetVehInfo( veh, "compart" ) == player.Name ) return true;
307else return false;
308}
309
310function VeiculoInfo( player, veh, opcao )
311{
312if ( opcao == 0 )
313{
314I_MSG( "ID: [" + veh.ID + "] | Modelo: [" + GetVehicleNameFromModel( veh.Model ) + "] | Preco: [$ " + GetVehInfo( veh, "preco" ) + "].", player );
315I_MSG( "Dono: [" + GetVehInfo( veh, "dono" ) + "] | Compartilhado com: [" + GetVehInfo( veh, "compart" ) + "].", player );
316}
317else if ( opcao == 1 ) I_MSG( "Voce saiu do veiculo " + GetVehicleNameFromModel( veh.Model ) + ".", player );
318}
319//==============================================================================
320//------------------------- Player Functions -----------------------------------
321//==============================================================================
322function Checar( player, plr )
323{
324if ( plr == null )
325{
326if ( status[ player.ID ].Registrado == false )
327{
328E_MSG( "Seu nick nao esta registrado.", player );
329return true;
330}
331else if ( status[ player.ID ].Registrado == true && status[ player.ID ].Logado == false )
332{
333E_MSG( "Voce nao esta logado.", player );
334return true;
335}
336}
337else if ( plr != null )
338{
339if ( status[ plr.ID ].Registrado == false )
340{
341E_MSG( plr.Name + " nao esta registrado.", player );
342return true;
343}
344else if ( status[ plr.ID ].Registrado == true && status[ plr.ID ].Logado == false )
345{
346E_MSG( plr.Name + " nao esta logado.", player );
347return true;
348}
349}
350else return false;
351}
352
353function GetStats( player )
354{
355local kills = status[ player.ID ].Matou, deaths = status[ player.ID ].Morreu, ratio;
356if ( kills >= 1 && deaths >= 1 ) ratio = format( "%.2f", kills.tofloat() / deaths.tofloat() );
357else ratio = 0;
358Message( "[#00BFFF]* Status de[#FFFFFF] " + player.Name + "[#00BFFF]: Matou:[#FFFFFF] " + kills + "[#00BFFF] | Morreu:[#FFFFFF] " + deaths + "[#00BFFF] | Ratio:[#FFFFFF] " + ratio + "[#00BFFF]." );
359EchoMessage( "12* Status de4 " + player.Name + "12: Matou:4 " + kills + "12 | Morreu:4 " + deaths + "12 | Ratio:4 " + ratio + "12." );
360}
361
362function Registrar( player, senha )
363{
364local pass = e(senha);
365QuerySQL( db, "INSERT INTO Contas ( Nome, IP, UID, Senha, Dinheiro, Banco, Level, Data_Reg, Data_Join, Matou, Morreu, Nogoto, SpawnLoc, Loc ) VALUES ( '" + player.Name +
366"', '" + player.IP + "', '" + player.UniqueID + "', '" + pass + "', 2000, 0, 1, '" + GetFullTime() + "', '" + GetFullTime() + "', 0, 0, 'off', 'off', 0 )" );
367IncCash( player, 2000 );
368status[ player.ID ].Registrado = true;
369status[ player.ID ].Logado = true;
370status[ player.ID ].Level = 1;
371A_MSG( player.Name + " se registrou no servidor.", player );
372I_MSG( "[#00CED1]Voce registrou seu nick com sucesso.", player );
373MSG( "Jogador + player.name + Se registrou no servidor!.", player );
374I_MSG( "[#6495ED]Nao esqueca sua senha: " + senha, player );
375Announce( "~y~Nick Registrado!", player, 3 );
376}
377
378function Login( player )
379{
380CarregarDados( player );
381MessagePlayer( player.Name + " efetuou o login corretamente.", player );
382I_MSG( "[#00CED1]Bem-vindo de Novamente " + player.Name + ".", player );
383I_MSG( "[#48D1CC]Voce efetuou o login corretamente.", player );
384I_MSG( "[#40E0D0]Level: " + status[ player.ID ].Level + " - Status: " + LevelTag( player ) + ".", player );
385Announce( "~y~Entrou!", player, 3 );
386}
387
388function ChecarConta( player )
389{
390status[ player.ID ] = PlayerStats();
391
392if ( GetLevel( player ) >= 1 )
393{
394if ( player.IP != GetIP( player ) )
395{
396MessagePlayer( "[#40E0D0]Voce esta conectado com um IP diferente.", player );
397MessagePlayer( "[#00CED1]Voce deve efetuar o login. Use /login <senha>", player );
398status[ player.ID ].Registrado = true;
399status[ player.ID ].Logado = false;
400}
401else if ( player.IP == GetIP( player ) )
402{
403CarregarDados( player );
404I_MSG( "[#00CED1]Bem-vindo Novamente " + player.Name + ".", player );
405I_MSG( "[#48D1CC]Voce logou automaticamente.", player );
406I_MSG( "[#40E0D0]Level: " + status[ player.ID ].Level + " - Status: " + LevelTag( player ) + ".", player );
407}
408}
409else
410{
411I_MSG( "[#00CED1]Ola! seja Bem-vindo " + player.Name + ".", player );
412I_MSG( "[#48D1CC]Seu nick nao esta registrado no servidor.", player );
413I_MSG( "[#40E0D0]Para se registrar no servidor use /registrar <senha>.", player );
414}
415ChecarJogador( player );
416}
417
418function CarregarDados( player )
419{
420local q = QuerySQL( db, "SELECT * FROM Contas WHERE Nome='" + player.Name + "'" );
421
422status[ player.ID ].Registrado = true;
423status[ player.ID ].Logado = true;
424status[ player.ID ].Dinheiro = GetSQLColumnData( q, 4 );
425status[ player.ID ].Banco = GetSQLColumnData( q, 5 );
426status[ player.ID ].Level = GetSQLColumnData( q, 6 );
427status[ player.ID ].Matou = GetSQLColumnData( q, 9 );
428status[ player.ID ].Morreu = GetSQLColumnData( q, 10 );
429if ( GetSQLColumnData( q, 11 ) == "on" ) status[ player.ID ].Nogoto = true;
430if ( GetSQLColumnData( q, 12 ) == "on" ) status[ player.ID ].SpawnLoc = true;
431if ( GetSQLColumnData( q, 13 ) != "0" ) status[ player.ID ].Loc = GetSQLColumnData( q, 13 );
432player.Cash = status[ player.ID ].Dinheiro;
433Data_IP( player );
434}
435
436function Data_IP( player )
437{
438QuerySQL( db, "UPDATE Contas SET IP='" + player.IP + "', Data_Join='" + GetFullTime() + "' WHERE Nome='" + player.Name + "'" );
439}
440
441function SalvarDados( player )
442{
443local p = status[ player.ID ], nogoto = "off";
444if ( p.Registrado == true && p.Logado == true )
445{
446if ( p.Nogoto == true ) nogoto = "on";
447QuerySQL( db, "UPDATE Contas SET Dinheiro='" + p.Dinheiro + "', Banco='" + p.Banco + "', Level='" + p.Level +
448"', Matou='" + p.Matou + "', Morreu='" + p.Morreu + "', Nogoto='" + nogoto + "' WHERE Nome='" + player.Name + "'" );
449}
450}
451
452function ChecarJogador( player )
453{
454local q = QuerySQL( db, "SELECT * FROM Bans WHERE UID='" + player.UniqueID + "'" );
455if ( GetSQLColumnData( q, 1 ) == player.UniqueID )
456{
457A_MSG( player.Name + " esta banido do servidor.", player );
458I_MSG( "Voce esta banido do servidor.", player );
459I_MSG( "Admin que baniu: " + GetSQLColumnData( q, 2 ) + " | Data: " + GetSQLColumnData( q, 4 ) + ".", player );
460I_MSG( "Motivo do banimento: " + GetSQLColumnData( q, 3 ) + ".", player );
461KickPlayer( player );
462}
463else if ( player.Name == "Ninguem" ) Kick( "Server", player, "Nick Bloqueado" );
464}
465
466function JoinMessage( player )
467{
468Message( "[#00BFFF]*** [#FFFAFA]" + player.Name + " [#FFFFF0]entrou no servidor. (" + IpToCountry( player.IP ) + ")" );
469EchoMessage( "10***4 " + player.Name + " 10entrou no servidor. (" + IpToCountry( player.IP ) + ")" );
470}
471
472function QuitMessage( player, motivo )
473{
474Message( "[#00BFFF]*** [#FFFFFF]" + player.Name + " [#00BFFF]saiu do servidor. (" + PartReason( motivo ) + ")" );
475EchoMessage( "10***4 " + player.Name + " 10saiu do servidor. (" + PartReason( motivo ) + ")" );
476}
477
478function LevelTag( player )
479{
480local lvl = status[ player.ID ].Level;
481if ( lvl == 0 ) return "Visitante";
482else if ( lvl == 1 ) return "Membro";
483else if ( lvl == 2 ) return "Helper";
484else if ( lvl == 3 ) return "Moderador";
485else if ( lvl == 4 ) return "Administrador";
486else if ( lvl == 5 ) return "Manager";
487else if ( lvl == 6 ) return "Scripter"
488else if ( lvl >= 7 ) return "Desenvolvedor"
489}
490
491function GetLevel( player )
492{
493local result = GetSQLColumnData( QuerySQL( db, "SELECT Level FROM Contas WHERE Nome='" + player.Name + "'" ), 0 ), lvl;
494if ( result == null ) lvl = GetSQLColumnData( QuerySQL( db, "SELECT Level FROM Contas WHERE Nome='" + player.Name + "'" ), 0 );
495else lvl = result;
496if ( lvl ) return lvl;
497else return 0;
498}
499
500function GetIP( player )
501{
502local result = GetSQLColumnData( QuerySQL( db, "SELECT IP FROM Contas WHERE Nome='" + player.Name + "'" ), 0 ), ip;
503if ( result == null ) ip = GetSQLColumnData( QuerySQL( db, "SELECT IP FROM Contas WHERE Nome='" + player.Name + "'" ), 0 );
504else ip = result;
505if ( ip ) return ip;
506else return 0;
507}
508
509function GetSenha( player )
510{
511local result = GetSQLColumnData( QuerySQL( db, "SELECT Senha FROM Contas WHERE Nome='" + player.Name + "'" ), 0 ), pass;
512if ( result == null ) pass = GetSQLColumnData( QuerySQL( db, "SELECT Senha FROM Contas WHERE Nome='" + player.Name + "'" ), 0 );
513else pass = result;
514if ( pass ) return pass;
515else return 0;
516}
517
518function IncCash( player, amount )
519{
520local cash = status[ player.ID ].Dinheiro;
521local add = cash + amount;
522status[ player.ID ].Dinheiro = add;
523player.Cash = add;
524}
525
526function DecCash( player, amount )
527{
528local cash = status[ player.ID ].Dinheiro;
529local det = cash - amount;
530status[ player.ID ].Dinheiro = det;
531player.Cash = det;
532}
533
534function IncBank( player, amount )
535{
536local bank = status[ player.ID ].Banco;
537local add = bank + amount;
538status[ player.ID ].Banco = add;
539}
540
541function DecBank( player, amount )
542{
543local bank = status[ player.ID ].Banco;
544local det = bank - amount;
545status[ player.ID ].Banco = det;
546}
547
548function Timer()
549{
550for( local i = 0, player; i < GetMaxPlayers(); i++ )
551{
552player = FindPlayer( i );
553if ( player )
554{
555if ( SpawnKill[ player.ID ] >= 1 ) SpawnKill[ player.ID ] --;
556if ( Multa[ player.ID ] >= 1 )
557{
558Multa[ player.ID ] --;
559if ( Multa[ player.ID ] == 0 ) UnMute( "Server", player );
560}
561}
562}
563}
564
565function CheckSpam( player, reason )
566{
567local MSNxSEC = 2000, LIMIT_REP_SPAM = 3;
568local spammer = ( GetTickCount() - status[ player.ID ].Count_Msg ) / MSNxSEC;
569status[ player.ID ].Msg_Player += spammer - 1;
570if ( status[ player.ID ].Msg_Player > LIMIT_REP_SPAM ) status[ player.ID ].Msg_Player = LIMIT_REP_SPAM - 1;
571if ( status[ player.ID ].Msg_Player < 0 ) status[ player.ID ].Msg_Player = -1;
572status[ player.ID ].Count_Msg = GetTickCount();
573if ( status[ player.ID ].Msg_Player < 0)
574{
575if ( Multa[ player.ID ] == 0 )
576{
577Multa[ player.ID ] = 30;
578I_MSG( "Voce foi multado por fazer spam.", player );
579A_MSG( "Auto-Mute " + player.Name + ", ID: " + player.ID + ". Motivo:[ " + reason + " ].", player );
580}
581}
582}
583
584function CheckSafe( user )
585{
586local player = FindPlayer( user );
587 if ( player )
588 {
589local EnterSafe = DistanceFromPoint( player.Pos.x, player.Pos.z, -937.731, 17.8038 );
590local ExitSafe = DistanceFromPoint( player.Pos.x, player.Pos.z, -937.698, 7.22692 );
591if ( EnterSafe.tointeger() < 1 )
592{
593NewTimer( "ResetFffect", 500, 1, player.ID );
594player.Pos = Vector( -937.698, -351.819, 7.22692 );
595player.Widescreen = true;
596}
597else if ( ExitSafe.tointeger() < 1 )
598{
599NewTimer( "ResetFffect", 500, 1, player.ID );
600player.Pos = Vector( -937.731, -351.445, 17.8038 );
601player.Widescreen = true;
602}
603}
604}
605
606function ResetFffect( user )
607{
608local player = FindPlayer( user );
609if ( player )
610{
611 player.Widescreen = false;
612}
613}
614
615function StartLottery()
616{
617 if ( LotteryCount >= 3 ) // Lottery starts from three tickets purchased. You chose this...
618 {
619 local ticket = raffle();
620 for ( local i = 0; i <= GetMaxPlayers(); i ++ )
621 {
622 local player = FindPlayer( i );
623 if ( player )
624 {
625 if ( Lottery[ player.ID ] == true )
626 {
627 if ( TicketsPurchased.rawget( player.ID ) == ticket )
628 {
629 LotteryWon = true;
630 Message( "[#ff0000]=========[#FFFFFF][[#8c1717]Loteria[#ffffff]][#ff0000]===========" );
631 Message( "[#FFFFFF][[#8c1717]Ganhador[#ffffff]]: " + player.Name + "." );
632 Message( "[#FFFFFF][[#8c1717]Bilhete Sorteado[#ffffff]]: " + TicketsPurchased.rawget( player.ID ) + " " );
633 Message( "[#FFFFFF][#8c1717][Premio[#FFFFFF]]:[#ffffff] " " + player.Cash + " " + LotteryPrize + " "." );
634 Message( "[#ff0000]=============================" );
635 EchoMessage( "10=========0[5Loteria0]10=============" );
636 EchoMessage( "0[5Ganhador0]: " + player.Name + "." );
637 EchoMessage( "0[5Bilhete Sorteado0]: " + TicketsPurchased.rawget( player.ID ) + " " );
638 EchoMessage( "0[5Premio0]:0 " " + player.Cash + " " + LotteryPrize + " "." );
639 EchoMessage( "10================================" );
640 player.Cash += LotteryPrize;
641 }
642 }
643 }
644 }
645 LotteryWon ? ( Message( "Loteria Encerrada." ), EndLottery() ) : Message( "Lottery: Nao a ganhador. " + LotteryPrize );
646 }
647 else
648 {
649 Message( "[#FFFFFF][[#8c1717]INFO[#FFFFFF]] [#6f4242]Bilheteria cancelada por falta de bilhetes comprado." );
650 _Lottery <- NewTimer( "StartLottery", 300000, 1 );
651 }
652}
653
654function EndLottery()
655{
656 for ( local i = 0; i <= GetMaxPlayers(); i ++ )
657 {
658 local player = FindPlayer( i );
659 if ( player )
660 {
661 if ( Lottery[ player.ID ] == true )
662 {
663 TicketsPurchased.rawset( player.ID, 0 );
664 Lottery [ player.ID ] = false;
665 LotteryWon = false;
666 LotteryCount = 0;
667 }
668 }
669 }
670
671 for ( local i = 1; i < 60; i ++ )
672 {
673 Tickets[i] = false;
674 usedTickets.clear();
675 }
676}
677
678function raffle()
679{
680 local rand = rand() % usedTickets.len();
681 return usedTickets[rand];
682}
683
684function UnMute( admin, player )
685{
686Multa[ player.ID ] = 0;
687MSG( "Admin " + admin + " desmultou " + player.Name + "." );
688}
689
690function RespawnVehicles( rtime = 0 ){
691//Loop over all the vehicles.
692for( local veh, i = 1; i <= 1000; i++ ){
693veh = FindVehicle(i);
694if( !veh ) continue;
695if( rtime == 0 ) veh.Respawn();
696else veh.RespawnTimer = rtime; //Time in ms.
697}
698}
699
700function MudarNick( novo, velho )
701{
702//Mudar o nome na tabela de contas
703QuerySQL( db, "UPDATE Contas SET Nome='" + novo + "' WHERE Nome LIKE '" + velho + "'");
704
705//Mudar o nome na tabela de veÃculos
706QuerySQL( db, "UPDATE Veiculos SET Dono='" + novo + "' WHERE Dono LIKE '" + velho + "'");
707QuerySQL( db, "UPDATE Veiculos SET Compart='" + novo + "' WHERE Compart LIKE '" + velho + "'");
708
709//Mudar o nome na tabela de casas
710QuerySQL( db, "UPDATE Casas SET Dono='" + novo + "' WHERE Dono LIKE '" + velho + "'");
711QuerySQL( db, "UPDATE Casas SET Compart='" + novo + "' WHERE Compart LIKE '" + velho + "'");
712
713//Mudar o nick do jogador
714if ( GetPlayerIDFromName( velho ) != -1 )
715{
716local player = FindPlayer( GetPlayerIDFromName( velho ) );
717player.Name = novo;
718}
719}
720
721function RobbingSystem()
722{
723QuerySQL( db, "CREATE TABLE IF NOT EXISTS Robskills( Name TEXT),Robskill NUMERIC )" );
724}
725function GetRobskills( player )
726{
727 local Robbing = GetSQLColumnData( QuerySQL( db, "SELECT Robskill FROM Robskills WHERE Name='" + player.Name+"'" ), 0 );
728 if ( Robbing ) return Robbing;
729 else return 0;
730}
731function SetRobskills( player, rob )
732{
733 QuerySQL(db, "UPDATE Robskills SET Robskill='" + rob.tointeger() + "' WHERE Name='" + player.Name + "'");
734}
735
736function RobieCopie()
737 {
738 QuerySQL( db, "CREATE TABLE IF NOT EXISTS Rob&Cop( Name TEXT),Robskill NUMERIC )" );
739 }
740 function GetRob( player )
741{
742 local Robie = GetSQLColumnData( QuerySQL( db, "SELECT Robskills FROM Rob&Cop WHERE Name='" + player.Name+"'" ), 0 );
743 if ( Robie ) return Robie;
744 else return 0;
745}
746function SetRob( player, rob )
747{
748 QuerySQL(db, "UPDATE Rob&Cop SET Robskill='" + rob.tointeger() + "' WHERE Name='" + player.Name + "'");
749}
750
751function Loade()
752{
753CreatePickup(508, Vector( 390.96, -506.26, 9.39 ));
754CreatePickup(405, Vector( 204.29, -490.98, 11.06 ));
755CreatePickup(405, Vector(-854.526, -631.75, 11.3756 ));
756CreatePickup(405, Vector(-688.706, -1262.49, 16.3473 ));
757CreatePickup(405, Vector(-665.025, -1484.42, 13.8016 ));
758CreatePickup(405, Vector(-885.324, -469.998, 13.1111 ));
759CreatePickup(405, Vector(-847.002, -71.6495, 11.5405 ));
760CreatePickup(405, Vector(-1079.64, -275.416, 12.0882 ));
761CreatePickup(405, Vector(-1036.4 81.2033, 11.6515 ));
762CreatePickup(405, Vector(-992.73, 200.392, 15.2213 ));
763CreatePickup(405, Vector(-830.158, 741.534, 11.2885 ));
764CreatePickup(405, Vector(-906.182, 799.715, 11.4546 ));
765CreatePickup(405, Vector(-854.047, 85 11.3846 ));
766CreatePickup(405, Vector(-754.53, 1342.74, 11.767 ));
767CreatePickup(405, Vector(472.16, 1009.2, 19.1493 ));
768CreatePickup(405, Vector(423.496, 1039.0 18.9648 ));
769CreatePickup(405, Vector(364.464, 1075.12, 19.0649 ));
770CreatePickup(405, Vector(470.443, 1208.18, 19.0094 ));
771CreatePickup(405, Vector(-939.213, -351.221, 17.8038));
772CreatePickup(405, Vector(-867.572, -584.978, 11.225));
773}
774
775function LoadPickups()
776{
777local q = QuerySQL( db, "SELECT * FROM Pickups" ), i = 0;
778while( GetSQLColumnData( q, 0 ) )
779{
780local
781ID = GetSQLColumnData( q, 0 ),
782PX = GetSQLColumnData( q, 2 ),
783PY = GetSQLColumnData( q, 3 ),
784PZ = GetSQLColumnData( q, 4 );
785
786CreatePickup(ID.tointeger(), Vector(PX.tofloat(), PY.tofloat(), PZ.tofloat()));
787GetSQLNextRow( q );
788i++;
789}
790print( "Pickups Carregadas - " + i );
791}
792
793function MSG1()
794{
795Message("[BvD] [#E0FFFF]Novos empregos Distribuidor de dinheiro e Caminhoneiro.");
796EchoMessage("10[BvD] 14Novos empregos Distribuidor de dinheiro e Caminhoneiro.");
797}
798
799function MSG2()
800{
801Message("[BvD] [#E0FFFF]Caso voce ache algum erro ignore erros sao normais aqui.");
802EchoMessage("10[BvD] 14Caso voce ache algum erro ignore erros sao normais aqui.");
803}
804
805function MSG3()
806{
807Message("[BvD] [#E0FFFF]Servidor apenas para testes nao vai se exaltando nao.");
808EchoMessage("10[BvD] 14Servidor apenas para testes nao vai se exaltando nao.");
809}
810
811function MSG4()
812{
813Message("[BvD] [#E0FFFF]Caso nao conheca os comandos use /cmds..");
814EchoMessage("10[BvD] 14Caso nao conheca os comandos use /cmds.");
815}
816
817function MSG5()
818{
819Message("[BvD] [#E0FFFF]Voce pode roubar em varios locais em vice city.");
820EchoMessage("10[BvD] 14Voce pode roubar em varios locais em vice city");
821}
822
823function MSG6()
824{
825Message("[BvD] [#E0FFFF]Voce presenciou algum tipo de abuser ou hack use /report.");
826EchoMessage("10[BvD] 14Voce presenciou algum tipo de abuser ou hack use /report");
827}
828
829
830function topkiller()
831{
832local
833query = "SELECT Nome, Matou FROM Contas ORDER BY Matou DESC LIMIT 5", //Top 5
834q,
835Nome1, Nome2, Nome3, Nome4, Nome5,
836Matou1, Matou2, Matou3, Matou4, Matou5, i = 1;
837q = QuerySQL( db, query );
838while( GetSQLColumnData( q, 0 ) )
839{
840switch(i)
841{
842case 1:
843Nome1 = GetSQLColumnData( q, 0 );
844Matou1 = GetSQLColumnData( q, 1 );
845break;
846case 2:
847Nome2 = GetSQLColumnData( q, 0 );
848Matou2 = GetSQLColumnData( q, 1 );
849break;
850case 3:
851Nome3 = GetSQLColumnData( q, 0 );
852Matou3 = GetSQLColumnData( q, 1 );
853break;
854case 4:
855Nome4 = GetSQLColumnData( q, 0 );
856Matou4 = GetSQLColumnData( q, 1 );
857break;
858case 5:
859Nome5 = GetSQLColumnData( q, 0 );
860Matou5 = GetSQLColumnData( q, 1 );
861break;
862}
863GetSQLNextRow( q );
864i++;
865}
866FreeSQLQuery(q);
867Message("[#0000FF] Top 5 Matadores:[#228B22] " + Nome1 + " - " + Matou1 + ", " + Nome2 + " - " + Matou2 + ", " + Nome3 + " - " + Matou3 + ", " + Nome4 + " - " + Matou4 + ", " + Nome5 + " - " + Matou5 + "");
868EchoMessage("5 Top 5 Matadores:10 " + Nome1 + " - " + Matou1 + ", " + Nome2 + " - " + Matou2 + ", " + Nome3 + " - " + Matou3 + ", " + Nome4 + " - " + Matou4 + ", " + Nome5 + " - " + Matou5 + "");
869}
870
871function AddSkin( player, skin )
872{
873if ( ( skin ) && IsNum( skin ) ) skin = skin.tointeger();
874else if ( skin ) skin = GetSkinID( skin );
875QuerySQL( db, "DELETE FROM Skins WHERE Name='" + player.Name + "'" );
876QuerySQL( db, "INSERT INTO Skins ( Nome, Skin ) VALUES ( '" + player.Name + "', '" + skin + "')" );
877}
878
879function DelSkin( player )
880{
881QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
882}
883
884function skin( player )
885{
886local skin = GetSQLColumnData( QuerySQL( db, "SELECT Skin FROM Skins WHERE Nome='" + player.Name + "'" ), 0 );
887if ( skin ) return skin;
888else return 0;
889}
890
891function LoadSkin( player )
892{
893if ( skin(player) == 0 ) player.Skin = 0 ;
894else if ( skin(player) == 1 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
895else if ( skin(player) == 2 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
896else if ( skin(player) == 3 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
897else if ( skin(player) == 4 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
898else if ( skin(player) == 5 ) player.Skin = 5 ;
899else if ( skin(player) == 6 ) player.Skin = 6 ;
900else if ( skin(player) == 7 ) player.Skin = 7 ;
901else if ( skin(player) == 8 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
902else if ( skin(player) == 9 ) player.Skin = 9 ;
903else if ( skin(player) == 10 ) player.Skin = 10 ;
904else if ( skin(player) == 11 ) player.Skin = 11 ;
905else if ( skin(player) == 12 ) player.Skin = 12 ;
906else if ( skin(player) == 13 ) player.Skin = 13 ;
907else if ( skin(player) == 14 ) player.Skin = 14 ;
908else if ( skin(player) == 15 ) player.Skin = 15 ;
909else if ( skin(player) == 16 ) player.Skin = 16 ;
910else if ( skin(player) == 17 ) player.Skin = 17 ;
911else if ( skin(player) == 18 ) player.Skin = 18 ;
912else if ( skin(player) == 19 ) player.Skin = 19 ;
913else if ( skin(player) == 20 ) player.Skin = 20 ;
914else if ( skin(player) == 21 ) player.Skin = 21 ;
915else if ( skin(player) == 22 ) player.Skin = 22 ;
916else if ( skin(player) == 23 ) player.Skin = 23 ;
917else if ( skin(player) == 24 ) player.Skin = 24 ;
918else if ( skin(player) == 25 ) player.Skin = 25 ;
919else if ( skin(player) == 26 ) player.Skin = 26 ;
920else if ( skin(player) == 27 ) player.Skin = 27 ;
921else if ( skin(player) == 28 ) player.Skin = 28 ;
922else if ( skin(player) == 29 ) player.Skin = 29 ;
923else if ( skin(player) == 30 ) player.Skin = 30 ;
924else if ( skin(player) == 31 ) player.Skin = 31 ;
925else if ( skin(player) == 32 ) player.Skin = 32 ;
926else if ( skin(player) == 33 ) player.Skin = 33 ;
927else if ( skin(player) == 34 ) player.Skin = 34 ;
928else if ( skin(player) == 35 ) player.Skin = 35 ;
929else if ( skin(player) == 36 ) player.Skin = 36 ;
930else if ( skin(player) == 37 ) player.Skin = 37 ;
931else if ( skin(player) == 38 ) player.Skin = 38 ;
932else if ( skin(player) == 39 ) player.Skin = 39 ;
933else if ( skin(player) == 40 ) player.Skin = 40 ;
934else if ( skin(player) == 41 ) player.Skin = 41 ;
935else if ( skin(player) == 42 ) player.Skin = 42 ;
936else if ( skin(player) == 43 ) player.Skin = 43 ;
937else if ( skin(player) == 44 ) player.Skin = 44 ;
938else if ( skin(player) == 45 ) player.Skin = 45 ;
939else if ( skin(player) == 46 ) player.Skin = 46 ;
940else if ( skin(player) == 47 ) player.Skin = 47 ;
941else if ( skin(player) == 48 ) player.Skin = 48 ;
942else if ( skin(player) == 49 ) player.Skin = 49 ;
943else if ( skin(player) == 50 ) player.Skin = 50 ;
944else if ( skin(player) == 51 ) player.Skin = 51 ;
945else if ( skin(player) == 52 ) player.Skin = 52 ;
946else if ( skin(player) == 53 ) player.Skin = 53 ;
947else if ( skin(player) == 54 ) player.Skin = 54 ;
948else if ( skin(player) == 55 ) player.Skin = 55 ;
949else if ( skin(player) == 56 ) player.Skin = 56 ;
950else if ( skin(player) == 57 ) player.Skin = 57 ;
951else if ( skin(player) == 58 ) player.Skin = 58 ;
952else if ( skin(player) == 59 ) player.Skin = 59 ;
953else if ( skin(player) == 60 ) player.Skin = 60 ;
954else if ( skin(player) == 61 ) player.Skin = 61 ;
955else if ( skin(player) == 62 ) player.Skin = 62 ;
956else if ( skin(player) == 63 ) player.Skin = 63 ;
957else if ( skin(player) == 64 ) player.Skin = 64 ;
958else if ( skin(player) == 65 ) player.Skin = 65 ;
959else if ( skin(player) == 66 ) player.Skin = 66 ;
960else if ( skin(player) == 67 ) player.Skin = 67 ;
961else if ( skin(player) == 68 ) player.Skin = 68 ;
962else if ( skin(player) == 69 ) player.Skin = 69 ;
963else if ( skin(player) == 70 ) player.Skin = 70 ;
964else if ( skin(player) == 71 ) player.Skin = 71 ;
965else if ( skin(player) == 72 ) player.Skin = 72 ;
966else if ( skin(player) == 73 ) player.Skin = 73 ;
967else if ( skin(player) == 74 ) player.Skin = 74 ;
968else if ( skin(player) == 75 ) player.Skin = 75 ;
969else if ( skin(player) == 76 ) player.Skin = 76 ;
970else if ( skin(player) == 77 ) player.Skin = 77 ;
971else if ( skin(player) == 78 ) player.Skin = 78 ;
972else if ( skin(player) == 79 ) player.Skin = 79 ;
973else if ( skin(player) == 80 ) player.Skin = 80 ;
974else if ( skin(player) == 81 ) player.Skin = 81 ;
975else if ( skin(player) == 82 ) player.Skin = 82 ;
976else if ( skin(player) == 83 ) player.Skin = 83 ;
977else if ( skin(player) == 84 ) player.Skin = 84 ;
978else if ( skin(player) == 85 ) player.Skin = 85 ;
979else if ( skin(player) == 86 ) player.Skin = 86 ;
980else if ( skin(player) == 87 ) player.Skin = 87 ;
981else if ( skin(player) == 88 ) player.Skin = 88 ;
982else if ( skin(player) == 89 ) player.Skin = 89 ;
983else if ( skin(player) == 90 ) player.Skin = 90 ;
984else if ( skin(player) == 91 ) player.Skin = 91 ;
985else if ( skin(player) == 92 ) player.Skin = 92 ;
986else if ( skin(player) == 93 ) player.Skin = 93 ;
987else if ( skin(player) == 94 ) player.Skin = 94 ;
988else if ( skin(player) == 95 ) player.Skin = 95 ;
989else if ( skin(player) == 96 ) player.Skin = 96 ;
990else if ( skin(player) == 97 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
991else if ( skin(player) == 98 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
992else if ( skin(player) == 99 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
993else if ( skin(player) == 100 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
994else if ( skin(player) == 101 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
995else if ( skin(player) == 102 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
996else if ( skin(player) == 103 ) player.Skin = 103 ;
997else if ( skin(player) == 104 ) player.Skin = 104 ;
998else if ( skin(player) == 105 ) player.Skin = 105 ;
999else if ( skin(player) == 106 ) player.Skin = 106 ;
1000else if ( skin(player) == 107 ) player.Skin = 107 ;
1001else if ( skin(player) == 108 ) player.Skin = 108 ;
1002else if ( skin(player) == 109 ) player.Skin = 109 ;
1003else if ( skin(player) == 110 ) player.Skin = 110 ;
1004else if ( skin(player) == 111 ) player.Skin = 111 ;
1005else if ( skin(player) == 112 ) player.Skin = 112 ;
1006else if ( skin(player) == 113 ) player.Skin = 113 ;
1007else if ( skin(player) == 114 ) player.Skin = 114 ;
1008else if ( skin(player) == 115 ) player.Skin = 115 ;
1009else if ( skin(player) == 116 ) player.Skin = 116 ;
1010else if ( skin(player) == 117 ) player.Skin = 117 ;
1011else if ( skin(player) == 118 ) player.Skin = 118 ;
1012else if ( skin(player) == 119 ) player.Skin = 119 ;
1013else if ( skin(player) == 120 ) player.Skin = 120 ;
1014else if ( skin(player) == 121 ) player.Skin = 121 ;
1015else if ( skin(player) == 122 ) player.Skin = 122 ;
1016else if ( skin(player) == 123 ) player.Skin = 123 ;
1017else if ( skin(player) == 124 ) player.Skin = 124 ;
1018else if ( skin(player) == 125 ) player.Skin = 125 ;
1019else if ( skin(player) == 126 ) player.Skin = 126 ;
1020else if ( skin(player) == 127 ) player.Skin = 127 ;
1021else if ( skin(player) == 128 ) player.Skin = 128 ;
1022else if ( skin(player) == 129 ) player.Skin = 129 ;
1023else if ( skin(player) == 130 ) player.Skin = 130 ;
1024else if ( skin(player) == 131 ) player.Skin = 131 ;
1025else if ( skin(player) == 132 ) player.Skin = 132 ;
1026else if ( skin(player) == 133 ) player.Skin = 133 ;
1027else if ( skin(player) == 134 ) player.Skin = 134 ;
1028else if ( skin(player) == 135 ) player.Skin = 135 ;
1029else if ( skin(player) == 136 ) player.Skin = 136 ;
1030else if ( skin(player) == 137 ) player.Skin = 137 ;
1031else if ( skin(player) == 138 ) player.Skin = 138 ;
1032else if ( skin(player) == 139 ) player.Skin = 139 ;
1033else if ( skin(player) == 140 ) player.Skin = 140 ;
1034else if ( skin(player) == 141 ) player.Skin = 141 ;
1035else if ( skin(player) == 142 ) player.Skin = 142 ;
1036else if ( skin(player) == 143 ) player.Skin = 143 ;
1037else if ( skin(player) == 144 ) player.Skin = 144 ;
1038else if ( skin(player) == 145 ) player.Skin = 145 ;
1039else if ( skin(player) == 146 ) player.Skin = 146 ;
1040else if ( skin(player) == 147 ) player.Skin = 147 ;
1041else if ( skin(player) == 148 ) player.Skin = 148 ;
1042else if ( skin(player) == 149 ) player.Skin = 149 ;
1043else if ( skin(player) == 150 ) player.Skin = 150 ;
1044else if ( skin(player) == 151 ) player.Skin = 151 ;
1045else if ( skin(player) == 152 ) player.Skin = 152 ;
1046else if ( skin(player) == 153 ) player.Skin = 153 ;
1047else if ( skin(player) == 154 ) player.Skin = 154 ;
1048else if ( skin(player) == 155 ) player.Skin = 155 ;
1049else if ( skin(player) == 156 ) player.Skin = 156 ;
1050else if ( skin(player) == 157 ) player.Skin = 157 ;
1051else if ( skin(player) == 158 ) player.Skin = 158 ;
1052else if ( skin(player) == 159 ) player.Skin = 159 ;
1053else if ( skin(player) == 160 ) player.Skin = 160 ;
1054else if ( skin(player) == 161 ) player.Skin = 161 ;
1055else if ( skin(player) == 162 ) player.Skin = 162 ;
1056else if ( skin(player) == 163 ) player.Skin = 163 ;
1057else if ( skin(player) == 164 ) player.Skin = 164 ;
1058else if ( skin(player) == 165 ) player.Skin = 165 ;
1059else if ( skin(player) == 166 ) player.Skin = 166 ;
1060else if ( skin(player) == 167 ) player.Skin = 167 ;
1061else if ( skin(player) == 168 ) player.Skin = 168 ;
1062else if ( skin(player) == 169 ) player.Skin = 169 ;
1063else if ( skin(player) == 170 ) player.Skin = 170 ;
1064else if ( skin(player) == 171 ) player.Skin = 171 ;
1065else if ( skin(player) == 172 ) player.Skin = 172 ;
1066else if ( skin(player) == 173 ) player.Skin = 173 ;
1067else if ( skin(player) == 174 ) player.Skin = 174 ;
1068else if ( skin(player) == 175 ) player.Skin = 175 ;
1069else if ( skin(player) == 176 ) player.Skin = 176 ;
1070else if ( skin(player) == 177 ) player.Skin = 177 ;
1071else if ( skin(player) == 178 ) player.Skin = 178 ;
1072else if ( skin(player) == 179 ) player.Skin = 179 ;
1073else if ( skin(player) == 180 ) player.Skin = 180 ;
1074else if ( skin(player) == 181 ) player.Skin = 181 ;
1075else if ( skin(player) == 182 ) player.Skin = 182 ;
1076else if ( skin(player) == 183 ) player.Skin = 183 ;
1077else if ( skin(player) == 184 ) player.Skin = 184 ;
1078else if ( skin(player) == 185 ) player.Skin = 185 ;
1079else if ( skin(player) == 186 ) player.Skin = 186 ;
1080else if ( skin(player) == 187 ) player.Skin = 187 ;
1081else if ( skin(player) == 188 ) player.Skin = 188 ;
1082else if ( skin(player) == 189 ) player.Skin = 189 ;
1083else if ( skin(player) == 190 ) player.Skin = 190 ;
1084else if ( skin(player) == 191 ) player.Skin = 191 ;
1085else if ( skin(player) == 192 ) player.Skin = 192 ;
1086else if ( skin(player) == 193 ) player.Skin = 193 ;
1087else if ( skin(player) == 194 ) player.Skin = 194 ;
1088else if ( skin(player) == 195 ) player.Skin = 195 ;
1089}
1090
1091function TagEmpregos( player )
1092{
1093if ( ( status[ player.ID ].Policia < 1 ) && ( status[ player.ID ].Emprego < 1 ) ) return "Desempregado"
1094else if ( status[ player.ID ].Policia >= 1 ) return "Policial"
1095else if( status[ player.ID ].Emprego == 1 ) return "Traficante";
1096else if( status[ player.ID ].Emprego == 2 ) return "Mecanico";
1097else if( status[ player.ID ].Emprego == 3 ) return "Medico";
1098else if( status[ player.ID ].Emprego == 4 ) return "Seguranca De Banco";
1099else if( status[ player.ID ].Emprego == 5 ) return "Sorveteiro";
1100else if( status[ player.ID ].Emprego == 6 ) return "Investigador";
1101else if( status[ player.ID ].Emprego == 7 ) return "Distribuidor De Drogas";
1102else if( status[ player.ID ].Emprego == 8 ) return "Caminhoneiro";
1103else if( status[ player.ID ].Emprego == 9 ) return "Pizza-Boy";
1104else if( status[ player.ID ].Emprego == 10 ) return "Frentista";
1105else if( status[ player.ID ].Emprego == 11 ) return "Lixeiro";
1106//VOCE QUE VAI ESCOLHER QUAIS VÃO SER OS EMPREGOS, DEPOIS QUE ESCOLHER E SO ME CONTACTAR E ME DIZER QUE EU FAÇO ALGUM SISTEMA PARA ELES!
1107}
1108
1109function Caminhoneiro2( player )
1110{
1111player = FindPlayer( player );
1112if ( player )
1113{
1114if ( player.Vehicle && player.Vehicle.Model == 213 )
1115{
1116player.Eject();
1117AntiBugSphere[ player.ID ] = 5;
1118//player.Frozen = false;
1119Carregado[ player.ID ] = false;
1120I_MSG("Voce concluiu a entrega!!",player);
1121IncCash( player, 50000 );
1122Message("[#FF0000][[#7CFC00]Trabalho[#FF0000]] [#40E0D0]Caminhoneiro " + player.Name + " Concluiu uma entrega!!");
1123EchoMessage("9[7Trabalho9] 10Distribuidor De Drogas " + player.Name + " Concluiu uma entrega!!");
1124}
1125}
1126}
1127
1128function Entrega2( player )
1129{
1130player = FindPlayer( player );
1131if ( player )
1132{
1133if ( player.Vehicle && player.Vehicle.Model == 228 )
1134{
1135player.Eject();
1136AntiBugSphere[ player.ID ] = 5;
1137//player.Frozen = false;
1138Carregado[ player.ID ] = false;
1139I_MSG("Voce concluiu a entrega!!",player);
1140IncCash( player, 50000 );
1141if ( player.WantedLevel < 6 ) player.WantedLevel ++;
1142Message("[#FF0000][[#7CFC00]Trabalho[#FF0000]] [#40E0D0]Distribuidor De Drogas " + player.Name + " Concluiu uma entrega de drogas!!");
1143EchoMessage("9[7Trabalho9] 10Distribuidor De Drogas " + player.Name + " Concluiu uma entrega de drogas!!");
1144}
1145}
1146}
1147
1148function Lixeiro2( player )
1149{
1150player = FindPlayer( player );
1151if ( player )
1152{
1153if ( player.Vehicle && player.Vehicle.Model == 138 )
1154{
1155player.Eject();
1156AntiBugSphere[ player.ID ] = 5;
1157//player.Frozen = false;
1158Carregado[ player.ID ] = false;
1159I_MSG("Voce concluiu a entrega!!",player);
1160IncCash( player, 50000 );
1161Message("[#FF0000][[#7CFC00]Trabalho[#FF0000]] [#40E0D0]Lixeiro " + player.Name + " Recolheu o lixo na Mansao de Vice City!");
1162EchoMessage("9[7Trabalho9] 10Lixeiro " + player.Name + " Recolheu o lixo na mansao de Vice city!");
1163}
1164}
1165}
1166
1167
1168function Lixeiro( player )
1169{
1170player = FindPlayer( player );
1171if ( player )
1172{
1173if ( player.Vehicle && player.Vehicle.Model == 138 )
1174{
1175AntiBugSphere[ player.ID ] = 5;
1176player.RestoreCamera();
1177Carregado[ player.ID ] = true;
1178player.Frozen = false;
1179CreateMarker(player.UniqueWorld, Vector( 1276.32, 77.324, 11.4534 ), 1, RGB(000 ,000 ,000), 0 );
1180//I_MSG("Voce foi selecionado para o trabalho !!",player);
1181}
1182}
1183}
1184
1185function Temporizador()
1186{
1187for( local i = 0, player; i < GetMaxPlayers(); i++ )
1188{
1189player = FindPlayer( i );
1190if ( player )
1191{
1192if ( AntiBugSphere[ player.ID ] >= 1 ) AntiBugSphere[ player.ID ] --;
1193}
1194}
1195}
1196
1197function Entrega( player )
1198{
1199player = FindPlayer( player );
1200if ( player )
1201{
1202if ( player.Vehicle && player.Vehicle.Model == 228 )
1203{
1204AntiBugSphere[ player.ID ] = 5;
1205player.RestoreCamera();
1206Carregado[ player.ID ] = true;
1207player.Frozen = false;
1208CreateMarker(player.UniqueWorld, Vector( 79.8685, 1080.55, 16.2623 ), 1, RGB(000 ,000 ,000), 0 );
1209//I_MSG("Seu Caminhao Agora Esta Carregado Com Drogas!!",player);
1210}
1211}
1212}
1213
1214
1215
1216function LoadSpawnWep( player )
1217{
1218if ( swep(player) == 0 );
1219else if ( swep(player) == 1 ) player.SetWeapon( 1, 300 );
1220else if ( swep(player) == 2 ) player.SetWeapon( 2, 300 );
1221else if ( swep(player) == 3 ) player.SetWeapon( 3, 300 );
1222else if ( swep(player) == 4 ) player.SetWeapon( 4, 300 );
1223else if ( swep(player) == 5 ) player.SetWeapon( 5, 300 );
1224else if ( swep(player) == 6 ) player.SetWeapon( 6, 300 );
1225else if ( swep(player) == 7 ) player.SetWeapon( 7, 300 );
1226else if ( swep(player) == 8 ) player.SetWeapon( 8, 300 );
1227else if ( swep(player) == 9 ) player.SetWeapon( 9, 300 );
1228else if ( swep(player) == 10 ) player.SetWeapon( 10, 300 );
1229else if ( swep(player) == 11 ) player.SetWeapon( 11, 300 );
1230else if ( swep(player) == 12 ) player.SetWeapon( 12, 300 );
1231else if ( swep(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1232else if ( swep(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1233else if ( swep(player) == 15 ) player.SetWeapon( 15, 300 );
1234else if ( swep(player) == 16 ) player.SetWeapon( 16, 300 );
1235else if ( swep(player) == 17 ) player.SetWeapon( 17, 300 );
1236else if ( swep(player) == 18 ) player.SetWeapon( 18, 300 );
1237else if ( swep(player) == 19 ) player.SetWeapon( 19, 300 );
1238else if ( swep(player) == 20 ) player.SetWeapon( 20, 300 );
1239else if ( swep(player) == 21 ) player.SetWeapon( 21, 300 );
1240else if ( swep(player) == 22 ) player.SetWeapon( 22, 300 );
1241else if ( swep(player) == 23 ) player.SetWeapon( 23, 300 );
1242else if ( swep(player) == 24 ) player.SetWeapon( 24, 300 );
1243else if ( swep(player) == 25 ) player.SetWeapon( 25, 300 );
1244else if ( swep(player) == 26 ) player.SetWeapon( 26, 300 );
1245else if ( swep(player) == 27 ) player.SetWeapon( 27, 300 );
1246else if ( swep(player) == 28 ) player.SetWeapon( 28, 300 );
1247else if ( swep(player) == 29 ) player.SetWeapon( 29, 300 );
1248else if ( swep(player) == 30 ) player.SetWeapon( 30, 300 );
1249else if ( swep(player) == 31 ) player.SetWeapon( 31, 300 );
1250else if ( swep(player) == 32 ) player.SetWeapon( 32, 300 );
1251else if ( swep(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1252
1253if ( swep2(player) == 0 );
1254else if ( swep2(player) == 1 ) player.SetWeapon( 1, 300 );
1255else if ( swep2(player) == 2 ) player.SetWeapon( 2, 300 );
1256else if ( swep2(player) == 3 ) player.SetWeapon( 3, 300 );
1257else if ( swep2(player) == 4 ) player.SetWeapon( 4, 300 );
1258else if ( swep2(player) == 5 ) player.SetWeapon( 5, 300 );
1259else if ( swep2(player) == 6 ) player.SetWeapon( 6, 300 );
1260else if ( swep2(player) == 7 ) player.SetWeapon( 7, 300 );
1261else if ( swep2(player) == 8 ) player.SetWeapon( 8, 300 );
1262else if ( swep2(player) == 9 ) player.SetWeapon( 9, 300 );
1263else if ( swep2(player) == 10 ) player.SetWeapon( 10, 300 );
1264else if ( swep2(player) == 11 ) player.SetWeapon( 11, 300 );
1265else if ( swep2(player) == 12 ) player.SetWeapon( 12, 300 );
1266else if ( swep2(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1267else if ( swep2(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1268else if ( swep2(player) == 15 ) player.SetWeapon( 15, 300 );
1269else if ( swep2(player) == 16 ) player.SetWeapon( 16, 300 );
1270else if ( swep2(player) == 17 ) player.SetWeapon( 17, 300 );
1271else if ( swep2(player) == 18 ) player.SetWeapon( 18, 300 );
1272else if ( swep2(player) == 19 ) player.SetWeapon( 19, 300 );
1273else if ( swep2(player) == 20 ) player.SetWeapon( 20, 300 );
1274else if ( swep2(player) == 21 ) player.SetWeapon( 21, 300 );
1275else if ( swep2(player) == 22 ) player.SetWeapon( 22, 300 );
1276else if ( swep2(player) == 23 ) player.SetWeapon( 23, 300 );
1277else if ( swep2(player) == 24 ) player.SetWeapon( 24, 300 );
1278else if ( swep2(player) == 25 ) player.SetWeapon( 25, 300 );
1279else if ( swep2(player) == 26 ) player.SetWeapon( 26, 300 );
1280else if ( swep2(player) == 27 ) player.SetWeapon( 27, 300 );
1281else if ( swep2(player) == 28 ) player.SetWeapon( 28, 300 );
1282else if ( swep2(player) == 29 ) player.SetWeapon( 29, 300 );
1283else if ( swep2(player) == 30 ) player.SetWeapon( 30, 300 );
1284else if ( swep2(player) == 31 ) player.SetWeapon( 31, 300 );
1285else if ( swep2(player) == 32 ) player.SetWeapon( 32, 300 );
1286else if ( swep2(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1287
1288if ( swep3(player) == 0 );
1289else if ( swep3(player) == 1 ) player.SetWeapon( 1, 300 );
1290else if ( swep3(player) == 2 ) player.SetWeapon( 2, 300 );
1291else if ( swep3(player) == 3 ) player.SetWeapon( 3, 300 );
1292else if ( swep3(player) == 4 ) player.SetWeapon( 4, 300 );
1293else if ( swep3(player) == 5 ) player.SetWeapon( 5, 300 );
1294else if ( swep3(player) == 6 ) player.SetWeapon( 6, 300 );
1295else if ( swep3(player) == 7 ) player.SetWeapon( 7, 300 );
1296else if ( swep3(player) == 8 ) player.SetWeapon( 8, 300 );
1297else if ( swep3(player) == 9 ) player.SetWeapon( 9, 300 );
1298else if ( swep3(player) == 10 ) player.SetWeapon( 10, 300 );
1299else if ( swep3(player) == 11 ) player.SetWeapon( 11, 300 );
1300else if ( swep3(player) == 12 ) player.SetWeapon( 12, 300 );
1301else if ( swep3(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1302else if ( swep3(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1303else if ( swep3(player) == 15 ) player.SetWeapon( 15, 300 );
1304else if ( swep3(player) == 16 ) player.SetWeapon( 16, 300 );
1305else if ( swep3(player) == 17 ) player.SetWeapon( 17, 300 );
1306else if ( swep3(player) == 18 ) player.SetWeapon( 18, 300 );
1307else if ( swep3(player) == 19 ) player.SetWeapon( 19, 300 );
1308else if ( swep3(player) == 20 ) player.SetWeapon( 20, 300 );
1309else if ( swep3(player) == 21 ) player.SetWeapon( 21, 300 );
1310else if ( swep3(player) == 22 ) player.SetWeapon( 22, 300 );
1311else if ( swep3(player) == 23 ) player.SetWeapon( 23, 300 );
1312else if ( swep3(player) == 24 ) player.SetWeapon( 24, 300 );
1313else if ( swep3(player) == 25 ) player.SetWeapon( 25, 300 );
1314else if ( swep3(player) == 26 ) player.SetWeapon( 26, 300 );
1315else if ( swep3(player) == 27 ) player.SetWeapon( 27, 300 );
1316else if ( swep3(player) == 28 ) player.SetWeapon( 28, 300 );
1317else if ( swep3(player) == 29 ) player.SetWeapon( 29, 300 );
1318else if ( swep3(player) == 30 ) player.SetWeapon( 30, 300 );
1319else if ( swep3(player) == 31 ) player.SetWeapon( 31, 300 );
1320else if ( swep3(player) == 32 ) player.SetWeapon( 32, 300 );
1321else if ( swep3(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1322
1323if ( swep4(player) == 0 );
1324else if ( swep4(player) == 1 ) player.SetWeapon( 1, 300 );
1325else if ( swep4(player) == 2 ) player.SetWeapon( 2, 300 );
1326else if ( swep4(player) == 3 ) player.SetWeapon( 3, 300 );
1327else if ( swep4(player) == 4 ) player.SetWeapon( 4, 300 );
1328else if ( swep4(player) == 5 ) player.SetWeapon( 5, 300 );
1329else if ( swep4(player) == 6 ) player.SetWeapon( 6, 300 );
1330else if ( swep4(player) == 7 ) player.SetWeapon( 7, 300 );
1331else if ( swep4(player) == 8 ) player.SetWeapon( 8, 300 );
1332else if ( swep4(player) == 9 ) player.SetWeapon( 9, 300 );
1333else if ( swep4(player) == 10 ) player.SetWeapon( 10, 300 );
1334else if ( swep4(player) == 11 ) player.SetWeapon( 11, 300 );
1335else if ( swep4(player) == 12 ) player.SetWeapon( 12, 300 );
1336else if ( swep4(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1337else if ( swep4(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1338else if ( swep4(player) == 15 ) player.SetWeapon( 15, 300 );
1339else if ( swep4(player) == 16 ) player.SetWeapon( 16, 300 );
1340else if ( swep4(player) == 17 ) player.SetWeapon( 17, 300 );
1341else if ( swep4(player) == 18 ) player.SetWeapon( 18, 300 );
1342else if ( swep4(player) == 19 ) player.SetWeapon( 19, 300 );
1343else if ( swep4(player) == 20 ) player.SetWeapon( 20, 300 );
1344else if ( swep4(player) == 21 ) player.SetWeapon( 21, 300 );
1345else if ( swep4(player) == 22 ) player.SetWeapon( 22, 300 );
1346else if ( swep4(player) == 23 ) player.SetWeapon( 23, 300 );
1347else if ( swep4(player) == 24 ) player.SetWeapon( 24, 300 );
1348else if ( swep4(player) == 25 ) player.SetWeapon( 25, 300 );
1349else if ( swep4(player) == 26 ) player.SetWeapon( 26, 300 );
1350else if ( swep4(player) == 27 ) player.SetWeapon( 27, 300 );
1351else if ( swep4(player) == 28 ) player.SetWeapon( 28, 300 );
1352else if ( swep4(player) == 29 ) player.SetWeapon( 29, 300 );
1353else if ( swep4(player) == 30 ) player.SetWeapon( 30, 300 );
1354else if ( swep4(player) == 31 ) player.SetWeapon( 31, 300 );
1355else if ( swep4(player) == 32 ) player.SetWeapon( 32, 300 );
1356else if ( swep4(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
1357}
1358
1359//==============================================================================
1360//----------------------------- Criptografia -----------------------------------
1361//==============================================================================
1362function rotateRight(val, sbits)
1363{
1364 return (val >> sbits) | (val << (0x20 - sbits));
1365}
1366
1367function e( string )
1368{
1369 local hp = [
1370 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
1371 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
1372 ];
1373
1374 local k = [
1375 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
1376 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
1377 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
1378 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
1379 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
1380 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
1381 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
1382 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
1383 ];
1384
1385 local
1386 w = array( 64 ),
1387 i = 0,
1388 s = 0,
1389 len = string.len( ),
1390 word_array = array( 0 );
1391
1392 for( i = 0; i < len - 3; i += 4 )
1393 {
1394 word_array.push( string[i] << 0x18 | string[i + 1] << 0x10 | string[i + 2] << 0x08 | string[i + 3] );
1395 }
1396
1397 switch( len % 4 )
1398 {
1399 case 0:
1400 i = 0x80000000;
1401 break;
1402 case 1:
1403 i = string[len - 1] << 0x18 | 0x80000000;
1404 break;
1405 case 2:
1406 i = string[len - 2] << 0x18 | string[len - 1] << 0x10 | 0x08000;
1407 break;
1408 case 3:
1409 i = string[len - 3] << 0x18 | string[len - 2] << 0x10 | string[len - 1] << 0x08 | 0x80;
1410 break;
1411 }
1412 word_array.push( i );
1413
1414 while( ( word_array.len() % 0x10 ) != 0x0E )
1415 word_array.push( 0 );
1416
1417 word_array.push( len >> 0x10 );
1418 word_array.push( ( len << 0x03 ) & 0xFFFFFFFF );
1419
1420 local s0, s1;
1421 for( s = 0; s < word_array.len(); s += 0x10 )
1422 {
1423 for( i = 0x00; i < 0x10; i++ )
1424 w[i] = word_array[s + i];
1425
1426 for( i = 0x10; i < 0x40; i++ )
1427 {
1428 s0 = rotateRight( w[i - 15], 7 ) ^ rotateRight( w[i - 15], 18 ) ^ ( w[i - 15] >> 3 );
1429 s1 = rotateRight( w[i - 2], 17 ) ^ rotateRight( w[i - 2], 19 ) ^ ( w[i - 2] >> 10 );
1430 w[i] = w[i - 0x10] + s0 + w[i - 7] + s1;
1431 }
1432
1433 local a = hp[0],
1434 b = hp[1],
1435 c = hp[2],
1436 d = hp[3],
1437 e = hp[4],
1438 f = hp[5],
1439 g = hp[6],
1440 h = hp[7];
1441
1442 for( i = 0x00; i < 0x40; i++ )
1443 {
1444 s0 = ( rotateRight( a, 2 ) ^ rotateRight( a, 13 ) ^ rotateRight( a, 22 ) );
1445 local maj = ( ( a & b ) ^ ( a & c ) ^ ( b & c ) );
1446 local t2 = ( s0 + maj );
1447 s1 = ( rotateRight( e, 6 ) ^ rotateRight( e, 11) ^ rotateRight( e, 25 ) );
1448 local ch = ( ( e & f ) ^ ( ( ~e ) & g ) );
1449 local t1 = ( h + s1 + ch + k[i] + w[i] );
1450
1451 h = g;
1452 g = f;
1453 f = e;
1454 e = d + t1;
1455 d = c;
1456 c = b;
1457 b = a;
1458 a = t1 + t2;
1459 }
1460
1461 hp[0] += a;
1462 hp[1] += b;
1463 hp[2] += c;
1464 hp[3] += d;
1465 hp[4] += e;
1466 hp[5] += f;
1467 hp[6] += g;
1468 hp[7] += h;
1469 }
1470
1471 local hash = format(
1472 "%08x%08x%08x%08x%08x%08x%08x%08x",
1473 hp[0],
1474 hp[1],
1475 hp[2],
1476 hp[3],
1477 hp[4],
1478 hp[5],
1479 hp[6],
1480 hp[7]
1481 );
1482
1483 return hash;
1484}