· 8 years ago · Mar 16, 2018, 08:16 PM
1//==============================================================================
2//------------------------- Server Functions -----------------------------------
3//==============================================================================
4/*
5 Server: Extreme City
6 Coding by: Florenco
7*/
8
9// One equals first biggest Island/ Two equals all center Islands/ Three equals other big Island
10Player_Island <- array( GetMaxPlayers(), 0 );
11// North and South/one/two
12Player_Locator <- array( GetMaxPlayers(), 0 );
13
14// Death Spawn
15Hospital_Spawn <- array( GetMaxPlayers(), false );
16HospitalSpawnLocations <- [ Vector( -886.074,-470.278,13.1109 ), Vector( -783.051,1141.83,12.4111), Vector( 467.763,697.68,11.7033 ), Vector( -135.137,-981.579,10.4634 ) ];
17Hospital_Locator <- array( GetMaxPlayers() );
18
19District_ID <- array(120, 0);
20District_Name <- array(120, "");
21SpawnKill <- array(GetMaxPlayers(), 0 );
22
23oldGetVehicleNameFromModel <- GetVehicleNameFromModel;
24function GetVehicleNameFromModel( modelID )
25{
26 switch( modelID )
27 {
28 case 6400:
29 {
30 return "Camaro";
31 }
32 break;
33 case 6401:
34 {
35 return "Tapete";
36 }
37 break;
38 case 6402:
39 {
40 return "Cop Bike";
41 }
42 break;
43 case 6403:
44 {
45 return "Hydra";
46 }
47 break;
48 case 6404:
49 {
50 return "Saveiro Pancadao";
51 }
52 break;
53 case 6405:
54 {
55 return "Porsche Cayenne";
56 }
57 break;
58 case 6406:
59 {
60 return "BMW Z4";
61 }
62 break;
63 case 6407:
64 {
65 return "Lamborghini Aventador";
66 }
67 break;
68 case 6408:
69 {
70 return "Buggati Veyron";
71 }
72 break;
73 case 6409:
74 {
75 return "Ferrari La Ferrari";
76 }
77 break;
78 case 6410:
79 {
80 return "Bicycle";
81 }
82 break;
83 case 6411:
84 {
85 return "Batmovel";
86 }
87 break; case 6412:
88 {
89 return "Porsche 911 GT2";
90 }
91 break;
92 case 6413:
93 {
94 return "Mercedes Benz";
95 }
96 break;
97 case 6414:
98 {
99 return "Salmvan";
100 }
101 break; case 6415:
102 {
103 return "Suzuki 1000RR";
104 }
105 break;
106 case 6416:
107 {
108 return "Horse";
109 }
110 break;
111 case 6417:
112 {
113 return "Carroca";
114 }
115 break;
116 case 6455:
117 {
118 return "Mustang";
119 }
120 break;
121 case 6461:
122 {
123 return "Lamborghini Galardo";
124 }
125 break;
126
127 default:
128 {
129 return oldGetVehicleNameFromModel( modelID );
130 }
131 break;
132 };
133};
134
135//-----------------------------------------------------------------------------------------
136
137function SetPlayersDistrict(Name, player) {
138 switch(Name) {
139 /* First Island */
140 case "Vice Point": return District_ID[player.ID] = 1;
141 case "Ocean Beach": return District_ID[player.ID] = 2;
142 case "Washington Beach": return District_ID[player.ID] = 3;
143
144 /* Center Shit */
145 case "Leaf Links": return District_ID[player.ID] = 4;
146 case "Starfish Island": return District_ID[player.ID] = 5;
147 case "Prawn Island": return District_ID[player.ID] = 6;
148
149 /* Third Island */
150 case "Escobar International Airport": return District_ID[player.ID] = 7;
151 case "Downtown Vice City": return District_ID[player.ID] = 8;
152 case "Junkyard": return District_ID[player.ID] = 9;
153 case "Little Haiti": return District_ID[player.ID] = 10;
154 case "Little Havana": return District_ID[player.ID] = 11;
155 case "Little Haiti": return District_ID[player.ID] = 12;
156
157 case "Viceport": return District_ID[player.ID] = 13;
158 case "Vice City": return District_ID[player.ID] = 14;
159 default: return District_ID[player.ID] = 0;
160 }
161}
162
163//-----------------------------------------------------------------------------------------
164
165function GetPlayerIsland(player) {
166 if ( ( District_ID[player.ID] >= 1 ) && ( District_ID[player.ID] <= 3 ) ) {
167 if (NearestHospital(player.Pos) == 1 ) {
168 Player_Island[player.ID] = 1;
169 Player_Locator[player.ID] = 1;
170 }
171 if (NearestHospital(player.Pos) == 2 ) {
172 Player_Island[player.ID] = 1;
173 Player_Locator[player.ID] = 2;
174 }
175 }
176
177 if ( ( District_ID[player.ID] >= 4 ) && ( District_ID[player.ID] <= 6 ) ) {
178 if (NearestHospital(player.Pos) == 1 ) {
179 Player_Island[player.ID] = 2;
180 Player_Locator[player.ID] = 1;
181 }
182 if (NearestHospital(player.Pos) == 2 ) {
183 Player_Island[player.ID] = 2;
184 Player_Locator[player.ID] = 2;
185 }
186 }
187
188 if ( ( District_ID[player.ID] >= 7 ) && ( District_ID[player.ID] <= 12 ) ) {
189 if (NearestHospital(player.Pos) == 1 ) {
190 Player_Island[player.ID] = 3;
191 Player_Locator[player.ID] = 1;
192 }
193 if (NearestHospital(player.Pos) == 2 ) {
194 Player_Island[player.ID] = 3;
195 Player_Locator[player.ID] = 2;
196 }
197 }
198
199 if ( ( District_ID[player.ID] == 13 ) || ( District_ID[player.ID] == 0 ) || ( District_ID[player.ID] == 14 )) {
200 if ((GetIsland(player.Pos) == 1 ) && ( NearestHospital(player.Pos) == 1 )) {
201 Player_Island[player.ID] = 1;
202 Player_Locator[player.ID] = 1;
203 }
204 if ((GetIsland(player.Pos) == 1 ) && ( NearestHospital(player.Pos) == 2 )) {
205 Player_Island[player.ID] = 1;
206 Player_Locator[player.ID] = 2;
207 }
208 if ((GetIsland(player.Pos) == 2 ) && ( NearestHospital(player.Pos) == 1 )) {
209 Player_Island[player.ID] = 2;
210 Player_Locator[player.ID] = 1;
211 }
212 if ((GetIsland(player.Pos) == 2 ) && ( NearestHospital(player.Pos) == 2 )) {
213 if (player.Pos.x < -500 ) {
214 Player_Island[player.ID] = 3;
215 Player_Locator[player.ID] = 2;
216 }
217 else{
218 Player_Island[player.ID] = 2;
219 Player_Locator[player.ID] = 2;
220 }
221 }
222 if ((GetIsland(player.Pos) == 3 ) && ( NearestHospital(player.Pos) == 1 )) {
223 Player_Island[player.ID] = 3;
224 Player_Locator[player.ID] = 1;
225 }
226 if ((GetIsland(player.Pos) == 3 ) && ( NearestHospital(player.Pos) == 2 )) {
227 Player_Island[player.ID] = 3;
228 Player_Locator[player.ID] = 2;
229 }
230 }
231}
232
233//-----------------------------------------------------------------------------------------
234
235function GetNearestHospital(player) {
236 Hospital_Spawn[player.ID] = true;
237 Hospital_Locator[player.ID] = player.Pos;
238
239 District_Name[player.ID] = GetDistrictName(player.Pos.x, player.Pos.y);
240
241 SetPlayersDistrict(District_Name[player.ID], player); //Do not remove player, LOL..
242
243 GetPlayerIsland(player);
244 if ( Player_Island[player.ID] == 1 ) {
245 local
246 pos = player.Pos,
247 first_check = GetDistance(HospitalSpawnLocations[2], pos).tointeger(),
248 second_check = GetDistance(HospitalSpawnLocations[3], pos).tointeger();
249
250 if (first_check <= second_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[2];
251 else if (second_check <= first_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[3];
252 }
253
254 if ( Player_Island[player.ID] == 3 ) {
255 local
256 pos = player.Pos,
257 first_check = GetDistance(HospitalSpawnLocations[0], pos).tointeger(),
258 second_check = GetDistance(HospitalSpawnLocations[1], pos).tointeger();
259
260 if (first_check <= second_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[0];
261 else if (second_check <= first_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[1];
262 }
263
264 if ( Player_Island[player.ID] == 2 ) {
265 if (Player_Locator[player.ID] == 1 ) {
266 local
267 pos = player.Pos,
268 first_check = GetDistance(HospitalSpawnLocations[1], pos).tointeger(),
269 second_check = GetDistance(HospitalSpawnLocations[2], pos).tointeger();
270
271 if (first_check <= second_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[1];
272 else if (second_check <= first_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[2];
273 }
274
275 if (Player_Locator[player.ID] == 2 ) {
276 local
277 pos = player.Pos,
278 first_check = GetDistance(HospitalSpawnLocations[0], pos).tointeger(),
279 second_check = GetDistance(HospitalSpawnLocations[3], pos).tointeger();
280
281 if (first_check <= second_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[0];
282 else if (second_check <= first_check ) Hospital_Locator[player.ID] = HospitalSpawnLocations[3];
283 }
284 }
285}
286//-----------------------------------------------------------------------------------------
287function GetIsland(pos) {
288
289 // First Island
290 if (pos.x > -170) return 1;
291 // Third Island
292 if (pos.x < -716) return 3;
293
294 // Center island BS
295 return 2;
296}
297
298function NearestHospital(pos) {
299 if (pos.y >= 0) return 1; // north hospitals
300 if (pos.y <= 0) return 2; // south hospitals
301}
302//-----------------------------------------------------------------------------------------
303function onPlayerRequestClass( player, classID, team, skin ) {
304 if (Hospital_Spawn[player.ID] == true) { player.Spawn(); }
305}
306
307function onPlayerSpawn(player) {
308 // Spawn data
309 if (Hospital_Spawn[player.ID] == true) { player.Pos = Hospital_Locator[player.ID]; Hospital_Spawn[player.ID] = false; }
310}
311
312function onPlayerKill( killer, killed, reason, bodypart ) {
313 GetNearestHospital(killed);
314}
315function onPlayerDeath( player, reason ) {
316 GetNearestHospital(player);
317}
318
319function GetDistance(pos1, pos2)
320{
321 return sqrt(pow(pos1.x - pos2.x, 2) + pow(pos1.y - pos2.y, 2) + pow(pos1.z - pos2.z, 2));
322}
323
324function onPlayerPart(player, reason) {
325 Player_Island[player.ID] = 0;
326 Player_Locator[player.ID] = 0;
327 Hospital_Spawn[player.ID] = false;
328 Hospital_Locator[player.ID] = null;
329
330 District_ID[player.ID] = 0;
331 District_Name[player.ID] = "";
332}
333
334//-----------------------------------------------------------------------------------------
335HideMapObject(1587,-1074.912964,-276.7081299,11.05003262); //pw_presrommshad - Print Works
336HideMapObject( 379, -1721.86,-293.002, 15.1086 )
337HideMapObject( 813, -832.981,-1484.41, 12.9336 )
338HideMapObject( 832, -844.324,-1496.67, 12.7424 )
339HideMapObject( 474, -879.05,-362.036, 11.3873 )
340HideMapObject( 449, -891.555,-356.085, 11.1887 )
341HideMapObject( 474, -890.837,-349.622, 12.0561)
342HideMapObject( 474, -890.875,-361.886, 12.0561)
343HideMapObject( 474, -879.072,-350.381, 11.3873)
344HideMapObject( 474, -890.189,-331.894, 12.0561)
345HideMapObject( 474, -878.258,-330.723, 11.2693)
346HideMapObject( 449, -890.156,-325.002, 11.1887)
347HideMapObject( 474, -877.137,-318.868, 11.2693)
348HideMapObject( 474, -889.261,-317.071, 12.0561)
349HideMapObject( 474, -854.112,-321.801, 9.27197)
350HideMapObject( 474, -855.012,-351.864, 9.27197)
351HideMapObject( 474, -855.972,-388.961, 9.27197)
352HideMapObject( 474, -854.957,-436.886, 9.27197)
353function LoadPickups()
354{
355local q = QuerySQL( db, "SELECT * FROM Pickups" ), i = 0;
356while( GetSQLColumnData( q, 0 ) )
357{
358local
359ID = GetSQLColumnData( q, 0 ),
360PX = GetSQLColumnData( q, 2 ),
361PY = GetSQLColumnData( q, 3 ),
362PZ = GetSQLColumnData( q, 4 );
363
364CreatePickup(ID.tointeger(), Vector(PX.tofloat(), PY.tofloat(), PZ.tofloat()));
365GetSQLNextRow( q );
366i++;
367}
368print( "Pickups Cargados - " + i );
369}
370
371function TagEmpregos( player )
372{
373if ( ( status[ player.ID ].Policia < 1 ) && ( status[ player.ID ].Emprego < 1 ) ) return "Desempregado"
374else if ( status[ player.ID ].Policia >= 1 ) return "Policial"
375else if( status[ player.ID ].Emprego == 1 ) return "Traficante";
376else if( status[ player.ID ].Emprego == 2 ) return "Mecanico";
377else if( status[ player.ID ].Emprego == 3 ) return "Medico";
378else if( status[ player.ID ].Emprego == 4 ) return "Seguranca De Banco";
379else if( status[ player.ID ].Emprego == 5 ) return "Sorveteiro";
380else if( status[ player.ID ].Emprego == 6 ) return "Investigador";
381else if( status[ player.ID ].Emprego == 7 ) return "Distribuidor De Drogas";
382else if( status[ player.ID ].Emprego == 8 ) return "Caminhoneiro";
383else if( status[ player.ID ].Emprego == 9 ) return "Pizza-Boy";
384else if( status[ player.ID ].Emprego == 10 ) return "Frentista";
385else if( status[ player.ID ].Emprego == 11 ) return "Lixeiro";
386//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!
387}
388
389function ForceSpawn(player)
390{
391 // Forced spawning
392 //player.Spawn();
393 // Forced character selection
394 //player.Select();
395}
396
397function Entrega2( player )
398{
399player = FindPlayer( player );
400if ( player )
401{
402if ( player.Vehicle && player.Vehicle.Model == 228 )
403{
404player.Eject();
405AntiBugSphere[ player.ID ] = 5;
406//player.Frozen = false;
407Carregado[ player.ID ] = false;
408I_MSG("You've Delivered Drugs and reward: 50k!!",player);
409IncCash( player, 56000 );
410if ( player.WantedLevel < 6 ) player.WantedLevel ++;
411Message("[#FF0000][[#7CFC00]Trabajo[#FF0000]] [#40E0D0]Drug distributor " + player.Name + " Complete a drug delivery!!");
412EchoMessage("9[7Trabajo9] 10Drug distributor " + player.Name + " Complete a drug delivery!!");
413}
414}
415}
416
417function Temporizador()
418{
419for( local i = 0, player; i < GetMaxPlayers(); i++ )
420{
421player = FindPlayer( i );
422if ( player )
423{
424if ( AntiBugSphere[ player.ID ] >= 1 ) AntiBugSphere[ player.ID ] --;
425}
426}
427}
428
429function Entrega( player )
430{
431player = FindPlayer( player );
432if ( player )
433{
434if ( player.Vehicle && player.Vehicle.Model == 228 )
435{
436AntiBugSphere[ player.ID ] = 5;
437player.RestoreCamera();
438Carregado[ player.ID ] = true;
439player.Frozen = false;
440CreateMarker(player.UniqueWorld, Vector( 79.8685, 1080.55, 16.2623 ), 1, RGB(000 ,000 ,000), 0 );
441//I_MSG("Your Truck Is Now Loaded With Drugs!!",player);
442}
443}
444}
445
446function CarregarCasas()
447{
448local i = 0, id, nome, preco, dono, compart, x, y, z;
449local q = QuerySQL( db, "SELECT * FROM Casas" );
450while ( GetSQLColumnData( q, 0 ) != null )
451{
452nome = GetSQLColumnData( q, 1 );
453preco = GetSQLColumnData( q, 2 );
454dono = GetSQLColumnData( q, 3 );
455compart = GetSQLColumnData( q, 4 );
456x = GetSQLColumnData( q, 5 );
457y = GetSQLColumnData( q, 6 );
458z = GetSQLColumnData( q, 7 );
459id = CreatePickup( 407, 1, 1, x, y, z, 255, true ).ID;
460Casa[ id ] = PropStats();
461Casa[ id ].ID = GetSQLColumnData( q, 0 );
462Casa[ id ].Nome = nome;
463Casa[ id ].Preco = preco;
464Casa[ id ].Dono = dono;
465Casa[ id ].Compart = compart;
466GetSQLNextRow( q );
467i++;
468}
469FreeSQLQuery( q );
470print( "[Cargado] Casas del servidor - " + i );
471}
472
473function CountProps()
474{
475local c = 0;
476for( local i = 0, pickup; i < GetPickupCount(); i++ )
477{
478pickup = FindPickup( i );
479if ( pickup && pickup.Model == 407 ) c ++;
480}
481return c;
482}
483
484function PropNameExist( nome )
485{
486local result = false;
487for( local i = 0, pickup; i < GetPickupCount(); i++ )
488{
489pickup = FindPickup( i );
490if ( pickup && Casa[ pickup.ID ] != null )
491{
492if ( Casa[ pickup.ID ].Nome == nome ) result = true;
493}
494}
495return result;
496}
497
498function FindProp( id )
499{
500if ( id < 0 ) return false;
501else if ( id > 1000 ) return false;
502else if ( Casa[ id ] == null ) return false;
503else return true;
504}
505
506function CarregarObjetos()
507{
508local i = 0, obj, modelo, world, pos, alpha, rot;
509local q = QuerySQL( db, "SELECT * FROM Objectss" );
510while ( GetSQLColumnData( q, 0 ) != null )
511{
512modelo = GetSQLColumnData( q, 0 );
513world = GetSQLColumnData( q, 1 );
514pos = Vector( GetSQLColumnData( q, 2 ), GetSQLColumnData( q, 3 ), GetSQLColumnData( q, 4 ) );
515alpha = GetSQLColumnData( q, 5 );
516rot = Vector( GetSQLColumnData( q, 6 ), GetSQLColumnData( q, 7 ), GetSQLColumnData( q, 8 ) );
517obj = CreateObject( modelo, world, pos, alpha );
518obj.RotateToEuler( rot, 0 );
519GetSQLNextRow( q );
520i++;
521}
522FreeSQLQuery( q );
523print( "Cargados objetos: "+ CountObjectss() );
524}
525
526function DeathWindow(leftName, reason, rightName)
527{
528 image <- "" + reason + ".png";
529 if (TextInfo[0])
530 {
531 TextInfo[0].Delete();
532 }
533 if(SpriteInfo[0])
534 {
535 SpriteInfo[0].Delete();
536 }
537 if (TextInfo2[0])
538 {
539 TextInfo2[0].Delete();
540 }
541 for (local i=0; i<MaxLines-1; i++)
542 {
543 if(TextLengh[i+1])
544 {
545 TextLengh[i] = TextLengh[i+1];
546 }
547 if (TextInfo[i+1])
548 {
549 TextInfo[i] = TextInfo[i+1];
550 TextInfo[i].SetPosForAll(PosX-TextLengh[i], PosY-(i)*LineGap);
551 }
552
553 if(SpriteInfo[i+1])
554 {
555 SpriteInfo[i] = SpriteInfo[i+1];
556 SpriteInfo[i].SetPosForAll(-230, PosY3-(i)*LineGap);
557 }
558
559 if(TextInfo2[i+1])
560 {
561 TextInfo2[i] = TextInfo2[i+1];
562 TextInfo2[i].SetPosForAll(PosX2, PosY-(i)*LineGap);
563 }
564 }
565
566 MinusPosX <- 0;
567
568 if(leftName.len() == 1)
569 {
570 MinusPosX <- 8;
571 }
572 else
573 {
574 MinusPosX <- leftName.len()*8;
575 }
576
577 TextLengh[MaxLines-1] = MinusPosX;
578 TextInfo[MaxLines-1] = CreateTextdraw(leftName, PosX-MinusPosX, PosY-(MaxLines-1)*LineGap, 0xFFB0B0B0);
579 TextInfo[MaxLines-1].ShowForAll();
580 SpriteInfo[MaxLines-1] = CreateSprite(image, -230, PosY3-(MaxLines-1)*LineGap, 0, 0, 0, 200);
581 SpriteInfo[MaxLines-1].ShowForAll();
582 TextInfo2[MaxLines-1] = CreateTextdraw(rightName, PosX2, PosY-(MaxLines-1)*LineGap, 0xFFB0B0B0);
583 TextInfo2[MaxLines-1].ShowForAll();
584 return 1;
585}
586
587function GetVehicleType( model )
588{
589 // by Force
590 // Returns: Car / Bike / Heli / Plane / Boat / RC
591 switch ( model ) {
592 case 136:
593 case 160:
594 case 176:
595 case 182:
596 case 183:
597 case 184:
598 case 190:
599 case 202:
600 case 203:
601 case 214:
602 case 223:
603 return "Boat";
604 case 155:
605 case 165:
606 case 217:
607 case 218:
608 case 227:
609 return "Heli";
610 case 166:
611 case 178:
612 case 191:
613 case 192:
614 case 193:
615 case 198:
616 return "Bike";
617 case 171:
618 case 194:
619 case 195:
620 case 231:
621 return "RC";
622 case 180:
623 case 181:
624 return "Plane";
625 default:
626 return "Car";
627 }
628}
629
630function ActivateNOS( vehicle )
631{
632
633}
634
635function DeactivateNOS( vehicle )
636{
637
638}
639
640function DecreaseNOS( vehID )
641{
642
643}
644
645function nosLoadSprites()
646{
647
648}
649
650function nosShowBar( player )
651{
652
653}
654
655function nosHideBar( player )
656{
657
658}
659
660function IsInRangeOfPoint( a, range, x, y, z )
661{
662local px = a.Pos.x, py = a.Pos.y, pz = a.Pos.z;
663px -= x, py -= y, pz -= z;
664return ( ( px * px ) + ( py * py ) + ( pz * pz ) ) < ( range * range );
665}
666
667function IsFloat( value )
668{
669if ( typeof value == "float" ) return true;
670try
671{
672if ( value.find( "." ) != null )
673{
674value = value.tofloat();
675return true;
676}
677else return false;
678}
679catch(e) return false;
680}
681
682function MoverPortao( player )
683{
684if ( player.IsSpawned )
685{
686for ( local i = 0; i < Portao.len(); i++ )
687{
688local portao = Portao[i].Objeto;
689if ( IsInRangeOfPoint( player, 10, Portao[i].Pos1.x, Portao[i].Pos1.y, Portao[i].Pos1.z ) )
690{
691if ( Casa[ Portao[i].ID ].Dono == player.Name || Casa[ Portao[i].ID ].Compart == player.Name )
692{
693if ( Portao[i].Trancado == true )
694{
695PlaySound( player.World, 145, player.Pos );
696portao.MoveTo( Portao[i].Pos2, 2800 );
697portao.RotateToEuler( Portao[i].Rot2, 2800 );
698Portao[i].Trancado = false;
699}
700else if ( Portao[i].Trancado == false )
701{
702PlaySound( player.World, 145, player.Pos );
703portao.MoveTo( Portao[i].Pos1, 2800 );
704portao.RotateToEuler( Portao[i].Rot1, 2800 );
705Portao[i].Trancado = true;
706}
707}
708}
709}
710}
711}
712
713function CarregarPortoes()
714{
715local i = 0, obj, id, modelo, pos1, rot1, pos2, rot2;
716local q = QuerySQL( db, "SELECT * FROM Portoes" );
717while ( GetSQLColumnData( q, 0 ) != null )
718{
719id = GetSQLColumnData( q, 0 );
720modelo = GetSQLColumnData( q, 1 );
721pos1 = split( GetSQLColumnData( q, 2 ), " " );
722rot1 = split( GetSQLColumnData( q, 3 ), " " );
723pos2 = split( GetSQLColumnData( q, 4 ), " " );
724rot2 = split( GetSQLColumnData( q, 5 ), " " );
725obj = CreateObject( modelo, 1, Vector( pos1[0].tofloat(), pos1[1].tofloat(), pos1[2].tofloat() ), 255 );
726obj.RotateToEuler( Vector( rot1[0].tofloat(), rot1[1].tofloat(), rot1[2].tofloat() ), 0 );
727Portao.push({
728Objeto = obj,
729ID = id,
730Pos1 = Vector( pos1[0].tofloat(), pos1[1].tofloat(), pos1[2].tofloat() ),
731Rot1 = Vector( rot1[0].tofloat(), rot1[1].tofloat(), rot1[2].tofloat() ),
732Pos2 = Vector( pos2[0].tofloat(), pos2[1].tofloat(), pos2[2].tofloat() ),
733Rot2 = Vector( rot2[0].tofloat(), rot2[1].tofloat(), rot2[2].tofloat() ),
734Trancado = true
735});
736GetSQLNextRow( q );
737i++;
738}
739FreeSQLQuery( q );
740print( "[Cargados] Portones del servidor - " + i );
741}
742
743function rotateRight(val, sbits)
744{
745 return (val >> sbits) | (val << (0x20 - sbits));
746}
747
748function topkiller()
749{
750local
751query = "SELECT Nome, Matou FROM Contas ORDER BY Matou DESC LIMIT 5", //Top 5
752q,
753Nome1, Nome2, Nome3, Nome4, Nome5,
754Matou1, Matou2, Matou3, Matou4, Matou5, i = 1;
755q = QuerySQL( db, query );
756while( GetSQLColumnData( q, 0 ) )
757{
758switch(i)
759{
760case 1:
761Nome1 = GetSQLColumnData( q, 0 );
762Matou1 = GetSQLColumnData( q, 1 );
763break;
764case 2:
765Nome2 = GetSQLColumnData( q, 0 );
766Matou2 = GetSQLColumnData( q, 1 );
767break;
768case 3:
769Nome3 = GetSQLColumnData( q, 0 );
770Matou3 = GetSQLColumnData( q, 1 );
771break;
772case 4:
773Nome4 = GetSQLColumnData( q, 0 );
774Matou4 = GetSQLColumnData( q, 1 );
775break;
776case 5:
777Nome5 = GetSQLColumnData( q, 0 );
778Matou5 = GetSQLColumnData( q, 1 );
779break;
780}
781GetSQLNextRow( q );
782i++;
783}
784FreeSQLQuery(q);
785MSG(" Top 5 Mejores Asesinos: " + Nome1 + " Mato a: " + Matou1 + ", " + Nome2 + " Mato a: " + Matou2 + ", " + Nome3 + " Mato a: " + Matou3 + ", " + Nome4 + " Mato a: " + Matou4 + ", " + Nome5 + " Mato a: " + Matou5 + "");
786}
787
788function PuxarModelo( modelo )
789{
790if ( modelo >= 6400 ) return VeiculosMods( modelo );
791else return GetVehicleNameFromModel( modelo );
792}
793
794function VeiculosMods( modelo )
795{
796if ( modelo == 6400 ) return "My Vehiculo MOD 1";
797else if ( modelo == 6401 ) return "Mi Vehiculo MOD 2";
798else if ( modelo == 6402 ) return "Mi Vehiculo MOD 3";
799else return "Desconocido";
800}
801
802function DecFuel()
803{
804for( local i = 0, player; i < GetMaxPlayers(); i++ )
805{
806player = FindPlayer( i );
807if ( player )
808{
809local vehicle = player.Vehicle;
810if ( vehicle && player.VehicleSlot == 0 )
811{
812if ( Fuel[ vehicle.ID ] >= 1 )
813{
814Fuel[ vehicle.ID ] --;
815Announce( "~b~Fuel: ~w~" + Fuel[ vehicle.ID ], player, 4 );
816if ( Fuel[ vehicle.ID ] == 0 )
817{
818vehicle.Speed = Vector( 0, 0, 0 );
819if ( vehicle.GetHandlingData( 13 ) != 0 ) vehicle.SetHandlingData( 13, 0 );
820if ( vehicle.GetHandlingData( 14 ) != 0 ) vehicle.SetHandlingData( 14, 0 );
821}
822}
823}
824}
825}
826}
827
828function CheckFuel( player, vehicle, door )
829{
830Announce( "~b~FUEL: ~w~" + Fuel[ vehicle.ID ], player, 4 );
831if ( Fuel[ vehicle.ID ] == 0 && door == 0 )
832{
833vehicle.Speed = Vector( 0, 0, 0 );
834if ( vehicle.GetHandlingData( 13 ) != 0 ) vehicle.SetHandlingData( 13, 0 );
835if ( vehicle.GetHandlingData( 14 ) != 0 ) vehicle.SetHandlingData( 14, 0 );
836}
837}
838
839function GetDistance(pos1, pos2)
840{
841 return sqrt(pow(pos1.x - pos2.x, 2) + pow(pos1.y - pos2.y, 2) + pow(pos1.z - pos2.z, 2));
842}
843
844function Arrest(player,target)
845{
846 if (!target) {
847 E_MSG("Jugador desconocido",player)
848 return false;
849 }
850 if (target.WantedLevel <1) {
851 I_MSG("This player is not wanted",player)
852 return false;
853 }
854 if (target.WantedLevel > 0) {
855 local distance = GetDistance(player.Pos,target.Pos)
856 if ( distance < 5 ) {
857 I_MSG("[#ffffff]You have Arrested "+target+" , you won $5000",player)
858 player.Cash += 5000;
859 target.Pos = Vector(386.59, -502.732, 9.39561)
860 target.WantedLevel = 0
861 Message("[#000099]Police[#ffffff] "+player+ " [#00ffff]has arrested[#ff0000] "+target)
862 }
863 }
864}
865
866function arresttime(p)
867{
868local player = FindPlayer(p);
869if (plr)
870plr.Pos = Vector(394.654, -495.409, 10.8694);
871MessagePlayer( RED+"**You have been released from jail",plr );
872}
873
874function Velocimetro()
875{
876if ( GetPlayers() >= 1 )
877{
878 for ( local i = 0; i < GetMaxPlayers(); i++ )
879 {
880 local player = FindPlayer( i );
881 if ( player )
882 {
883 if ( player.IsSpawned && player.Vehicle )
884 {
885 local vehicle = player.Vehicle;
886 local Speed = sqrt(vehicle.Speed.x*vehicle.Speed.x + vehicle.Speed.y * vehicle.Speed.y + vehicle.Speed.z * vehicle.Speed.z) * 50 * 3.6;
887 local output = round(Speed, 0);
888 Announce("\x10 \x10 \x10 \x20 \x20 \x20 \x20 \x20 \x20 \x20 \x20 ~w~Kph: ~o~" + output, player, 1 );
889}
890}
891}
892}
893}
894
895function round(value, precision) {
896 local factor = pow(10.0, precision);
897 return floor(value * factor + 0.5) / factor;
898}
899/*
900
901function onKeyDown(player,key)
902{
903if ( key == L )
904{
905I_MSG("[#FF9933]Ahorita no hay un evento de esquivar creado.",player);
906}
907else if ( key == P )
908{
909MoverPortao( player );
910}
911else if ( key == I )
912{
913I_MSG("[#FF9933]Ahorita no hay un evento de agilidad creado.",player);
914}
915}
916*/
917function AddSkin( player, skin )
918{
919if ( ( skin ) && IsNum( skin ) ) skin = skin.tointeger();
920else if ( skin ) skin = GetSkinID( skin );
921QuerySQL( db, "DELETE FROM Skins WHERE Name='" + player.Name + "'" );
922QuerySQL( db, "INSERT INTO Skins ( Nome, Skin ) VALUES ( '" + player.Name + "', '" + skin + "')" );
923}
924
925function DelSkin( player )
926{
927QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
928}
929
930function skin( player )
931{
932local skin = GetSQLColumnData( QuerySQL( db, "SELECT Skin FROM Skins WHERE Nome='" + player.Name + "'" ), 0 );
933if ( skin ) return skin;
934else return 0;
935}
936
937function LoadSkin( player )
938{
939if ( skin(player) == 0 ) player.Skin = 0 ;
940else if ( skin(player) == 1 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
941else if ( skin(player) == 2 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
942else if ( skin(player) == 3 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
943else if ( skin(player) == 4 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
944else if ( skin(player) == 5 ) player.Skin = 5 ;
945else if ( skin(player) == 6 ) player.Skin = 6 ;
946else if ( skin(player) == 7 ) player.Skin = 7 ;
947else if ( skin(player) == 8 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
948else if ( skin(player) == 9 ) player.Skin = 9 ;
949else if ( skin(player) == 10 ) player.Skin = 10 ;
950else if ( skin(player) == 11 ) player.Skin = 11 ;
951else if ( skin(player) == 12 ) player.Skin = 12 ;
952else if ( skin(player) == 13 ) player.Skin = 13 ;
953else if ( skin(player) == 14 ) player.Skin = 14 ;
954else if ( skin(player) == 15 ) player.Skin = 15 ;
955else if ( skin(player) == 16 ) player.Skin = 16 ;
956else if ( skin(player) == 17 ) player.Skin = 17 ;
957else if ( skin(player) == 18 ) player.Skin = 18 ;
958else if ( skin(player) == 19 ) player.Skin = 19 ;
959else if ( skin(player) == 20 ) player.Skin = 20 ;
960else if ( skin(player) == 21 ) player.Skin = 21 ;
961else if ( skin(player) == 22 ) player.Skin = 22 ;
962else if ( skin(player) == 23 ) player.Skin = 23 ;
963else if ( skin(player) == 24 ) player.Skin = 24 ;
964else if ( skin(player) == 25 ) player.Skin = 25 ;
965else if ( skin(player) == 26 ) player.Skin = 26 ;
966else if ( skin(player) == 27 ) player.Skin = 27 ;
967else if ( skin(player) == 28 ) player.Skin = 28 ;
968else if ( skin(player) == 29 ) player.Skin = 29 ;
969else if ( skin(player) == 30 ) player.Skin = 30 ;
970else if ( skin(player) == 31 ) player.Skin = 31 ;
971else if ( skin(player) == 32 ) player.Skin = 32 ;
972else if ( skin(player) == 33 ) player.Skin = 33 ;
973else if ( skin(player) == 34 ) player.Skin = 34 ;
974else if ( skin(player) == 35 ) player.Skin = 35 ;
975else if ( skin(player) == 36 ) player.Skin = 36 ;
976else if ( skin(player) == 37 ) player.Skin = 37 ;
977else if ( skin(player) == 38 ) player.Skin = 38 ;
978else if ( skin(player) == 39 ) player.Skin = 39 ;
979else if ( skin(player) == 40 ) player.Skin = 40 ;
980else if ( skin(player) == 41 ) player.Skin = 41 ;
981else if ( skin(player) == 42 ) player.Skin = 42 ;
982else if ( skin(player) == 43 ) player.Skin = 43 ;
983else if ( skin(player) == 44 ) player.Skin = 44 ;
984else if ( skin(player) == 45 ) player.Skin = 45 ;
985else if ( skin(player) == 46 ) player.Skin = 46 ;
986else if ( skin(player) == 47 ) player.Skin = 47 ;
987else if ( skin(player) == 48 ) player.Skin = 48 ;
988else if ( skin(player) == 49 ) player.Skin = 49 ;
989else if ( skin(player) == 50 ) player.Skin = 50 ;
990else if ( skin(player) == 51 ) player.Skin = 51 ;
991else if ( skin(player) == 52 ) player.Skin = 52 ;
992else if ( skin(player) == 53 ) player.Skin = 53 ;
993else if ( skin(player) == 54 ) player.Skin = 54 ;
994else if ( skin(player) == 55 ) player.Skin = 55 ;
995else if ( skin(player) == 56 ) player.Skin = 56 ;
996else if ( skin(player) == 57 ) player.Skin = 57 ;
997else if ( skin(player) == 58 ) player.Skin = 58 ;
998else if ( skin(player) == 59 ) player.Skin = 59 ;
999else if ( skin(player) == 60 ) player.Skin = 60 ;
1000else if ( skin(player) == 61 ) player.Skin = 61 ;
1001else if ( skin(player) == 62 ) player.Skin = 62 ;
1002else if ( skin(player) == 63 ) player.Skin = 63 ;
1003else if ( skin(player) == 64 ) player.Skin = 64 ;
1004else if ( skin(player) == 65 ) player.Skin = 65 ;
1005else if ( skin(player) == 66 ) player.Skin = 66 ;
1006else if ( skin(player) == 67 ) player.Skin = 67 ;
1007else if ( skin(player) == 68 ) player.Skin = 68 ;
1008else if ( skin(player) == 69 ) player.Skin = 69 ;
1009else if ( skin(player) == 70 ) player.Skin = 70 ;
1010else if ( skin(player) == 71 ) player.Skin = 71 ;
1011else if ( skin(player) == 72 ) player.Skin = 72 ;
1012else if ( skin(player) == 73 ) player.Skin = 73 ;
1013else if ( skin(player) == 74 ) player.Skin = 74 ;
1014else if ( skin(player) == 75 ) player.Skin = 75 ;
1015else if ( skin(player) == 76 ) player.Skin = 76 ;
1016else if ( skin(player) == 77 ) player.Skin = 77 ;
1017else if ( skin(player) == 78 ) player.Skin = 78 ;
1018else if ( skin(player) == 79 ) player.Skin = 79 ;
1019else if ( skin(player) == 80 ) player.Skin = 80 ;
1020else if ( skin(player) == 81 ) player.Skin = 81 ;
1021else if ( skin(player) == 82 ) player.Skin = 82 ;
1022else if ( skin(player) == 83 ) player.Skin = 83 ;
1023else if ( skin(player) == 84 ) player.Skin = 84 ;
1024else if ( skin(player) == 85 ) player.Skin = 85 ;
1025else if ( skin(player) == 86 ) player.Skin = 86 ;
1026else if ( skin(player) == 87 ) player.Skin = 87 ;
1027else if ( skin(player) == 88 ) player.Skin = 88 ;
1028else if ( skin(player) == 89 ) player.Skin = 89 ;
1029else if ( skin(player) == 90 ) player.Skin = 90 ;
1030else if ( skin(player) == 91 ) player.Skin = 91 ;
1031else if ( skin(player) == 92 ) player.Skin = 92 ;
1032else if ( skin(player) == 93 ) player.Skin = 93 ;
1033else if ( skin(player) == 94 ) player.Skin = 94 ;
1034else if ( skin(player) == 95 ) player.Skin = 95 ;
1035else if ( skin(player) == 96 ) player.Skin = 96 ;
1036else if ( skin(player) == 97 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1037else if ( skin(player) == 98 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1038else if ( skin(player) == 99 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1039else if ( skin(player) == 100 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1040else if ( skin(player) == 101 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1041else if ( skin(player) == 102 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1042else if ( skin(player) == 103 ) player.Skin = 103 ;
1043else if ( skin(player) == 104 ) player.Skin = 104 ;
1044else if ( skin(player) == 105 ) player.Skin = 105 ;
1045else if ( skin(player) == 106 ) player.Skin = 106 ;
1046else if ( skin(player) == 107 ) player.Skin = 107 ;
1047else if ( skin(player) == 108 ) player.Skin = 108 ;
1048else if ( skin(player) == 109 ) player.Skin = 109 ;
1049else if ( skin(player) == 110 ) player.Skin = 110 ;
1050else if ( skin(player) == 111 ) player.Skin = 111 ;
1051else if ( skin(player) == 112 ) player.Skin = 112 ;
1052else if ( skin(player) == 113 ) player.Skin = 113 ;
1053else if ( skin(player) == 114 ) player.Skin = 114 ;
1054else if ( skin(player) == 115 ) player.Skin = 115 ;
1055else if ( skin(player) == 116 ) player.Skin = 116 ;
1056else if ( skin(player) == 117 ) player.Skin = 117 ;
1057else if ( skin(player) == 118 ) player.Skin = 118 ;
1058else if ( skin(player) == 119 ) player.Skin = 119 ;
1059else if ( skin(player) == 120 ) player.Skin = 120 ;
1060else if ( skin(player) == 121 ) player.Skin = 121 ;
1061else if ( skin(player) == 122 ) player.Skin = 122 ;
1062else if ( skin(player) == 123 ) player.Skin = 123 ;
1063else if ( skin(player) == 124 ) player.Skin = 124 ;
1064else if ( skin(player) == 125 ) player.Skin = 125 ;
1065else if ( skin(player) == 126 ) player.Skin = 126 ;
1066else if ( skin(player) == 127 ) player.Skin = 127 ;
1067else if ( skin(player) == 128 ) player.Skin = 128 ;
1068else if ( skin(player) == 129 ) player.Skin = 129 ;
1069else if ( skin(player) == 130 ) player.Skin = 130 ;
1070else if ( skin(player) == 131 ) player.Skin = 131 ;
1071else if ( skin(player) == 132 ) player.Skin = 132 ;
1072else if ( skin(player) == 133 ) player.Skin = 133 ;
1073else if ( skin(player) == 134 ) player.Skin = 134 ;
1074else if ( skin(player) == 135 ) player.Skin = 135 ;
1075else if ( skin(player) == 136 ) player.Skin = 136 ;
1076else if ( skin(player) == 137 ) player.Skin = 137 ;
1077else if ( skin(player) == 138 ) player.Skin = 138 ;
1078else if ( skin(player) == 139 ) player.Skin = 139 ;
1079else if ( skin(player) == 140 ) player.Skin = 140 ;
1080else if ( skin(player) == 141 ) player.Skin = 141 ;
1081else if ( skin(player) == 142 ) player.Skin = 142 ;
1082else if ( skin(player) == 143 ) player.Skin = 143 ;
1083else if ( skin(player) == 144 ) player.Skin = 144 ;
1084else if ( skin(player) == 145 ) player.Skin = 145 ;
1085else if ( skin(player) == 146 ) player.Skin = 146 ;
1086else if ( skin(player) == 147 ) player.Skin = 147 ;
1087else if ( skin(player) == 148 ) player.Skin = 148 ;
1088else if ( skin(player) == 149 ) player.Skin = 149 ;
1089else if ( skin(player) == 150 ) player.Skin = 150 ;
1090else if ( skin(player) == 151 ) player.Skin = 151 ;
1091else if ( skin(player) == 152 ) player.Skin = 152 ;
1092else if ( skin(player) == 153 ) player.Skin = 153 ;
1093else if ( skin(player) == 154 ) player.Skin = 154 ;
1094else if ( skin(player) == 155 ) player.Skin = 155 ;
1095else if ( skin(player) == 156 ) player.Skin = 156 ;
1096else if ( skin(player) == 157 ) player.Skin = 157 ;
1097else if ( skin(player) == 158 ) player.Skin = 158 ;
1098else if ( skin(player) == 159 ) player.Skin = 159 ;
1099else if ( skin(player) == 160 ) player.Skin = 160 ;
1100else if ( skin(player) == 161 ) player.Skin = 161 ;
1101else if ( skin(player) == 162 ) player.Skin = 162 ;
1102else if ( skin(player) == 163 ) player.Skin = 163 ;
1103else if ( skin(player) == 164 ) player.Skin = 164 ;
1104else if ( skin(player) == 165 ) player.Skin = 165 ;
1105else if ( skin(player) == 166 ) player.Skin = 166 ;
1106else if ( skin(player) == 167 ) player.Skin = 167 ;
1107else if ( skin(player) == 168 ) player.Skin = 168 ;
1108else if ( skin(player) == 169 ) player.Skin = 169 ;
1109else if ( skin(player) == 170 ) player.Skin = 170 ;
1110else if ( skin(player) == 171 ) player.Skin = 171 ;
1111else if ( skin(player) == 172 ) player.Skin = 172 ;
1112else if ( skin(player) == 173 ) player.Skin = 173 ;
1113else if ( skin(player) == 174 ) player.Skin = 174 ;
1114else if ( skin(player) == 175 ) player.Skin = 175 ;
1115else if ( skin(player) == 176 ) player.Skin = 176 ;
1116else if ( skin(player) == 177 ) player.Skin = 177 ;
1117else if ( skin(player) == 178 ) player.Skin = 178 ;
1118else if ( skin(player) == 179 ) player.Skin = 179 ;
1119else if ( skin(player) == 180 ) player.Skin = 180 ;
1120else if ( skin(player) == 181 ) player.Skin = 181 ;
1121else if ( skin(player) == 182 ) player.Skin = 182 ;
1122else if ( skin(player) == 183 ) player.Skin = 183 ;
1123else if ( skin(player) == 184 ) player.Skin = 184 ;
1124else if ( skin(player) == 185 ) player.Skin = 185 ;
1125else if ( skin(player) == 186 ) player.Skin = 186 ;
1126else if ( skin(player) == 187 ) player.Skin = 187 ;
1127else if ( skin(player) == 188 ) player.Skin = 188 ;
1128else if ( skin(player) == 189 ) player.Skin = 189 ;
1129else if ( skin(player) == 190 ) player.Skin = 190 ;
1130else if ( skin(player) == 191 ) player.Skin = 191 ;
1131else if ( skin(player) == 192 ) player.Skin = 192 ;
1132else if ( skin(player) == 193 ) player.Skin = 193 ;
1133else if ( skin(player) == 194 ) player.Skin = 194 ;
1134else if ( skin(player) == 195 ) player.Skin = 195 ;
1135else if ( skin(player) == 196 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1136else if ( skin(player) == 197 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1137else if ( skin(player) == 198 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1138else if ( skin(player) == 199 ) QuerySQL( db, "DELETE FROM Skins WHERE Nome='" + player.Name + "'" );
1139else if ( skin(player) == 200 ) player.Skin = 200 ;
1140else if ( skin(player) == 201 ) player.Skin = 201 ;
1141else if ( skin(player) == 202 ) player.Skin = 202 ;
1142else if ( skin(player) == 203 ) player.Skin = 203 ;
1143else if ( skin(player) == 204 ) player.Skin = 204 ;
1144else if ( skin(player) == 205 ) player.Skin = 205 ;
1145else if ( skin(player) == 206 ) player.Skin = 206 ;
1146else if ( skin(player) == 207 ) player.Skin = 207 ;
1147else if ( skin(player) == 208 ) player.Skin = 208 ;
1148else if ( skin(player) == 209 ) player.Skin = 209 ;
1149else if ( skin(player) == 210 ) player.Skin = 210 ;
1150else if ( skin(player) == 211 ) player.Skin = 211 ;
1151else if ( skin(player) == 212 ) player.Skin = 212 ;
1152else if ( skin(player) == 213 ) player.Skin = 213 ;
1153else if ( skin(player) == 214 ) player.Skin = 214 ;
1154else if ( skin(player) == 215 ) player.Skin = 215 ;
1155else if ( skin(player) == 216 ) player.Skin = 216 ;
1156else if ( skin(player) == 217 ) player.Skin = 217 ;
1157else if ( skin(player) == 218 ) player.Skin = 218 ;
1158}
1159
1160function CountObjectss()
1161{
1162try
1163 {
1164 local a = 0, q = QuerySQL( db, "SELECT * FROM Objectss" );
1165 while ( GetSQLColumnData( q, 0 ) )
1166 {
1167 a ++;
1168 GetSQLNextRow( q );
1169 }
1170 return a;
1171 FreeSQLQuery( q );
1172 }
1173 catch(e) print( "[Error] CountObjects - " + e );
1174}
1175
1176function RespawnVehicles( rtime = 0 ){
1177//Loop over all the vehicles.
1178for( local veh, i = 1; i <= 1000; i++ ){
1179veh = FindVehicle(i);
1180if( !veh ) continue;
1181if( rtime == 0 ) veh.Respawn();
1182else veh.RespawnTimer = rtime; //Time in ms.
1183}
1184}
1185
1186function onPickupPickedUp( player, pickup )
1187{
1188 if ( !player.Vehicle && pickup.Model == 407 )
1189 {
1190 if ( Casa[ pickup.ID ] != null )
1191 {
1192 pickup.Timer = 3000;
1193 MessagePlayer( "[#EEC900]Name of Prop: [#00FFFF]" + Casa[ pickup.ID ].Nome + "[#EEC900] - ID: [#00FFFF]" + pickup.ID + "[#EEC900] - Owner: [#00FFFF]" + Casa[ pickup.ID ].Dono + "[#EEC900].", player );
1194 MessagePlayer( "[#EEC900]Price: [#00FFFF]$" + Casa[ pickup.ID ].Preco + "[#EEC900] - Shared with: [#00FFFF]" + Casa[ pickup.ID ].Compart + "[#EEC900].", player );
1195 }
1196 }
1197 if ( pickup.Model == 345 )
1198 {
1199 MSG( player.Name + " found the surprise box! Reward: $1000000!" );
1200 IncCash( player, 10000000 );
1201 pickup.Remove();
1202 BoxActive = false;
1203 }
1204if ( pickup.Model == 407 )
1205{
1206if ( Casa[ pickup.ID ] != null )
1207{
1208pickup.Timer = 3000;
1209
1210}
1211}
1212else if ( pickup.Model == 408 )
1213{
1214local robbedcash = random( 2000, 4000);
1215Message("[#ff0000]"+ player.Name +" [#00ffff]robbed [#cccccc]$" + robbedcash + " [#cc00cc]on[#00cc00] "+ GetDistrictName( player.Pos.x, player.Pos.y ) +"");
1216IncCash( player, robbedcash );
1217player.WantedLevel++;
1218pickup.RespawnTime = 15000;
1219}
1220else if ( pickup.Model == 356 )
1221{
1222local vehicle = player.Vehicle;
1223if ( !vehicle ) I_MSG( "You need to be in your vehicle.", player );
1224else if ( Fuel[ vehicle.ID ] >= 51 ) I_MSG( "The vehicle does not need gas.", player );
1225else if ( player.Cash <= 2000 ) E_MSG( "You need 10,000.", player );
1226else
1227{
1228Fuel[ vehicle.ID ] = 100;
1229player.Cash -= 10000;
1230I_MSG( "Recharged petrol!", player );
1231if ( vehicle.GetHandlingData( 13 ) == 0 ) vehicle.ResetHandlingData( 13 );
1232if ( vehicle.GetHandlingData( 14 ) == 0 ) vehicle.ResetHandlingData( 14 );
1233Announce("\x10 \x10 \x10 \x20 \x20 \x20 \x20 \x20 \x20 \x20 \x20 ~w~Gasolina: ~w~" + Fuel[ vehicle.ID ], player, 5 );
1234pickup.RespawnTime = 10000;
1235}
1236}
1237else if ( pickup.Model == 406 )
1238{
1239player.Pos = Vector( -713.673 1298.67 11.7673 );
1240I_MSG( "Para salir interior use /casa <ID>", player );
1241}
1242else if ( pickup.Model == 409 )
1243{
1244I_MSG("Now you work as a police officer." player );
1245player.Skin = ( 1 );
1246}
1247}
1248
1249function random(start, finish)
1250{
1251local t = ((rand() % (finish - start)) + start);
1252return t;
1253}
1254
1255function createpickupss()
1256{
1257CreatePickup(408, Vector( 207.214, -470.93, 11.0699 )); // bunchoftools
1258CreatePickup(408, Vector( 467.072, -53.9059, 11.4837 )); // malibu
1259CreatePickup(408, Vector( 418.765, 91.317, 11.2808 )); // pizzavc
1260CreatePickup(408, Vector( 491.143, 701.207, 12.1033 )); // hospitalvc
1261CreatePickup(408, Vector( 450.729, 782.371, 12.954 )); // storevc
1262CreatePickup(408, Vector( 472.171, 1009.33, 19.1462 )); // tarbrush1
1263CreatePickup(408, Vector( 471.983, 1014.02, 20.0473 )); // tarbrush2
1264CreatePickup(408, Vector( 421.842, 1026.69, 25.2993 )); // gash
1265CreatePickup(408, Vector( 364.444, 1052.46, 19.213 )); // ammunationmall
1266CreatePickup(408, Vector( 363.719, 1074.71, 19.0613 )); // tooledup
1267CreatePickup(408, Vector( 351.45, 1111.41, 25.3879 )); // musicshop
1268CreatePickup(408, Vector( 469.438, 1206.76, 19.0103 )); // jewelry
1269CreatePickup(408, Vector( 2.39992, 956.954, 11.1667 )); // film
1270CreatePickup(408, Vector( -680.664, 1204.1, 11.1093 )); // ammudowntown
1271CreatePickup(408, Vector( -822.855, 1138.59, 12.4111 )); // hospitaldt
1272CreatePickup(408, Vector( -853.756, 850.456, 11.3846 )); // jewelrydt
1273CreatePickup(408, Vector( -905.961, 799.732, 11.4661 )); // pizzadt
1274CreatePickup(408, Vector( -830.144, 742.221, 11.2885 )); // medicaldt
1275CreatePickup(408, Vector( -594.15, 643.695, 11.6765 )); // bikers
1276CreatePickup(408, Vector( -846.475, -71.8574, 11.5403 )); // medicallh
1277CreatePickup(408, Vector( -1079.9, -275.156, 12.0882 )); // printworks
1278CreatePickup(408, Vector( -1038.02, 80.8385, 11.6263 )); // pizzalh
1279CreatePickup(408, Vector( -997.021, 186.33, 12.434 )); // kaufman
1280CreatePickup(408, Vector( -887.722, -474.079, 13.1115 )); // hospitallh
1281CreatePickup(408, Vector( -867.464, -584.271, 11.2155 )); // cherrypopper
1282CreatePickup(408, Vector( -855.472, -631.404, 11.3756 )); // donuts
1283CreatePickup(408, Vector( -1166.79, -620.55, 11.8279 )); // cubaan
1284CreatePickup(408, Vector( -1031.45, -850.113, 13.5224 )); // sunshine
1285CreatePickup(408, Vector( -665.544, -1484.63, 13.8016 )); // boatyard
1286CreatePickup(408, Vector( -112.599, -975.639, 10.4634 )); // hospitalvc
1287CreatePickup(408, Vector( -63.8908, -1485.23, 10.505 )); // ammuvc
1288CreatePickup(408, Vector( 90.5438, -1454.35, 10.5655 )); // poleposition
1289CreatePickup(356, Vector( 59.9425, -1071.8, 10.4633 ));
1290CreatePickup(356, Vector( 59.9448, -1078.36, 10.4633 ));
1291CreatePickup(409, Vector( 404.011, -490.092, 12.3432 ));
1292CreatePickup(408, Vector( -714.307, -1265.8, 11.0715 ));
1293}
1294
1295function random( min, max )
1296{
1297 if ( min < max )
1298 return rand() % (max - min + 1) + min.tointeger();
1299 else if ( min > max )
1300 return rand() % (min - max + 1) + max.tointeger();
1301 else if ( min == max )
1302 return min.tointeger();
1303}
1304
1305function MSG1()
1306{
1307MSG("Need fuel? .Go on washington's beach fuel station");
1308}
1309
1310function MSG2()
1311{
1312MSG("You can work as drug distributor to earn money.");
1313}
1314
1315function MSG3()
1316{
1317MSG("Want to race? Use /race.");
1318}
1319
1320function MSG4()
1321{
1322MSG("Want duel? Use /duel.");
1323}
1324
1325function MSG5()
1326{
1327MSG("Server version: 1.3.");
1328}
1329
1330function MSG6()
1331{
1332MSG("Something illegal? /report.");
1333}
1334
1335function MSG7()
1336{
1337MSG("Use /cmds to learn faster the commands.");
1338}
1339
1340function GetTok(string, separator, n, ...)
1341{
1342 local m = vargv.len() > 0 ? vargv[0] : n,
1343 tokenized = split(string, separator),
1344 text = "";
1345
1346 if (n > tokenized.len() || n < 1) return null;
1347 for (; n <= m; n++)
1348 {
1349 text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
1350 }
1351 return text;
1352}
1353
1354function NumTok(string, separator)
1355{
1356 local tokenized = split(string, separator);
1357 return tokenized.len();
1358}
1359
1360function Distance(x3, y6, x3, y6)
1361{
1362local dist = sqrt(((x2 - x1)*(x2 - x1)) + ((y2 - y1)*(y2 - y1)));
1363return dist;
1364}
1365
1366function GetPlayer( plr )
1367{
1368if ( plr )
1369{
1370if ( IsNum( plr ) )
1371{
1372plr = FindPlayer( plr.tointeger() );
1373if ( plr ) return plr;
1374else return false;
1375}
1376else
1377{
1378plr = FindPlayer( plr );
1379if ( plr ) return plr;
1380else return false;
1381}
1382}
1383else return false;
1384}
1385
1386function GetFullTime()
1387{
1388local t = date();
1389return ::format(@"%.2d/%.2d/%d - %.2d:%.2d:%.2d", t.day, t.month, t.year, t.hour, t.min, t.sec);
1390}
1391
1392function CriarTabelas()
1393{
1394QuerySQL( 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 )" );
1395QuerySQL( db, "CREATE TABLE IF NOT EXISTS Bans ( Nome TEXT, UID TEXT, Admin TEXT, Motivo TEXT, Data TEXT )" );
1396QuerySQL( db, "CREATE TABLE IF NOT EXISTS Locs ( Nome TEXT, Pos TEXT, Criador TEXT, Data TEXT )" );
1397QuerySQL( db, "CREATE TABLE IF NOT EXISTS SpawnWep ( Nome TEXT, Wep1 NUMERIC, Wep2 NUMERIC, Wep3 NUMERIC, Wep4 NUMERIC )" );
1398QuerySQL( 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 )" );
1399QuerySQL( db, "CREATE TABLE IF NOT EXISTS Skins ( Nome TEXT, Skin NUMERIC )" );
1400QuerySQL( db, "CREATE TABLE IF NOT EXISTS Portoes ( CasaID NUMERIC, Model NUMERIC, Pos1 TEXT, Rot1 TEXT, Pos2 TEXT, Rot2 TEXT )" );
1401QuerySQL( db, "CREATE TABLE IF NOT EXISTS Objectss ( Model NUMERIC, World NUMERIC, PX FLOAT, PY FLOAT, PZ FLOAT, Alpha NUMERIC, RX FLOAT, RT FLOAT, RZ FLOAT, Creator TEXT )" );
1402QuerySQL( db, "CREATE TABLE IF NOT EXISTS Casas ( ID NUMERIC, Nome TEXT, Preco NUMERIC, Dono TEXT, Compart TEXT, PX FLOAT, PY FLOAT, PZ FLOAT )" );
1403QuerySQL( db, "CREATE TABLE IF NOT EXISTS Pickups(ID TEXT, Creator VARCHAR(32), X NUMERIC, Y NUMERIC, Z NUMERIC, PickupID TEXT, World NUMERIC )" );
1404QuerySQL( db, "CREATE TABLE IF NOT EXISTS Report(Player TEXT, Reporter TEXT, Reason TEXT, Date_Of_Report TEXT )" );
1405}
1406
1407function Reload()
1408{
1409dofile( "scripts/Main.nut" );
1410dofile( "scripts/Functions.nut" );
1411dofile( "scripts/Cmds.nut" );
1412dofile( "scripts/Echo.nut" );
1413MSG( "Script Reloaded" );
1414print( "Script Reloaded" );
1415}
1416
1417function CarregarCarros()
1418{
1419local i = 0, modelo, x, y, z, angulo, cor1, cor2;
1420local q = QuerySQL( db, "SELECT * FROM Carros" );
1421
1422while ( GetSQLColumnData( q, 0 ) != null )
1423{
1424modelo = GetSQLColumnData( q, 4 );
1425x = GetSQLColumnData( q, 5 );
1426y = GetSQLColumnData( q, 6 );
1427z = GetSQLColumnData( q, 7 );
1428angulo = GetSQLColumnData( q, 8 );
1429cor1 = GetSQLColumnData( q, 9 );
1430cor2 = GetSQLColumnData( q, 10 );
1431CreateVehicle( modelo, 0, Vector( x.tofloat(), y.tofloat(), z.tofloat() ), angulo, cor1, cor2 );
1432GetSQLNextRow( q );
1433i++;
1434}
1435FreeSQLQuery( q );
1436print( "Vehiculos Cargados - " + i );
1437}
1438
1439function IpToCountry( IP )
1440{
1441local country = geoip_country_name_by_addr( IP );
1442if ( IP == "127.0.0.1" ) return "Local-Host";
1443else if ( country == null ) return "Nao Encontrado";
1444else return country;
1445}
1446
1447function PartReason( reason )
1448{
1449if ( reason == 0 ) return "Timeout";
1450else if ( reason == 1 ) return "Quit";
1451else if ( reason == 2 ) return "Kickado";
1452else if ( reason == 3 ) return "Crash";
1453}
1454
1455function DeathReason( reason )
1456{
1457if ( reason == 70 ) return "Suicidio";
1458else if ( reason == 39 ) return "Car Accident";
1459else if ( reason == 31 ) return "Burned";
1460else if ( reason == 14 ) return "Suffocated";
1461else if ( reason == 43 ) return "Drowned";
1462else if ( reason == 41 ) return "Exploded";
1463else if ( reason == 51 ) return "Exploded";
1464else if ( reason == 44 ) return "Fell";
1465else return "Motivo Desconocido";
1466}
1467
1468function GetBP( part )
1469{
1470local group = "";
1471if ( part == 0 ) group = "Body";
1472else if ( part == 1 ) group = "Torso";
1473else if ( part == 2 ) group = "Left Arm";
1474else if ( part == 3 ) group = "Right Arm";
1475else if ( part == 4 ) group = "Left Leg";
1476else if ( part == 5 ) group = "Right Leg";
1477else if ( part == 6 ) group = "Head";
1478return group;
1479}
1480
1481function Configuracao()
1482{
1483SetUseClasses( true );
1484SetDeathMessages( false );
1485SetDrivebyEnabled( true );
1486SetDriveOnWater( true );
1487SetFlyingCars( false );
1488SetFriendlyFire( false );
1489SetJoinMessages( false );
1490SetShowNametags( true );
1491SetShowOnRadar( true );
1492SetStuntBike( false );
1493SetTaxiBoostJump( true );
1494SetServerName( Server.Nome );
1495SetSpawnPlayerPos( 104.356, -797.621, 10.4633 );
1496SetSpawnCameraPos( 98.3744, -810.273, 10.4633 );
1497SetSpawnCameraLook( 475.172, -67.5395, 9.98375 );
1498SetGameModeName( " v" + Server.Versao );
1499SetTime( 18, 00 );
1500SetTimeRate( 0 );
1501Classes();
1502print( Server.Nome + " v" + Server.Versao + " creado por " + Server.Desenvolvedor + " iniciado." );
1503}
1504
1505function Classes()
1506{
1507//================================= Tommy Team =================================
1508AddClass( 0, RGB( 30, 144, 255 ), 0, Vector( -378.557, -541.685, 17.2831 ), -0.00544404, 17, 1000 , 21, 1000, 26, 1000 );
1509AddClass( 0, RGB( 30, 144, 255 ), 95, Vector( -378.557, -541.685, 17.2831 ), -0.00544404, 17, 1000 , 21, 1000, 26, 1000 );
1510//================================== Cop Team ==================================
1511AddClass( 1, RGB( 190, 190, 190 ), 1, Vector( -657.341, 762.188, 11.5999 ), 2.441, 17, 1000 , 21, 1000, 26, 1000 );
1512AddClass( 1, RGB( 190, 190, 190 ), 3, Vector( -657.341, 762.188, 11.5999 ), 2.441, 17, 1000 , 21, 1000, 26, 1000 );
1513//================================== Army Team =================================
1514AddClass( 2, RGB( 255, 0, 0 ), 2, Vector( -1721.48, -226.703, 14.8683 ), -3.12018, 17, 1000 , 21, 1000, 26, 1000 );
1515AddClass( 2, RGB( 255, 0, 0 ), 4, Vector( -1721.48, -226.703, 14.8683 ), -3.12018, 17, 1000 , 21, 1000, 26, 1000 );
1516//================================== Taxi Team =================================
1517AddClass( 3, RGB( 255, 165, 0 ), 28, Vector( -995.355, 185.432, 12.434 ), -0.123521, 17, 1000 , 21, 1000, 26, 1000 );
1518AddClass( 3, RGB( 255, 165, 0 ), 74, Vector( -995.355, 185.432, 12.434 ), -0.123521, 17, 1000 , 21, 1000, 26, 1000 );
1519//================================== Golf Team =================================
1520AddClass( 4, RGB( 250, 128, 114 ), 62, Vector( 100.034, 254.158, 21.7719 ), -2.70758, 17, 1000 , 21, 1000, 26, 1000 );
1521AddClass( 4, RGB( 250, 128, 114 ), 64, Vector( 100.034, 254.158, 21.7719 ), -2.70758, 17, 1000 , 21, 1000, 26, 1000 );
1522//================================== Biker Team ================================
1523AddClass( 5, RGB( 160, 32, 240 ), 93, Vector( -603.613, 634.466, 12.2347 ), -1.47827, 17, 1000 , 21, 1000, 26, 1000 );
1524AddClass( 5, RGB( 160, 32, 240 ), 94, Vector( -603.613, 634.466, 12.2347 ), -1.47827, 17, 1000 , 21, 1000, 26, 1000 );
1525//================================== Pizza Team ================================
1526AddClass( 6, RGB( 255, 255, 0 ), 68, Vector( -907.399, 800.637, 11.3918 ), -1.64542, 17, 1000 , 21, 1000, 26, 1000 );
1527AddClass( 6, RGB( 255, 255, 0 ), 132, Vector( -907.399, 800.637, 11.3918 ), -1.64542, 17, 1000 , 21, 1000, 26, 1000 );
1528//================================== Thug Team =================================
1529AddClass( 7, RGB( 0, 139, 139 ), 154, Vector( 85.0716, 1112.38, 18.7597 ), 3.12136, 17, 1000 , 21, 1000, 26, 1000 );
1530AddClass( 7, RGB( 0, 139, 139 ), 148, Vector( 85.0716, 1112.38, 18.7597 ), 3.12136, 17, 1000 , 21, 1000, 26, 1000 );
1531//================================ Haitian Team ================================
1532AddClass( 8, RGB( 0, 255, 255 ), 85, Vector( -965.356, 148.572, 9.39548 ), -1.53778, 17, 1000 , 21, 1000, 26, 1000 );
1533AddClass( 8, RGB( 0, 255, 255 ), 86, Vector( -965.356, 148.572, 9.39548 ), -1.53778, 17, 1000 , 21, 1000, 26, 1000 );
1534//================================= Cuban Team =================================
1535AddClass( 9, RGB( 255, 192, 203 ), 83, Vector( -1167.03, -614.434, 11.8292 ), 1.78367, 17, 1000 , 21, 1000, 26, 1000 );
1536AddClass( 9, RGB( 255, 192, 203 ), 84, Vector( -1167.03, -614.434, 11.8292 ), 1.78367, 17, 1000 , 21, 1000, 26, 1000 );
1537//================================ Malibu Team =================================
1538AddClass( 10, RGB( 127, 255, 212 ), 186, Vector( 465.706, -53.9011, 15.7038 ), -2.37175, 17, 1000 , 21, 1000, 26, 1000 );
1539AddClass( 10, RGB( 127, 255, 212 ), 115, Vector( 465.706, -53.9011, 15.7038 ), -2.37175, 17, 1000 , 21, 1000, 26, 1000 );
1540//================================= FBI Team ===================================
1541AddClass( 11, RGB( 255, 215, 0 ), 97, Vector( -873.145, -684.57, 11.3023 ), -0.649355, 17, 1000 , 21, 1000, 26, 1000 );
1542AddClass( 11, RGB( 255, 215, 0 ), 100, Vector( -873.145, -684.57, 11.3023 ), -0.649355, 17, 1000 , 21, 1000, 26, 1000 );
1543}
1544
1545function GetNameClass( classID )
1546{
1547local id = classID;
1548if ( id == 0 ) return "Tommy's Team";
1549else if ( id == 1 ) return "Police Team";
1550else if ( id == 2 ) return "Army Team";
1551else if ( id == 3 ) return "Taxi Team";
1552else if ( id == 4 ) return "Golf Team";
1553else if ( id == 5 ) return "Bikers Team";
1554else if ( id == 6 ) return "Pizza Team";
1555else if ( id == 7 ) return "Thug Team";
1556else if ( id == 8 ) return "Haitian Team";
1557else if ( id == 9 ) return "Cuban Team";
1558else if ( id == 10 ) return "Malibu Team";
1559else if ( id == 11 ) return "FBI Team";
1560else return " ";
1561}
1562
1563function S_MSG( text, player ) MessagePlayer( "[#00cc00]|SINTAX|[#FFFFFF] " + text, player );
1564
1565function E_MSG( text, player ) MessagePlayer( "[#ff0000]|ERROR|[#FFFFFF] " + text, player );
1566
1567function I_MSG( text, player ) MessagePlayer( "[#000099]|INFO|[#FFFFFF] " + text, player );
1568
1569function A_MSG( text, player )
1570{
1571MessageAllExcept( "[#FFFFFF]***[#00FFFF] " + text, player );
1572EchoMessage( "6***3 " + text );
1573}
1574
1575function MSG( text )
1576{
1577Message( "[#FFFFFF]***[#00FFFF] " + text );
1578EchoMessage( "6***3 " + text );
1579}
1580
1581function SalvarTudo()
1582{
1583for( local i = 0, plr; i < GetMaxPlayers(); i++ )
1584{
1585plr = FindPlayer( i );
1586if ( plr ) SalvarDados( plr );
1587}
1588}
1589
1590function CreateBox()
1591{
1592 Box = CreatePickup( 345 , Vector( -403.665, 900.964, 39.2562 ) );
1593}
1594
1595function Agua( user )
1596{
1597local player = FindPlayer( user );
1598if ( player ) player.Pos = Vector( -597.7496, -1858.9531, 28.1291 );
1599}
1600
1601function Drown( admin, player, motivo )
1602{
1603if ( player.Vehicle ) player.Eject();
1604MSG( "Admin " + admin + " drowned " + player.Name + ". Motiv: " + motivo + "." );
1605player.Health = 3;
1606NewTimer( "Agua", 700, 1, player.ID );
1607}
1608
1609function Ban( admin, player, motivo )
1610{
1611QuerySQL( db, "INSERT INTO Bans ( Nome, UID, Admin, Motivo, Data ) VALUES ( '" + player.Name + "', '" + player.UniqueID + "', '" + admin + "', '" + motivo + "', '" + GetFullTime() + "' )" );
1612MSG( "Admin " + admin + " baneo a " + player.Name + ". Motivo: " + motivo + "." );
1613KickPlayer( player );
1614}
1615
1616function Kick( admin, player, motivo )
1617{
1618MSG( "Admin " + admin + " kickeo " + player.Name + ". Motivo: " + motivo + "." );
1619KickPlayer( player );
1620}
1621
1622function GetVehInfo( veh, opcao )
1623{
1624local opcao = opcao.tolower();
1625if ( veh )
1626{
1627local q = QuerySQL( db, "SELECT * FROM Carros WHERE ID='" + veh.ID + "'" );
1628if ( opcao == "preco" ) return GetSQLColumnData( q, 1 ).tointeger();
1629else if ( opcao == "dono" ) return GetSQLColumnData( q, 2 );
1630else if ( opcao == "compart" ) return GetSQLColumnData( q, 3 );
1631else return "Informacion no encontrada";
1632}
1633}
1634
1635function DonoCompartVeh( player, veh )
1636{
1637if ( GetVehInfo( veh, "dono" ) == player.Name || GetVehInfo( veh, "compart" ) == player.Name ) return true;
1638else return false;
1639}
1640
1641function VeiculoInfo( player, veh, opcao )
1642{
1643if ( opcao == 0 )
1644{
1645I_MSG( "ID: [" + veh.ID + "] | Price: [$ " + GetVehInfo( veh, "preco" ) + "].", player );
1646I_MSG( "Owner: [" + GetVehInfo( veh, "dono" ) + "] | Shared with: [" + GetVehInfo( veh, "compart" ) + "].", player );
1647}
1648else if ( opcao == 1 ) I_MSG( "You have left the vehicle " + ".", player );
1649}
1650
1651function IsVehForSale( id )
1652{
1653local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+id+"'" );
1654local own = GetSQLColumnData( q, 2 );
1655if ( own == "Unowned" ) return 1;
1656else return 0;
1657}
1658function IsOwnerOrSharer( veh, player )
1659{
1660local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+veh.ID+"'" );
1661local owner = GetSQLColumnData( q, 2 );
1662local sha = GetSQLColumnData( q, 3 );
1663local sha2 = GetSQLColumnData( q, 4 );
1664if ( ( owner == player.Name ) || ( sha == player.Name ) || ( sha2 == player.Name ) ) return 1;
1665else return 0;
1666}
1667function IsVehicleOwner( veh, player )
1668{
1669local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+veh.ID+"'" );
1670local owner = GetSQLColumnData( q, 2 );
1671if ( owner == player.Name ) return 1;
1672else return 0;
1673}
1674//==============================================================================
1675//------------------------- Player Functions -----------------------------------
1676//==============================================================================
1677function Checar( player, plr )
1678{
1679if ( plr == null )
1680{
1681if ( status[ player.ID ].Registrado == false )
1682{
1683E_MSG( "[#cccccc]Your name is not registered.", player );
1684return true;
1685}
1686else if ( status[ player.ID ].Registrado == true && status[ player.ID ].Logado == false )
1687{
1688E_MSG( "[#cccccc]You are not loged in.", player );
1689return true;
1690}
1691}
1692else if ( plr != null )
1693{
1694if ( status[ plr.ID ].Registrado == false )
1695{
1696E_MSG( plr.Name + " [#cccccc]it's not registered.", player );
1697return true;
1698}
1699else if ( status[ plr.ID ].Registrado == true && status[ plr.ID ].Logado == false )
1700{
1701E_MSG( plr.Name + " [#cccccc]not loged in.", player );
1702return true;
1703}
1704}
1705else return false;
1706}
1707
1708function GetStats( player )
1709{
1710local kills = status[ player.ID ].Matou, deaths = status[ player.ID ].Morreu, ratio;
1711if ( kills >= 1 && deaths >= 1 ) ratio = format( "%.2f", kills.tofloat() / deaths.tofloat() );
1712else ratio = 0;
1713Message( "[#cc00cc]* Stats de[#ff0000] " + player.Name + "[#00fFFF]: Killed:[#00FFFF] " + kills + "[#00fFFF] | Died:[#00FFFF] " + deaths + "[#00fFFF] | Experiencia:[#00FFFF] " + ratio + "[#00fFFF]." );
1714EchoMessage( "12* Status de4 " + player.Name + "12: Matou:4 " + kills + "12 | Morreu:4 " + deaths + "12 | Ratio:4 " + ratio + "12." );
1715}
1716
1717function Registrar( player, senha )
1718{
1719local pass = e(senha);
1720QuerySQL( db, "INSERT INTO Contas ( Nome, IP, UID, Senha, Dinheiro, Banco, Level, Data_Reg, Data_Join, Matou, Morreu, Nogoto, SpawnLoc, Loc ) VALUES ( '" + player.Name +
1721"', '" + player.IP + "', '" + player.UniqueID + "', '" + pass + "', 2000, 0, 1, '" + GetFullTime() + "', '" + GetFullTime() + "', 0, 0, 'off', 'off', 0 )" );
1722IncCash( player, 10000 );
1723status[ player.ID ].Registrado = true;
1724status[ player.ID ].Logado = true;
1725status[ player.ID ].Level = 1;
1726A_MSG( player.Name + " se registro con exito.", player );
1727I_MSG( "Usted se registro con exito.", player );
1728I_MSG( "No olvide su contrasenia: " + senha, player );
1729Announce( "~y~Nombre registrado!", player, 3 );
1730}
1731
1732function Login( player )
1733{
1734CarregarDados( player );
1735A_MSG( player.Name + " has successfully loged in.", player );
1736I_MSG( "[#00cc00]Welcome back [#cccccc]" + player.Name + ".", player );
1737I_MSG( "[#cccccc]You have entered correctly.", player );
1738I_MSG( "Level: " + status[ player.ID ].Level + " - Status: " + LevelTag( player ) + ".", player );
1739Announce( "~y~Loged in!", player, 3 );
1740}
1741
1742function ChecarConta( player )
1743{
1744status[ player.ID ] = PlayerStats();
1745
1746if ( GetLevel( player ) >= 1 )
1747{
1748if ( player.IP != GetIP( player ) )
1749{
1750I_MSG( "[#cccccc]You are connected with a different IP.", player );
1751I_MSG( "[#cccccc]Please use /login <password>", player );
1752status[ player.ID ].Registrado = true;
1753status[ player.ID ].Logado = false;
1754}
1755else if ( player.IP == GetIP( player ) )
1756{
1757CarregarDados( player );
1758I_MSG( "[#00cc00]Welcome back [#cccccc]" + player.Name + ".", player );
1759I_MSG( "[#cccccc]You have loged in automatically.", player );
1760I_MSG( "Level: " + status[ player.ID ].Level + " - Status: " + LevelTag( player ) + ".", player );
1761}
1762}
1763else
1764{
1765I_MSG( "[#00cc00]Welcome back [#cccccc]" + player.Name + ".", player );
1766I_MSG( "[#cccccc]Your name is not registered on the server.", player );
1767I_MSG( "[#cccccc]Please use /register <password>.", player );
1768}
1769ChecarJogador( player );
1770}
1771
1772function CarregarDados( player )
1773{
1774local q = QuerySQL( db, "SELECT * FROM Contas WHERE Nome='" + player.Name + "'" );
1775
1776status[ player.ID ].Registrado = true;
1777status[ player.ID ].Logado = true;
1778status[ player.ID ].Dinheiro = GetSQLColumnData( q, 4 );
1779status[ player.ID ].Banco = GetSQLColumnData( q, 5 );
1780status[ player.ID ].Level = GetSQLColumnData( q, 6 );
1781status[ player.ID ].Matou = GetSQLColumnData( q, 9 );
1782status[ player.ID ].Morreu = GetSQLColumnData( q, 10 );
1783if ( GetSQLColumnData( q, 11 ) == "on" ) status[ player.ID ].Nogoto = true;
1784if ( GetSQLColumnData( q, 12 ) == "on" ) status[ player.ID ].SpawnLoc = true;
1785if ( GetSQLColumnData( q, 13 ) != "0" ) status[ player.ID ].Loc = GetSQLColumnData( q, 13 );
1786player.Cash = status[ player.ID ].Dinheiro;
1787Data_IP( player );
1788}
1789
1790function Data_IP( player )
1791{
1792QuerySQL( db, "UPDATE Contas SET IP='" + player.IP + "', Data_Join='" + GetFullTime() + "' WHERE Nome='" + player.Name + "'" );
1793}
1794
1795function SalvarDados( player )
1796{
1797local p = status[ player.ID ], nogoto = "off";
1798if ( p.Registrado == true && p.Logado == true )
1799{
1800if ( p.Nogoto == true ) nogoto = "on";
1801QuerySQL( db, "UPDATE Contas SET Dinheiro='" + p.Dinheiro + "', Banco='" + p.Banco + "', Level='" + p.Level +
1802"', Matou='" + p.Matou + "', Morreu='" + p.Morreu + "', Nogoto='" + nogoto + "' WHERE Nome='" + player.Name + "'" );
1803}
1804}
1805
1806function ChecarJogador( player )
1807{
1808local q = QuerySQL( db, "SELECT * FROM Bans WHERE UID='" + player.UniqueID + "'" );
1809if ( GetSQLColumnData( q, 1 ) == player.UniqueID )
1810{
1811A_MSG( player.Name + " esta baneado.", player );
1812I_MSG( "Usted esta baneado del server.", player );
1813I_MSG( "Admin que te baneo: " + GetSQLColumnData( q, 2 ) + " | Data: " + GetSQLColumnData( q, 4 ) + ".", player );
1814I_MSG( "Motivo de banimento: " + GetSQLColumnData( q, 3 ) + ".", player );
1815KickPlayer( player );
1816}
1817else if ( player.Name == "Ninguem" ) Kick( "Server", player, "Nick Bloqueado" );
1818}
1819
1820function Heal( user )
1821{
1822local player = FindPlayer( user );
1823if ( player )
1824{
1825if ( player.IsSpawned && player.Health >= 1 )
1826{
1827player.IsFrozen = false;
1828DecCash( player, 250 );
1829player.Health = 100;
1830I_MSG( "[#cccccc]Usted se ha curado. Precio $250.", player );
1831}
1832else
1833{
1834player.IsFrozen = false;
1835E_MSG( "Usted no puede curarse en este momento.", player );
1836}
1837}
1838}
1839
1840function Goto( user, user2 )
1841{
1842local player = FindPlayer( user ), plr = FindPlayer( user2 );
1843if ( player && plr )
1844{
1845player.Pos = plr.Pos;
1846player.IsFrozen = false;
1847I_MSG( "You have teleported to " + plr.Name + ".", player );
1848I_MSG( player.Name + " teleported to you.", plr );
1849}
1850if ( !plr )
1851{
1852player.IsFrozen = false;
1853I_MSG( "Jugador desconocido.", player );
1854}
1855}
1856
1857function Gotoloc( user, loc )
1858{
1859local player = FindPlayer( user );
1860if ( player )
1861{
1862local q = QuerySQL( db, "SELECT * FROM Locs WHERE Nome='" + loc + "'" ),
1863pos = split( GetSQLColumnData( q, 1 ), " " );
1864player.Pos = Vector( pos[0].tofloat(), pos[1].tofloat(), pos[2].tofloat() );
1865I_MSG( "Teleported to the location: " + loc + " | Created by: " + GetSQLColumnData( q, 2 ) + " | Date: " + GetSQLColumnData( q, 3 ) + ".", player );
1866player.IsFrozen = false;
1867}
1868}
1869
1870function GiveWeapons( player, vargv )
1871{
1872local Weapons = "", i;
1873for ( i = 0; i < vargv.len(); i++ )
1874{
1875if( GetWeaponID( vargv[ i ] ) && GetWeaponName( GetWeaponID( vargv[ i ] ) ) != "Unknown" && GetWeaponID( vargv[ i ] ) != 33 )
1876{
1877local wep = GetWeaponID( vargv[ i ] );
1878if ( wep != 33 )
1879{
1880player.SetWeapon( GetWeaponID( vargv[ i ] ), 9999 );
1881if( Weapons == "" ) Weapons = GetWeaponName( GetWeaponID( vargv[ i ] ) ).tostring();
1882else Weapons = Weapons + ", " + GetWeaponName( GetWeaponID( vargv[ i ] ) ).tostring();
1883}
1884}
1885}
1886I_MSG( Weapons + ".", player );
1887}
1888
1889function JoinMessage( player )
1890{
1891Message( "[#00BFFF]*** [#FFFFFF]" + player.Name + " [#00ffff]Entered on the server. (" + IpToCountry( player.IP ) + ")" );
1892EchoMessage( "10***4 " + player.Name + " 10Entered on server. (" + IpToCountry( player.IP ) + ")" );
1893}
1894
1895function QuitMessage( player, motivo )
1896{
1897Message( "[#00BFFF]*** [#FFFFFF]" + player.Name + " [#00BFFF]saiu do servidor. (" + PartReason( motivo ) + ")" );
1898EchoMessage( "10***4 " + player.Name + " 10left the server. (" + PartReason( motivo ) + ")" );
1899}
1900
1901function LevelTag( player )
1902{
1903local lvl = status[ player.ID ].Level;
1904if ( lvl == 0 ) return "Visitante";
1905else if ( lvl == 1 ) return "Miembro";
1906else if ( lvl == 2 ) return "VIP";
1907else if ( lvl == 3 ) return "Admin";
1908else if ( lvl == 4 ) return "Administrador";
1909else if ( lvl == 5 ) return "Co_Moderador";
1910else if ( lvl == 6 ) return "Moderador";
1911else if ( lvl == 7 ) return "Administrador avanzado";
1912else if ( lvl == 8 ) return "Administrador Maestro";
1913else if ( lvl == 9 ) return "Manager";
1914else if ( lvl >= 10 ) return "Desarrollador";
1915}
1916
1917function GetLevel( player )
1918{
1919local result = GetSQLColumnData( QuerySQL( db, "SELECT Level FROM Contas WHERE Nome='" + player.Name + "'" ), 0 ), lvl;
1920if ( result == null ) lvl = GetSQLColumnData( QuerySQL( db, "SELECT Level FROM Contas WHERE Nome='" + player.Name + "'" ), 0 );
1921else lvl = result;
1922if ( lvl ) return lvl;
1923else return 0;
1924}
1925
1926function GetIP( player )
1927{
1928local result = GetSQLColumnData( QuerySQL( db, "SELECT IP FROM Contas WHERE Nome='" + player.Name + "'" ), 0 ), ip;
1929if ( result == null ) ip = GetSQLColumnData( QuerySQL( db, "SELECT IP FROM Contas WHERE Nome='" + player.Name + "'" ), 0 );
1930else ip = result;
1931if ( ip ) return ip;
1932else return 0;
1933}
1934
1935function GetSenha( player )
1936{
1937local result = GetSQLColumnData( QuerySQL( db, "SELECT Senha FROM Contas WHERE Nome='" + player.Name + "'" ), 0 ), pass;
1938if ( result == null ) pass = GetSQLColumnData( QuerySQL( db, "SELECT Senha FROM Contas WHERE Nome='" + player.Name + "'" ), 0 );
1939else pass = result;
1940if ( pass ) return pass;
1941else return 0;
1942}
1943
1944function IncCash( player, amount )
1945{
1946local cash = status[ player.ID ].Dinheiro;
1947local add = cash + amount;
1948status[ player.ID ].Dinheiro = add;
1949player.Cash = add;
1950}
1951
1952function DecCash( player, amount )
1953{
1954local cash = status[ player.ID ].Dinheiro;
1955local det = cash - amount;
1956status[ player.ID ].Dinheiro = det;
1957player.Cash = det;
1958}
1959
1960function IncBank( player, amount )
1961{
1962local bank = status[ player.ID ].Banco;
1963local add = bank + amount;
1964status[ player.ID ].Banco = add;
1965}
1966
1967function DecBank( player, amount )
1968{
1969local bank = status[ player.ID ].Banco;
1970local det = bank - amount;
1971status[ player.ID ].Banco = det;
1972}
1973
1974function Timer()
1975{
1976for( local i = 0, player; i < GetMaxPlayers(); i++ )
1977{
1978player = FindPlayer( i );
1979if ( player )
1980{
1981if ( SpawnKill[ player.ID ] >= 1 ) SpawnKill[ player.ID ] --;
1982if ( Multa[ player.ID ] >= 1 )
1983{
1984Multa[ player.ID ] --;
1985if ( Multa[ player.ID ] == 0 ) UnMute( "Server", player );
1986}
1987}
1988}
1989}
1990
1991function CheckSpam( player, reason )
1992{
1993local MSNxSEC = 2000, LIMIT_REP_SPAM = 3;
1994local spammer = ( GetTickCount() - status[ player.ID ].Count_Msg ) / MSNxSEC;
1995status[ player.ID ].Msg_Player += spammer - 1;
1996if ( status[ player.ID ].Msg_Player > LIMIT_REP_SPAM ) status[ player.ID ].Msg_Player = LIMIT_REP_SPAM - 1;
1997if ( status[ player.ID ].Msg_Player < 0 ) status[ player.ID ].Msg_Player = -1;
1998status[ player.ID ].Count_Msg = GetTickCount();
1999if ( status[ player.ID ].Msg_Player < 0)
2000{
2001if ( Multa[ player.ID ] == 0 )
2002{
2003Multa[ player.ID ] = 30;
2004I_MSG( "[#ff0000]Cuidado: [#cccccc]you have been muted for spamming and you will not be able to chat for a moment.", player );
2005A_MSG( "Auto-Mute " + player.Name + ", ID: " + player.ID + ". Motivo:[ " + reason + " ].", player );
2006}
2007}
2008}
2009
2010function UnMute( admin, player )
2011{
2012Multa[ player.ID ] = 0;
2013MSG( "Admin " + admin + " desmuteo a " + player.Name + "." );
2014}
2015
2016function LoadSpawnLoc( player )
2017{
2018if ( status[ player.ID ].SpawnLoc == true && status[ player.ID ].Loc != null )
2019{
2020local loc = status[ player.ID ].Loc,
2021pos = split( loc, " " ),
2022px = pos[0].tofloat(), py = pos[1].tofloat(), pz = pos[2].tofloat();
2023player.Pos = Vector( px, py, pz );
2024}
2025}
2026
2027function AddSpawnWep( player, wep, wep2, wep3, wep4 )
2028{
2029if ( ( wep ) && IsNum( wep ) ) wep = wep.tointeger();
2030else if ( wep ) wep = GetWeaponID( wep );
2031if ( ( wep2 ) && IsNum( wep2 ) ) wep2 = wep2.tointeger();
2032else if ( wep2 ) wep2 = GetWeaponID( wep2 );
2033if ( ( wep3 ) && IsNum( wep3 ) ) wep3 = wep3.tointeger();
2034else if ( wep3 ) wep3 = GetWeaponID( wep3 );
2035if ( ( wep4 ) && IsNum( wep4 ) ) wep4 = wep4.tointeger();
2036else if ( wep4 ) wep4 = GetWeaponID( wep4 );
2037QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2038QuerySQL( db, "INSERT INTO SpawnWep ( Nome, Wep1, Wep2, Wep3, Wep4 ) VALUES ( '" + player.Name + "', '" + wep + "', '" + wep2 + "', '" + wep3 + "', '" + wep4 + "')" );
2039I_MSG( "Arma(s) adiciona(s) e carregada(s).", player );
2040}
2041
2042function DelSpawnWep( player )
2043{
2044QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2045I_MSG( "Arma(s) deletada(s) de seu spawn.", player );
2046}
2047
2048function swep( player )
2049{
2050local swep = GetSQLColumnData( QuerySQL( db, "SELECT Wep1 FROM SpawnWep WHERE Nome='" + player.Name + "'" ), 0 );
2051if ( swep ) return swep;
2052else return 0;
2053}
2054
2055function swep2( player )
2056{
2057local swep2 = GetSQLColumnData( QuerySQL( db, "SELECT Wep2 FROM SpawnWep WHERE Nome='" + player.Name + "'" ), 0 );
2058if ( swep2 ) return swep2;
2059else return 0;
2060}
2061
2062function swep3( player )
2063{
2064local swep3 = GetSQLColumnData( QuerySQL( db, "SELECT Wep3 FROM SpawnWep WHERE Nome='" + player.Name + "'" ), 0 );
2065if ( swep3 ) return swep3;
2066else return 0;
2067}
2068function swep4( player )
2069{
2070local swep4 = GetSQLColumnData( QuerySQL( db, "SELECT Wep4 FROM SpawnWep WHERE Nome='" + player.Name + "'" ), 0 );
2071if ( swep4 ) return swep4;
2072else return 0;
2073}
2074
2075function LoadSpawnWep( player )
2076{
2077if ( swep(player) == 0 );
2078else if ( swep(player) == 1 ) player.SetWeapon( 1, 300 );
2079else if ( swep(player) == 2 ) player.SetWeapon( 2, 300 );
2080else if ( swep(player) == 3 ) player.SetWeapon( 3, 300 );
2081else if ( swep(player) == 4 ) player.SetWeapon( 4, 300 );
2082else if ( swep(player) == 5 ) player.SetWeapon( 5, 300 );
2083else if ( swep(player) == 6 ) player.SetWeapon( 6, 300 );
2084else if ( swep(player) == 7 ) player.SetWeapon( 7, 300 );
2085else if ( swep(player) == 8 ) player.SetWeapon( 8, 300 );
2086else if ( swep(player) == 9 ) player.SetWeapon( 9, 300 );
2087else if ( swep(player) == 10 ) player.SetWeapon( 10, 300 );
2088else if ( swep(player) == 11 ) player.SetWeapon( 11, 300 );
2089else if ( swep(player) == 12 ) player.SetWeapon( 12, 300 );
2090else if ( swep(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2091else if ( swep(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2092else if ( swep(player) == 15 ) player.SetWeapon( 15, 300 );
2093else if ( swep(player) == 16 ) player.SetWeapon( 16, 300 );
2094else if ( swep(player) == 17 ) player.SetWeapon( 17, 300 );
2095else if ( swep(player) == 18 ) player.SetWeapon( 18, 300 );
2096else if ( swep(player) == 19 ) player.SetWeapon( 19, 300 );
2097else if ( swep(player) == 20 ) player.SetWeapon( 20, 300 );
2098else if ( swep(player) == 21 ) player.SetWeapon( 21, 300 );
2099else if ( swep(player) == 22 ) player.SetWeapon( 22, 300 );
2100else if ( swep(player) == 23 ) player.SetWeapon( 23, 300 );
2101else if ( swep(player) == 24 ) player.SetWeapon( 24, 300 );
2102else if ( swep(player) == 25 ) player.SetWeapon( 25, 300 );
2103else if ( swep(player) == 26 ) player.SetWeapon( 26, 300 );
2104else if ( swep(player) == 27 ) player.SetWeapon( 27, 300 );
2105else if ( swep(player) == 28 ) player.SetWeapon( 28, 300 );
2106else if ( swep(player) == 29 ) player.SetWeapon( 29, 300 );
2107else if ( swep(player) == 30 ) player.SetWeapon( 30, 300 );
2108else if ( swep(player) == 31 ) player.SetWeapon( 31, 300 );
2109else if ( swep(player) == 32 ) player.SetWeapon( 32, 300 );
2110else if ( swep(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2111
2112if ( swep2(player) == 0 );
2113else if ( swep2(player) == 1 ) player.SetWeapon( 1, 300 );
2114else if ( swep2(player) == 2 ) player.SetWeapon( 2, 300 );
2115else if ( swep2(player) == 3 ) player.SetWeapon( 3, 300 );
2116else if ( swep2(player) == 4 ) player.SetWeapon( 4, 300 );
2117else if ( swep2(player) == 5 ) player.SetWeapon( 5, 300 );
2118else if ( swep2(player) == 6 ) player.SetWeapon( 6, 300 );
2119else if ( swep2(player) == 7 ) player.SetWeapon( 7, 300 );
2120else if ( swep2(player) == 8 ) player.SetWeapon( 8, 300 );
2121else if ( swep2(player) == 9 ) player.SetWeapon( 9, 300 );
2122else if ( swep2(player) == 10 ) player.SetWeapon( 10, 300 );
2123else if ( swep2(player) == 11 ) player.SetWeapon( 11, 300 );
2124else if ( swep2(player) == 12 ) player.SetWeapon( 12, 300 );
2125else if ( swep2(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2126else if ( swep2(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2127else if ( swep2(player) == 15 ) player.SetWeapon( 15, 300 );
2128else if ( swep2(player) == 16 ) player.SetWeapon( 16, 300 );
2129else if ( swep2(player) == 17 ) player.SetWeapon( 17, 300 );
2130else if ( swep2(player) == 18 ) player.SetWeapon( 18, 300 );
2131else if ( swep2(player) == 19 ) player.SetWeapon( 19, 300 );
2132else if ( swep2(player) == 20 ) player.SetWeapon( 20, 300 );
2133else if ( swep2(player) == 21 ) player.SetWeapon( 21, 300 );
2134else if ( swep2(player) == 22 ) player.SetWeapon( 22, 300 );
2135else if ( swep2(player) == 23 ) player.SetWeapon( 23, 300 );
2136else if ( swep2(player) == 24 ) player.SetWeapon( 24, 300 );
2137else if ( swep2(player) == 25 ) player.SetWeapon( 25, 300 );
2138else if ( swep2(player) == 26 ) player.SetWeapon( 26, 300 );
2139else if ( swep2(player) == 27 ) player.SetWeapon( 27, 300 );
2140else if ( swep2(player) == 28 ) player.SetWeapon( 28, 300 );
2141else if ( swep2(player) == 29 ) player.SetWeapon( 29, 300 );
2142else if ( swep2(player) == 30 ) player.SetWeapon( 30, 300 );
2143else if ( swep2(player) == 31 ) player.SetWeapon( 31, 300 );
2144else if ( swep2(player) == 32 ) player.SetWeapon( 32, 300 );
2145else if ( swep2(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2146
2147if ( swep3(player) == 0 );
2148else if ( swep3(player) == 1 ) player.SetWeapon( 1, 300 );
2149else if ( swep3(player) == 2 ) player.SetWeapon( 2, 300 );
2150else if ( swep3(player) == 3 ) player.SetWeapon( 3, 300 );
2151else if ( swep3(player) == 4 ) player.SetWeapon( 4, 300 );
2152else if ( swep3(player) == 5 ) player.SetWeapon( 5, 300 );
2153else if ( swep3(player) == 6 ) player.SetWeapon( 6, 300 );
2154else if ( swep3(player) == 7 ) player.SetWeapon( 7, 300 );
2155else if ( swep3(player) == 8 ) player.SetWeapon( 8, 300 );
2156else if ( swep3(player) == 9 ) player.SetWeapon( 9, 300 );
2157else if ( swep3(player) == 10 ) player.SetWeapon( 10, 300 );
2158else if ( swep3(player) == 11 ) player.SetWeapon( 11, 300 );
2159else if ( swep3(player) == 12 ) player.SetWeapon( 12, 300 );
2160else if ( swep3(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2161else if ( swep3(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2162else if ( swep3(player) == 15 ) player.SetWeapon( 15, 300 );
2163else if ( swep3(player) == 16 ) player.SetWeapon( 16, 300 );
2164else if ( swep3(player) == 17 ) player.SetWeapon( 17, 300 );
2165else if ( swep3(player) == 18 ) player.SetWeapon( 18, 300 );
2166else if ( swep3(player) == 19 ) player.SetWeapon( 19, 300 );
2167else if ( swep3(player) == 20 ) player.SetWeapon( 20, 300 );
2168else if ( swep3(player) == 21 ) player.SetWeapon( 21, 300 );
2169else if ( swep3(player) == 22 ) player.SetWeapon( 22, 300 );
2170else if ( swep3(player) == 23 ) player.SetWeapon( 23, 300 );
2171else if ( swep3(player) == 24 ) player.SetWeapon( 24, 300 );
2172else if ( swep3(player) == 25 ) player.SetWeapon( 25, 300 );
2173else if ( swep3(player) == 26 ) player.SetWeapon( 26, 300 );
2174else if ( swep3(player) == 27 ) player.SetWeapon( 27, 300 );
2175else if ( swep3(player) == 28 ) player.SetWeapon( 28, 300 );
2176else if ( swep3(player) == 29 ) player.SetWeapon( 29, 300 );
2177else if ( swep3(player) == 30 ) player.SetWeapon( 30, 300 );
2178else if ( swep3(player) == 31 ) player.SetWeapon( 31, 300 );
2179else if ( swep3(player) == 32 ) player.SetWeapon( 32, 300 );
2180else if ( swep3(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2181
2182if ( swep4(player) == 0 );
2183else if ( swep4(player) == 1 ) player.SetWeapon( 1, 300 );
2184else if ( swep4(player) == 2 ) player.SetWeapon( 2, 300 );
2185else if ( swep4(player) == 3 ) player.SetWeapon( 3, 300 );
2186else if ( swep4(player) == 4 ) player.SetWeapon( 4, 300 );
2187else if ( swep4(player) == 5 ) player.SetWeapon( 5, 300 );
2188else if ( swep4(player) == 6 ) player.SetWeapon( 6, 300 );
2189else if ( swep4(player) == 7 ) player.SetWeapon( 7, 300 );
2190else if ( swep4(player) == 8 ) player.SetWeapon( 8, 300 );
2191else if ( swep4(player) == 9 ) player.SetWeapon( 9, 300 );
2192else if ( swep4(player) == 10 ) player.SetWeapon( 10, 300 );
2193else if ( swep4(player) == 11 ) player.SetWeapon( 11, 300 );
2194else if ( swep4(player) == 12 ) player.SetWeapon( 12, 300 );
2195else if ( swep4(player) == 13 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2196else if ( swep4(player) == 14 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2197else if ( swep4(player) == 15 ) player.SetWeapon( 15, 300 );
2198else if ( swep4(player) == 16 ) player.SetWeapon( 16, 300 );
2199else if ( swep4(player) == 17 ) player.SetWeapon( 17, 300 );
2200else if ( swep4(player) == 18 ) player.SetWeapon( 18, 300 );
2201else if ( swep4(player) == 19 ) player.SetWeapon( 19, 300 );
2202else if ( swep4(player) == 20 ) player.SetWeapon( 20, 300 );
2203else if ( swep4(player) == 21 ) player.SetWeapon( 21, 300 );
2204else if ( swep4(player) == 22 ) player.SetWeapon( 22, 300 );
2205else if ( swep4(player) == 23 ) player.SetWeapon( 23, 300 );
2206else if ( swep4(player) == 24 ) player.SetWeapon( 24, 300 );
2207else if ( swep4(player) == 25 ) player.SetWeapon( 25, 300 );
2208else if ( swep4(player) == 26 ) player.SetWeapon( 26, 300 );
2209else if ( swep4(player) == 27 ) player.SetWeapon( 27, 300 );
2210else if ( swep4(player) == 28 ) player.SetWeapon( 28, 300 );
2211else if ( swep4(player) == 29 ) player.SetWeapon( 29, 300 );
2212else if ( swep4(player) == 30 ) player.SetWeapon( 30, 300 );
2213else if ( swep4(player) == 31 ) player.SetWeapon( 31, 300 );
2214else if ( swep4(player) == 32 ) player.SetWeapon( 32, 300 );
2215else if ( swep4(player) == 33 ) QuerySQL( db, "DELETE FROM SpawnWep WHERE Nome='" + player.Name + "'" );
2216}
2217//==============================================================================
2218//----------------------------- Criptografia -----------------------------------
2219//==============================================================================
2220function rotateRight(val, sbits)
2221{
2222 return (val >> sbits) | (val << (0x20 - sbits));
2223}
2224
2225function e( string )
2226{
2227 local hp = [
2228 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
2229 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
2230 ];
2231
2232 local k = [
2233 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
2234 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
2235 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
2236 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
2237 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
2238 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
2239 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
2240 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
2241 ];
2242
2243 local
2244 w = array( 64 ),
2245 i = 0,
2246 s = 0,
2247 len = string.len( ),
2248 word_array = array( 0 );
2249
2250 for( i = 0; i < len - 3; i += 4 )
2251 {
2252 word_array.push( string[i] << 0x18 | string[i + 1] << 0x10 | string[i + 2] << 0x08 | string[i + 3] );
2253 }
2254
2255 switch( len % 4 )
2256 {
2257 case 0:
2258 i = 0x80000000;
2259 break;
2260 case 1:
2261 i = string[len - 1] << 0x18 | 0x80000000;
2262 break;
2263 case 2:
2264 i = string[len - 2] << 0x18 | string[len - 1] << 0x10 | 0x08000;
2265 break;
2266 case 3:
2267 i = string[len - 3] << 0x18 | string[len - 2] << 0x10 | string[len - 1] << 0x08 | 0x80;
2268 break;
2269 }
2270 word_array.push( i );
2271
2272 while( ( word_array.len() % 0x10 ) != 0x0E )
2273 word_array.push( 0 );
2274
2275 word_array.push( len >> 0x10 );
2276 word_array.push( ( len << 0x03 ) & 0xFFFFFFFF );
2277
2278 local s0, s1;
2279 for( s = 0; s < word_array.len(); s += 0x10 )
2280 {
2281 for( i = 0x00; i < 0x10; i++ )
2282 w[i] = word_array[s + i];
2283
2284 for( i = 0x10; i < 0x40; i++ )
2285 {
2286 s0 = rotateRight( w[i - 15], 7 ) ^ rotateRight( w[i - 15], 18 ) ^ ( w[i - 15] >> 3 );
2287 s1 = rotateRight( w[i - 2], 17 ) ^ rotateRight( w[i - 2], 19 ) ^ ( w[i - 2] >> 10 );
2288 w[i] = w[i - 0x10] + s0 + w[i - 7] + s1;
2289 }
2290
2291 local a = hp[0],
2292 b = hp[1],
2293 c = hp[2],
2294 d = hp[3],
2295 e = hp[4],
2296 f = hp[5],
2297 g = hp[6],
2298 h = hp[7];
2299
2300 for( i = 0x00; i < 0x40; i++ )
2301 {
2302 s0 = ( rotateRight( a, 2 ) ^ rotateRight( a, 13 ) ^ rotateRight( a, 22 ) );
2303 local maj = ( ( a & b ) ^ ( a & c ) ^ ( b & c ) );
2304 local t2 = ( s0 + maj );
2305 s1 = ( rotateRight( e, 6 ) ^ rotateRight( e, 11) ^ rotateRight( e, 25 ) );
2306 local ch = ( ( e & f ) ^ ( ( ~e ) & g ) );
2307 local t1 = ( h + s1 + ch + k[i] + w[i] );
2308
2309 h = g;
2310 g = f;
2311 f = e;
2312 e = d + t1;
2313 d = c;
2314 c = b;
2315 b = a;
2316 a = t1 + t2;
2317 }
2318
2319 hp[0] += a;
2320 hp[1] += b;
2321 hp[2] += c;
2322 hp[3] += d;
2323 hp[4] += e;
2324 hp[5] += f;
2325 hp[6] += g;
2326 hp[7] += h;
2327 }
2328
2329 local hash = format(
2330 "%08x%08x%08x%08x%08x%08x%08x%08x",
2331 hp[0],
2332 hp[1],
2333 hp[2],
2334 hp[3],
2335 hp[4],
2336 hp[5],
2337 hp[6],
2338 hp[7]
2339 );
2340
2341 return hash;
2342}