· 7 years ago · Aug 23, 2018, 10:40 PM
1/* Plugin generated by AMXX-Studio */
2
3#include < amxmodx >
4#include < amxmisc >
5#include < cstrike >
6#include < hamsandwich >
7#include < fun >
8#include < engine >
9#include < fakemeta >
10#include < mysqlt >
11
12new const szPluginInfo [ ][ ] = {
13
14 { "[AMXX] Hidden Mod" },
15
16 { "1.0 BETA" },
17
18 { "Chema" }
19
20};
21
22#pragma compress 1
23
24new const g_sCommunity[ ] = "!g[BREAKING GAMING]!y";
25
26new const g_sUncompress[ ] = "no_amxx_uncompress";
27
28new g_countdown;
29new g_maxplayers;
30
31new g_iRemoveEntities;
32
33new g_iFlashbangTeam;
34
35const TASK_COUNTDOWN = 12523;
36
37const GRENADE_FLASH = 333;
38
39enum pCvarsStruct {
40
41 COUNTDOWN_TIME
42}
43
44new pCvars [ pCvarsStruct ];
45
46new g_iMsgSync [ 2 ];
47
48
49/* BLOCK BUY COMMANDS */
50
51new const g_sBuyCommands[][] =
52{
53 "usp", "glock", "deagle", "p228", "elites",
54 "fn57", "m3", "xm1014", "mp5", "tmp", "p90",
55 "mac10", "ump45", "ak47", "galil", "famas",
56 "sg552", "m4a1", "aug", "scout", "awp", "g3sg1",
57 "sg550", "m249", "vest", "vesthelm", "flash",
58 "hegren", "sgren", "defuser", "nvgs", "shield",
59 "primammo", "secammo", "km45", "9x19mm", "nighthawk",
60 "228compact", "fiveseven", "12gauge", "autoshotgun",
61 "mp", "c90", "cv47", "defender", "clarion", "krieg552",
62 "bullpup", "magnum", "d3au1", "krieg550"
63};
64
65/* HOOK MESSAGES ID */
66
67new g_sMessagesId [ ] [ ] = {
68
69 "#CTs_Win",
70
71 "#Terrorists_Win",
72
73 "#Game_will_restart_in"
74}
75
76new const g_sEntities [ ] [ ] = {
77
78 "func_bomb_target",
79
80 "info_bomb_target"
81}
82
83/* BLANK MODEL TERRORIST */
84
85new const g_sKnifeModel_v[ ] = "models/v_knife.mdl";
86new const g_sKnifeModel_w[ ] = "models/w_knife.mdl";
87new const g_sBlank [ ] = "";
88
89/* MENUS */
90
91const KEYS_PRINCIPAL = ( 1 << 0 ) | ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 3 ) | ( 1 << 4 ) | ( 1 << 5 ) | ( 1 << 6 ) | ( 1 << 7 ) | ( 1 << 8 ) | ( 1 << 9 );
92
93const KEYS_CONFIGURACION = ( 1 << 0 ) | ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 3 ) | ( 1 << 4 ) | ( 1 << 5 ) | ( 1 << 6 ) | ( 1 << 7 ) | ( 1 << 8 ) | ( 1 << 9 );
94
95const KEYS_PERFIL = ( 1 << 0 ) | ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 3 ) | ( 1 << 4 ) | ( 1 << 5 ) | ( 1 << 6 ) | ( 1 << 7 ) | ( 1 << 8 ) | ( 1 << 9 );
96
97const KEYS_LOGUEADO = ( 1 << 0 ) | ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 3 ) | ( 1 << 4 ) | ( 1 << 5 ) | ( 1 << 6 ) | ( 1 << 7 ) | ( 1 << 8 ) | ( 1 << 9 );
98
99/* SEXO */
100
101enum _:sexoStruct {
102
103 HOMBRE,
104 MUJER,
105 INDEFINIDO
106};
107
108new const g_sSexos [ sexoStruct ] [ ] = {
109
110 "HOMBRE",
111
112 "MUJER",
113
114 "INDEFINIDO"
115};
116
117new g_iSexo [ sexoStruct ];
118
119/* ACCOUNTS SYSTEM */
120
121new g_iNivel [ 33 ], g_iFrags [ 33 ];
122
123#define SiguienteNivel(%1) ( %1 * 15)
124
125new const g_sDatos [ ] [ ] = {
126
127 "localhost", // SERVER
128
129 "root", // USER
130
131 "", // PASSWORD
132
133 "hidden_db", // DATABASE
134
135 "hns_table" // TABLE
136};
137
138new Handle:g_hTuple;
139
140new g_id [ 33 ];
141new g_usuario [ 33 ] [ 34 ];
142new g_password [ 33 ] [ 34 ];
143new g_sPlayerName [ 33 ] [ 33 ];
144
145new g_sPlayerEmail [ 33 ] [ 34 ];
146
147new g_iStatus [ 33 ];
148
149enum {
150
151 ONLINE,
152 OFFLINE,
153 LOGED,
154};
155
156enum {
157
158 REGISTRAR_CUENTA,
159 LOGUEAR_CUENTA,
160 CARGAR_DATOS,
161 GUARDAR_DATOS,
162 MOSTRAR_TOP
163};
164
165new const g_sEmails[][] = {
166
167 "@live.com",
168
169 "@gmail.com",
170
171 "@hotmail.com",
172
173 "@live.com.ar",
174
175 "@gmail.com.ar",
176
177 "@hotmail.es",
178
179 "@hotmail.com.ar"
180};
181
182/* TABLE */
183/*
184CREATE TABLE hns_table (
185
186 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
187 Usuario varchar(34) NOT NULL UNIQUE KEY,
188 Password varchar(34) NOT NULL,
189 Pj varchar(32) NOT NULL UNIQUE KEY,
190 Nivel int(10) NOT NULL DEFAULT '0',
191 Frags int(10) NOT NULL DEFAULT '0',
192 email varchar(32) NOT NULL,
193 Sexo varchar(32) NOT NULL
194)
195*/
196
197public plugin_init ( ) {
198
199 register_plugin ( szPluginInfo [ 0 ], szPluginInfo [ 1 ], szPluginInfo [ 2 ] );
200
201 register_clcmd ( "say /set", "cmd_set" );
202
203 register_clcmd ( "say /info", "cmd_info" );
204
205 register_clcmd ( "CREAR_USUARIO", "reg_usuario" );
206 register_clcmd ( "CREAR_PASSWORD", "reg_password" );
207 register_clcmd ( "CREAR_EMAIL", "reg_email" );
208 register_clcmd ( "LOGUEAR_USUARIO", "log_usuario" );
209 register_clcmd ( "LOGUEAR_PASSWORD", "log_password" );
210
211 register_clcmd ( "chooseteam", "clcmd_changeteam" );
212 register_clcmd ( "jointeam", "clcmd_changeteam" );
213
214 /* MENÚS */
215
216 register_menu ( "Principal", KEYS_PRINCIPAL, "HM_Principal" );
217
218 register_menu ( "Configuracion", KEYS_CONFIGURACION, "HM_Configuracion" );
219
220 register_menu ( "Perfil", KEYS_PERFIL, "HM_Perfil" );
221
222 register_menu ( "Logueado", KEYS_LOGUEADO, "HM_Logueado" );
223
224 register_event ( "HLTV","Event_HLTV_New_Round", "a", "1=0", "2=0" );
225
226 register_event ( "CurWeapon", "eventCurWeapon", "b", "1=1" );
227
228 RegisterHam ( Ham_Spawn, "player", "fw_PlayerSpawn", 1 );
229
230 RegisterHam ( Ham_Killed, "player", "fw_killed", 1 );
231
232 RegisterHam ( Ham_Think,"grenade","fw_GrenadeThink_Pre", false );
233
234 unregister_forward ( FM_Spawn, g_iRemoveEntities );
235
236 register_forward ( FM_ClientUserInfoChanged, "FW_ClientUserInfoChanged" );
237
238 register_forward ( FM_SetModel,"fw_SetModel_Pre", false );
239
240 register_forward ( FM_CmdStart, "fw_CommandStart", 0 );
241
242 register_forward ( FM_PlayerPreThink, "fw_PlayerPreThink", 0 );
243
244 register_message ( get_user_msgid ( "StatusIcon" ), "message_StatusIcon" );
245
246 register_message ( get_user_msgid ( "TextMsg" ) ,"message_TextMsg" );
247
248 register_message ( get_user_msgid ( "ScreenFade" ),"message_ScreenFade" );
249
250 register_message ( get_user_msgid ( "ShowMenu" ), "message_ShowMenu" );
251 register_message ( get_user_msgid ( "VGUIMenu" ), "message_VGUIMenu" );
252
253
254 pCvars [ COUNTDOWN_TIME ] = register_cvar ( "hm_countdown", "10" );
255
256 g_maxplayers = get_maxplayers ( );
257
258 g_iMsgSync [ 0 ] = CreateHudSyncObj( );
259
260 new Entity = -1;
261
262 while ( ( Entity = find_ent_by_class ( Entity, "func_breakable" ) ) ) {
263
264 remove_entity ( Entity );
265 }
266
267 /* MYSQL DATA */
268 MySQLx_Init( );
269
270 server_print ( g_sUncompress );
271}
272
273public plugin_precache ( ) {
274
275 g_iRemoveEntities = register_forward ( FM_Spawn, "fw_RemoveEntities" );
276}
277
278public client_command ( id ) {
279
280 new sArgs [ 13 ];
281 if ( read_argv ( 0, sArgs, 12 ) > 11 )
282 return PLUGIN_CONTINUE;
283
284 for( new i = 0; i < sizeof ( g_sBuyCommands ); i++ ) {
285
286 if ( equali ( g_sBuyCommands [ i ], sArgs, 0 ) )
287 return PLUGIN_HANDLED;
288 }
289
290 return PLUGIN_CONTINUE;
291}
292
293public message_StatusIcon ( msgid, msgdest, id ) {
294
295 static sIcon [ 8 ];
296
297 get_msg_arg_string ( 2, sIcon, 7 );
298
299 if ( equal ( sIcon, "buyzone" ) && get_msg_arg_int ( 1 ) ) {
300
301 set_pdata_int ( id, 235, get_pdata_int ( id, 235 ) & ~( 1<<0 ) );
302 return PLUGIN_HANDLED;
303 }
304
305 return PLUGIN_CONTINUE;
306}
307
308public message_TextMsg ( msg_id, msg_dest, msg_entity ) {
309
310 static sMessages [ 32 ];
311
312 get_msg_arg_string ( 2, sMessages, charsmax ( sMessages ) );
313
314 if ( equal( sMessages, g_sMessagesId[ 0 ] ) ) {
315
316 PrintText ( 0, "%s^1 Ganaron los^4 CT's^1 se cambiarán los equipos.", g_sCommunity );
317 switchTeams ( );
318 }
319 else if ( equal ( sMessages, g_sMessagesId[ 1 ] ) ) {
320
321 PrintText ( 0, "%s^1 Ganaron los^4 terroristas^1, no hay cambio de equipos.", g_sCommunity );
322 }
323
324 if ( equal ( sMessages, g_sMessagesId [ 2 ] ) ) {
325
326 remove_task ( TASK_COUNTDOWN );
327 }
328
329 return PLUGIN_CONTINUE;
330}
331
332public message_VGUIMenu( iMsgid, iDest, id ) {
333
334 if( g_iStatus [ id ] == LOGED || get_msg_arg_int( 1 ) != 2 )
335 return PLUGIN_CONTINUE;
336
337 show_login_menu( id );
338 return PLUGIN_HANDLED;
339}
340
341public message_ShowMenu( iMsgid, iDest, id ) {
342
343 if( g_iStatus [ id ] == LOGED )
344 return PLUGIN_CONTINUE;
345
346 static sMenuCode[ 33 ];
347 get_msg_arg_string( 4, sMenuCode, charsmax( sMenuCode ) );
348
349 if( containi( sMenuCode, "Team_Select" ) != -1 ) {
350 show_login_menu( id );
351 return PLUGIN_HANDLED;
352 }
353
354 return PLUGIN_CONTINUE;
355}
356
357public clcmd_changeteam ( id ) {
358
359 if ( g_iStatus [ id ] != LOGED ) {
360
361 show_login_menu( id );
362
363 return PLUGIN_HANDLED;
364 }
365
366 if ( g_iStatus [ id ] == LOGED ) {
367
368 if ( cs_get_user_team ( id ) == CS_TEAM_SPECTATOR || cs_get_user_team ( id ) == CS_TEAM_UNASSIGNED ) {
369
370 SM_Logueado ( id );
371
372 return PLUGIN_HANDLED
373 }
374 }
375
376 SM_Principal ( id );
377
378 return PLUGIN_HANDLED;
379}
380
381/* MENÚS */
382
383public SM_Principal ( id ) {
384
385 if ( g_iStatus [ id ] != LOGED ) {
386
387 show_login_menu ( id );
388
389 return PLUGIN_HANDLED
390 }
391
392 client_cmd ( id, "spk buttons/button3.wav" );
393
394 new sText [ 500 ];
395
396 new iLen; iLen = 0
397
398 iLen += formatex( sText, charsmax ( sText ) - iLen, "\r[BG]\y MENÚ PRINCIPAL^n^n" );
399
400 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r1. \wShop^n^n" );
401 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r2. \wHabilidades^n")
402 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r3. \wConfiguración^n^n")
403
404
405 //iLen += formatex( gText[ iLen ], charsmax( gText ) - iLen, "\%s9. \wAdministracion^n", is_user_admin( id ) ? "y" : "d")
406 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r0. \wSalir")
407
408 show_menu ( id, KEYS_PRINCIPAL, sText, - 1, "Principal")
409 return PLUGIN_HANDLED
410}
411
412public HM_Principal ( id, key ) {
413
414 switch ( key ) {
415
416 case 0: PrintText ( id, "%s Probando menús!", g_sCommunity );
417 case 1: PrintText ( id, "%s Probando menús!", g_sCommunity );
418 case 2: SM_Configuracion ( id );
419 }
420
421 return PLUGIN_HANDLED
422}
423
424public SM_Configuracion ( id ) {
425
426 if ( g_iStatus [ id ] != LOGED ) {
427
428 show_login_menu ( id );
429
430 return PLUGIN_HANDLED
431 }
432
433 client_cmd ( id, "spk buttons/button3.wav" );
434
435 new sText [ 500 ];
436
437 new iLen; iLen = 0
438
439 iLen += formatex( sText, charsmax ( sText ) - iLen, "\r[BG]\y CONFIGURACION^n^n" );
440
441 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r1. \wPerfil^n" );
442 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r2. \wEstadisticas^n")
443 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r3. \wConfigurar HUD^n^n")
444
445 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r0. \wSalir")
446
447 show_menu ( id, KEYS_CONFIGURACION, sText, - 1, "Configuracion")
448 return PLUGIN_HANDLED
449}
450
451public HM_Configuracion ( id, key ) {
452
453 switch ( key ) {
454
455 case 0: SM_Perfil ( id );
456 case 1: PrintText ( id, "%s Probando menús!", g_sCommunity );
457 case 2: PrintText ( id, "%s Probando menús!", g_sCommunity );
458 }
459
460 return PLUGIN_HANDLED
461}
462
463public SM_Perfil ( id ) {
464
465 if ( g_iStatus [ id ] != LOGED ) {
466
467 show_login_menu ( id );
468
469 return PLUGIN_HANDLED
470 }
471
472 client_cmd ( id, "spk buttons/button3.wav" );
473
474 new sText [ 1024 ];
475
476 new iLen; iLen = 0
477
478 iLen += formatex( sText, charsmax ( sText ) - iLen, "\r[BG]\y PERFIL^n^n" );
479
480 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r-. \wCuenta \d[\r %s\d ]\r | \wContraseña \d[\r %s\d ]^n^n", g_usuario [ id ], g_password [ id ] );
481
482 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r-. \wE-Mail \d[\r %s\d ]\r | \wADMIN \d[\r %s\d ]^n^n", g_sPlayerEmail [ id ], is_user_admin ( id ) ? "ACTIVADO" : "DESACTIVADO" );
483
484 for ( new i = 2; i < sizeof ( g_sSexos ); i++ ) {
485
486 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r-. \wSexo \d[\r %s\d ]^n^n", g_sSexos [ g_iSexo [ i ] ] );
487 }
488
489 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r0. \wSalir")
490
491 show_menu ( id, KEYS_PERFIL, sText, - 1, "Perfil")
492 return PLUGIN_HANDLED
493}
494
495public HM_Perfil ( id, key ) {
496
497 switch ( key ) {
498
499 }
500
501 return PLUGIN_HANDLED
502}
503
504public SM_Logueado ( id ) {
505
506 if ( g_iStatus [ id ] != LOGED ) {
507
508 show_login_menu ( id );
509
510 return PLUGIN_HANDLED
511 }
512
513 client_cmd ( id, "spk buttons/button3.wav" );
514
515 new sText [ 500 ];
516
517 new iLen; iLen = 0
518
519 iLen += formatex( sText, charsmax ( sText ) - iLen, "\r[BG]\y BIENVENIDO^n^n" );
520
521 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r1. \wEntrar a jugar^n" );
522 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r2. \wReglas^n")
523 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r3. \wCerrar sesión^n^n")
524
525 iLen += formatex( sText [ iLen ], charsmax ( sText ) - iLen, "\r0. \wSalir")
526
527 show_menu ( id, KEYS_LOGUEADO, sText, - 1, "Logueado")
528 return PLUGIN_HANDLED
529}
530
531public HM_Logueado ( id, key ) {
532
533 switch ( key ) {
534
535 case 0: {
536
537 PrintText ( 0, "%s El jugador !g%s!y inicio sesión.", g_sCommunity, g_sPlayerName [ id ] );
538 func_login_success ( id );
539 }
540 case 1: PrintText ( id, "%s Reglas", g_sCommunity );
541 case 2: {
542
543 PrintText ( 0, "%s El jugador !g%s!y cerro sesión.", g_sCommunity, g_sPlayerName [ id ] );
544 g_iStatus [ id ] = OFFLINE;
545
546 show_login_menu ( id );
547 }
548 }
549
550 return PLUGIN_HANDLED
551}
552
553public fw_RemoveEntities ( entity ) {
554
555 if ( !pev_valid ( entity ) )
556 return FMRES_IGNORED;
557
558 new classname [ 32 ];
559 pev ( entity, pev_classname, classname, sizeof classname - 1 );
560
561 for ( new i = 0; i < sizeof g_sEntities; i++ ) {
562
563 if ( equal ( classname, g_sEntities [ i ] ) ) {
564
565 engfunc ( EngFunc_RemoveEntity, entity );
566 return FMRES_SUPERCEDE;
567 }
568 }
569
570 return FMRES_IGNORED;
571}
572
573public message_ScreenFade ( iMessage,iDest,iEnt ) {
574
575 if ( ( get_msg_arg_int ( 4 ) == 255 && get_msg_arg_int ( 5 ) == 255 && get_msg_arg_int ( 6 ) == 255 ) && ( get_user_team ( iEnt ) == g_iFlashbangTeam ) )
576 return PLUGIN_HANDLED;
577
578 return PLUGIN_CONTINUE;
579}
580
581public fw_SetModel_Pre( iEnt,szModel [ ] ) {
582
583 if ( !pev_valid ( iEnt ) || !( szModel [ 7 ] == 'w' && szModel [ 9 ] == 'f' && szModel [ 14 ] == 'b' ) )
584 return FMRES_IGNORED;
585
586 set_pev ( iEnt, pev_iuser3, GRENADE_FLASH );
587 set_pev ( iEnt, pev_iuser4, get_user_team ( pev ( iEnt,pev_owner ) ) );
588
589 return FMRES_HANDLED;
590}
591
592public fw_GrenadeThink_Pre ( iEnt ) {
593
594 if ( !is_valid_ent ( iEnt ) || ( entity_get_float ( iEnt,EV_FL_dmgtime ) > get_gametime ( ) ) || ( entity_get_int ( iEnt,EV_INT_iuser3 ) != GRENADE_FLASH ) )
595 return HAM_IGNORED;
596
597 g_iFlashbangTeam = entity_get_int ( iEnt,EV_INT_iuser4 );
598
599 return HAM_IGNORED;
600}
601
602public Event_HLTV_New_Round ( ) {
603
604 for ( new i = 1; i <= g_maxplayers; i++ ) {
605
606 if ( g_iStatus [ i ] == LOGED && is_user_connected ( i ) )
607 guardar_datos ( i );
608 }
609
610 g_countdown = 11;
611 set_task( 1.0, "show_countdown", TASK_COUNTDOWN, _, _, "a", 11 );
612}
613
614public fw_PlayerSpawn ( id ) {
615
616 if ( !is_user_alive ( id ) )
617 return PLUGIN_HANDLED;
618
619 strip_user_weapons ( id );
620 give_item ( id , "weapon_knife" );
621
622 if ( g_countdown < 1 )
623 set_task ( 1.0, "giveItems", id );
624
625 switch ( cs_get_user_team ( id ) ) {
626
627 case CS_TEAM_CT: {
628
629 set_user_footsteps ( id, 0 );
630 }
631
632 case CS_TEAM_T: {
633
634 set_user_footsteps ( id, 1 );
635 }
636 }
637
638 return PLUGIN_HANDLED;
639}
640
641public fw_PlayerPreThink ( id ) {
642
643 if ( is_user_alive ( id ) ) {
644
645 if ( g_countdown >= 1 && get_user_team ( id ) == 2 ) {
646
647 set_pev ( id, pev_maxspeed, -1.0 );
648 set_pev ( id, pev_velocity, Float: { 0.0, 0.0, 0.0 } );
649 }
650 }
651}
652
653public show_countdown ( taskid ) {
654
655 g_countdown--;
656
657 if ( g_countdown > 0 ) {
658
659 new sSound [ 16 ];
660 num_to_word ( g_countdown, sSound, 15 );
661
662 client_cmd ( 0, "spk fvox/%s.wav", sSound );
663
664 set_hudmessage ( 0, 120, 220, -1.0, -1.0, 1, 0.0, 5.0, 0.1, 0.1, 3 );
665 ShowSyncHudMsg ( 0, g_iMsgSync [ 0 ] , " %i SECONDS LEFT TO HIDE ", g_countdown );
666
667 for ( new i = 0; i < g_maxplayers; i++ ) {
668
669 if ( !is_user_alive ( i ) || get_user_team ( i ) != 2 )
670 continue;
671
672 ScreenFade(i, 1.0, 0, 0, 0, 100)
673 }
674 }
675
676 else {
677
678 set_hudmessage ( 0, 120, 220, -1.0, -1.0, 1, 0.0, 5.0, 0.1, 0.1, 3 );
679 ShowSyncHudMsg ( 0, g_iMsgSync [ 0 ] , " THE GAME STARTED " );
680
681 remove_task ( taskid );
682
683 for ( new i = 0; i < g_maxplayers; i++ ) {
684
685 giveItems ( i );
686
687 if ( !is_user_alive ( i ) || get_user_team ( i ) != 2 )
688 continue;
689
690 engfunc ( EngFunc_SetClientMaxspeed, i, 250.0 );
691 set_pev ( i, pev_maxspeed, 250.0 );
692 }
693 }
694}
695
696public fw_CommandStart ( id, ucHandle, seed ) {
697
698 if ( !is_user_alive ( id ) ) return FMRES_IGNORED;
699
700 static clip, ammo;
701
702 if ( get_user_weapon ( id, clip, ammo ) != CSW_KNIFE )
703 return FMRES_IGNORED;
704
705 if ( get_user_team ( id ) == 1 ) {
706
707 new button = get_uc(ucHandle, UC_Buttons);
708
709 if ( button & IN_ATTACK )
710 button &= ~IN_ATTACK;
711 if ( button & IN_ATTACK2 )
712 button &= ~IN_ATTACK2;
713
714 set_uc ( ucHandle, UC_Buttons, button );
715
716 return FMRES_SUPERCEDE;
717 }
718
719 else if ( get_user_team ( id )== 2 ) {
720
721 new button = get_uc ( ucHandle, UC_Buttons );
722
723 if ( button & IN_ATTACK ) {
724
725 button &= ~IN_ATTACK;
726 button |= IN_ATTACK2;
727 }
728
729 set_uc ( ucHandle, UC_Buttons, button );
730
731 return FMRES_SUPERCEDE;
732 }
733
734 return FMRES_IGNORED;
735}
736
737public eventCurWeapon ( id ) {
738
739 if ( cs_get_user_team ( id ) == CS_TEAM_T ) {
740
741 new sModel[ 32 ];
742
743 pev ( id, pev_viewmodel2, sModel, 31 );
744
745 if ( equali( sModel, g_sKnifeModel_v, 0 ) ) {
746
747 set_pev ( id, pev_viewmodel2, g_sBlank );
748 }
749
750 pev ( id, pev_weaponmodel2, sModel, 31 );
751
752 if ( equali ( sModel, g_sKnifeModel_w, 0 ) ) {
753
754 set_pev ( id, pev_weaponmodel2, g_sBlank );
755 }
756 }
757
758 return PLUGIN_CONTINUE;
759}
760
761public switchTeams ( ) {
762
763 new Players [ 32 ], Num, id;
764
765 get_players ( Players, Num, "ch" );
766
767 for ( new i = 0; i < Num; i++ ) {
768
769 id = Players[ i ];
770
771 new CsTeams:Team;
772
773 Team = cs_get_user_team ( id );
774
775 if ( Team == CS_TEAM_T )
776 cs_set_user_team ( id, CS_TEAM_CT );
777 else if ( Team == CS_TEAM_CT )
778 cs_set_user_team ( id, CS_TEAM_T );
779 }
780}
781
782public giveItems ( id ) {
783
784 if ( !is_user_alive ( id ) )
785 return;
786
787 if ( get_user_team ( id ) == 1 ) {
788
789 give_item ( id, "weapon_hegrenade" );
790 give_item ( id, "weapon_flashbang" );
791 give_item ( id, "weapon_smokegrenade" );
792 }
793}
794
795public cmd_set ( id ) {
796
797 g_iNivel [ id ]++;
798
799 g_iFrags [ id ]++;
800
801 return PLUGIN_HANDLED;
802}
803
804public cmd_info ( id ) {
805
806 PrintText ( id, "%s NIVEL !g%d!t | !yFRAGS !g%d!y.", g_sCommunity, g_iNivel [ id ], g_iFrags [ id ] );
807
808 return PLUGIN_HANDLED;
809}
810
811public fw_killed ( victim, attacker, shouldgibs ) {
812
813 if ( !is_user_connected ( attacker ) || !is_user_connected ( victim ) || attacker == victim )
814 return;
815
816 g_iFrags [ attacker ]++;
817
818 ChequearNivel ( attacker );
819}
820
821public ChequearNivel ( id ) {
822
823 static Level
824 Level = g_iNivel [ id ];
825
826 while ( g_iFrags [ id ] >= SiguienteNivel ( g_iNivel [ id ] ) && g_iNivel [ id ] < 150 )
827 {
828 g_iFrags [ id ] = 0;
829 g_iNivel [ id ]++;
830 }
831
832 if ( Level < g_iNivel [ id ] ) {
833
834 PrintText ( 0, "%s El jugador !g%s!y subió al nivel !g%d!y.", g_sCommunity, g_sPlayerName [ id ], g_iNivel [ id ] )
835 return PLUGIN_HANDLED
836 }
837
838 return PLUGIN_HANDLED
839}
840
841/* SISTME DE CUENTAS */
842public show_login_menu( id ) {
843
844 new sText [ 128 ];
845
846 get_user_name ( id, g_sPlayerName [ id ], charsmax ( g_sPlayerName [ ] ) );
847
848 formatex ( sText, charsmax ( sText ), "\r[BG]\y SISTEMA DE CUENTAS^n^n\w Bienvenido \d [ \r%s\d ]\w.", g_sPlayerName [ id ] );
849
850 new menu = menu_create ( sText, "login_menu" );
851
852 menu_additem ( menu, "Registrar cuenta" );
853 menu_additem ( menu, "Iniciar sesión" );
854
855 menu_setprop ( menu, MPROP_EXIT, MEXIT_NEVER );
856
857 menu_display ( id, menu );
858
859 return PLUGIN_HANDLED;
860}
861
862public login_menu( id, menu, item ) {
863
864 switch( item ) {
865
866 case 0: client_cmd ( id, "messagemode CREAR_USUARIO" );
867 case 1: client_cmd ( id, "messagemode LOGUEAR_USUARIO" );
868 }
869
870 return PLUGIN_HANDLED;
871}
872
873public reg_usuario( id ) {
874 read_args( g_usuario[ id ], charsmax( g_usuario[ ] ) );
875 remove_quotes( g_usuario[ id ] );
876 trim( g_usuario[ id ] );
877
878 //md5( g_usuario[ id ], g_usuario[ id ] );
879
880 client_cmd( id, "messagemode CREAR_PASSWORD" );
881
882 return PLUGIN_HANDLED;
883}
884
885public reg_password( id ) {
886
887 read_args( g_password[ id ], charsmax( g_password[ ] ) );
888 remove_quotes( g_password[ id ] );
889 trim( g_password[ id ] );
890
891 client_cmd( id, "messagemode CREAR_EMAIL" );
892
893 return PLUGIN_HANDLED;
894}
895
896public reg_email( id ) {
897
898 read_args ( g_sPlayerEmail [ id ], charsmax ( g_sPlayerEmail [ ] ) );
899 remove_quotes ( g_sPlayerEmail [ id ] );
900 trim ( g_sPlayerEmail [ id ] );
901
902 new iArroba = contain ( g_sPlayerEmail[ id ], "@");
903 new bool:bValid = false
904
905 if(iArroba > 0 && strlen(g_sPlayerEmail[id] ) > 7 ) {
906
907 for ( new i = 0; i < sizeof ( g_sEmails ); i++) {
908
909 if (equali(g_sPlayerEmail[id][iArroba], g_sEmails[i])) {
910
911 //client_cmd(id, "spk buttons/button3.wav");
912
913 reg_sexo ( id );
914
915 bValid = true;
916 break;
917 }
918 }
919 }
920
921 if ( !bValid ) {
922
923 show_login_menu ( id );
924 PrintText ( id, "%s Dirección de correo electrónico inválido... Inténtalo nuevamente", g_sCommunity );
925
926 client_cmd(id, "spk buttons/button2.wav");
927 }
928
929 return PLUGIN_HANDLED;
930}
931
932public reg_sexo ( id ) {
933
934 new iMenu;
935
936 iMenu = menu_create ( "\r[BG]\y ELIGE TÚ SEXO", "hand_sexo" )
937
938 menu_additem ( iMenu, "Hombre" );
939 menu_additem ( iMenu, "Mujer" );
940 menu_additem ( iMenu, "Indefinido" );
941
942 menu_setprop ( iMenu, MPROP_EXIT, MEXIT_NEVER );
943
944 menu_display ( id, iMenu );
945}
946
947public hand_sexo ( id, menu, item ) {
948
949 if ( item == MENU_EXIT )
950 return PLUGIN_HANDLED;
951
952 // Le seteamos lo que eligio
953 g_iSexo [ item ] |= ( 1<< ( id - 1 ) );
954
955 client_cmd ( id, "spk buttons/button3.wav" );
956
957 PrintText ( id, "%s Has seleccionado tú sexo cómo !g%s!y.", g_sCommunity, g_sSexos [ item ] );
958
959 new szQuery[512], iData[2];
960
961 iData[0] = id;
962 iData[1] = REGISTRAR_CUENTA;
963
964 get_user_name( id, g_sPlayerName[ id ], charsmax( g_sPlayerName[ ] ) );
965
966 formatex( szQuery, charsmax( szQuery ), "INSERT INTO %s (Usuario, Password, Pj, email, Sexo) VALUES (^"%s^", ^"%s^", ^"%s^", ^"%s^", ^"%s^")", g_sDatos [ 4 ], g_usuario[ id ], g_password[ id ], g_sPlayerName[ id ], g_sPlayerEmail [ id ], g_sSexos [ item ] );
967 mysql_query(g_hTuple, "DataHandler", szQuery, iData, 2);
968
969 return PLUGIN_HANDLED;
970}
971
972public log_usuario( id ) {
973 read_args( g_usuario[ id ], charsmax( g_usuario[ ] ) );
974 remove_quotes( g_usuario[ id ] );
975 trim( g_usuario[ id ] );
976 //md5( g_usuario[ id ], g_usuario[ id ] );
977
978 client_cmd( id, "messagemode LOGUEAR_PASSWORD" );
979
980 return PLUGIN_HANDLED;
981}
982
983public log_password( id ) {
984 read_args( g_password[ id ], charsmax( g_password[ ] ) );
985 remove_quotes( g_password[ id ] );
986 trim( g_password[ id ] );
987 //md5( g_password[ id ], g_password[ id ] );
988
989 new szQuery[ 128 ], iData[ 2 ];
990
991 iData[ 0 ] = id;
992 iData[ 1 ] = LOGUEAR_CUENTA;
993
994 formatex( szQuery, charsmax( szQuery ), "SELECT * FROM %s WHERE Usuario=^"%s^" AND Password=^"%s^"", g_sDatos [ 4 ], g_usuario[ id ], g_password[ id ] );
995 mysql_query( g_hTuple, "DataHandler", szQuery, iData, 2 );
996
997 return PLUGIN_HANDLED;
998}
999
1000public guardar_datos( id ) {
1001
1002 new szQuery[ 128 ], iData[ 2 ];
1003
1004 iData[ 0 ] = id;
1005 iData[ 1 ] = GUARDAR_DATOS;
1006
1007 formatex( szQuery, charsmax( szQuery ), "UPDATE %s SET Nivel='%d', Frags='%d' WHERE id='%d'", g_sDatos [ 4 ], g_iNivel [ id ], g_iFrags [ id ], g_id[ id ] );
1008
1009 mysql_query( g_hTuple, "DataHandler", szQuery, iData, 2 );
1010}
1011
1012public DataHandler ( failstate, error [ ], error2, data[], size, Float:queuetime ) {
1013
1014 static id; id = data [ 0 ];
1015
1016 if ( !is_user_connected ( id ) )
1017 return;
1018
1019 switch ( failstate ) {
1020
1021 case TQUERY_CONNECT_FAILED: {
1022
1023 log_to_file ( "SQL_LOG_TQ.txt", "Error en la conexion al MySQL [%i]: %s", error2, error );
1024 return;
1025 }
1026 case TQUERY_QUERY_FAILED:
1027 log_to_file ( "SQL_LOG_TQ.txt", "Error en la consulta al MySQL [%i]: %s", error2, error );
1028 }
1029
1030 switch ( data [ 1 ] ) {
1031
1032 case REGISTRAR_CUENTA: {
1033
1034 if ( failstate < TQUERY_SUCCESS ) {
1035
1036 if ( containi ( error, "Usuario" ) != -1 )
1037 PrintText ( id, "%s El usuario ya existe.", g_sCommunity );
1038
1039 else if ( containi ( error, "Pj" ) != -1 )
1040 PrintText ( id, "%s El nombre de personaje esta en uso.", g_sCommunity );
1041 else
1042 PrintText ( id, "%s Error al crear la cuenta. Intente nuevamente.", g_sCommunity );
1043
1044 client_cmd ( id, "spk buttons/button10.wav" );
1045
1046 show_login_menu ( id );
1047 }
1048 else {
1049
1050 PrintText ( id, "%s Tu cuenta ha sido creada correctamente.", g_sCommunity );
1051
1052 new szQuery[ 128 ], iData[ 2 ];
1053
1054 iData [ 0 ] = id;
1055 iData [ 1 ] = CARGAR_DATOS;
1056
1057 formatex ( szQuery, charsmax ( szQuery ), "SELECT id FROM %s WHERE Usuario=^"%s^"", g_sDatos [ 4 ], g_usuario [ id ] );
1058 mysql_query ( g_hTuple, "DataHandler", szQuery, iData, 2 );
1059 }
1060
1061 }
1062 case LOGUEAR_CUENTA: {
1063
1064 if ( mysql_num_results ( ) ) {
1065
1066 g_id [ id ] = mysql_read_result ( 0 )
1067
1068 mysql_read_result (3, g_sPlayerName [ id ], charsmax ( g_sPlayerName[ ] ) )
1069 mysql_read_result (6, g_sPlayerEmail [ id ], charsmax ( g_sPlayerEmail[ ] ) )
1070 //mysql_read_result(7, g_sSexos [ id ], sizeof ( g_sSexos ) )
1071
1072 // Cargamos datos
1073 g_iNivel [ id ] = mysql_read_result ( 4 );
1074 g_iFrags [ id ] = mysql_read_result ( 5 );
1075
1076 PrintText ( id, "%s Bienvenido denuevo !g%s!y.", g_sCommunity, g_sPlayerName [ id ] );
1077
1078
1079 g_iStatus [ id ] = LOGED;
1080 SM_Logueado ( id );
1081 }
1082 else {
1083
1084 PrintText ( id, "%s Usuario o Contraseñ incorrecta.", g_sCommunity );
1085 client_cmd ( id, "spk buttons/button10.wav" );
1086
1087 show_login_menu ( id );
1088 }
1089 }
1090 case CARGAR_DATOS: {
1091
1092 if ( mysql_num_results ( ) ) {
1093
1094 g_id [ id ] = mysql_read_result ( 0 )
1095
1096 // Ponemos la exp en 0 para el nuevo usuario.
1097 g_iNivel [ id ] = 1;
1098 g_iFrags [ id ] = 0;
1099
1100 PrintText ( id, "%s Bienvenido !g%s!y eres la cuenta !g#%d!y.", g_sCommunity, g_sPlayerName [ id ], g_id [ id ] );
1101
1102 g_iStatus [ id ] = LOGED;
1103
1104 SM_Logueado ( id );
1105 }
1106 else {
1107
1108 PrintText ( id, "%s Error al cargar los datos, intente nuevamente.", g_sCommunity );
1109 show_login_menu ( id );
1110 }
1111 }
1112 case GUARDAR_DATOS: {
1113
1114 if ( failstate < TQUERY_SUCCESS )
1115 console_print ( id, "%s Error en el guardado de datos.", g_sCommunity );
1116
1117 else
1118 console_print ( id, "%s Datos guardados.", g_sCommunity );
1119 }
1120 }
1121}
1122
1123public func_login_success ( id ) {
1124
1125 engclient_cmd ( id, "jointeam", "5" );
1126 engclient_cmd ( id, "joinclass", "5" );
1127
1128 g_iStatus [ id ] = LOGED;
1129
1130 set_user_info ( id, "name", g_sPlayerName [ id ] );
1131}
1132
1133public FW_ClientUserInfoChanged ( id, szBuffer ) {
1134
1135 if ( is_user_connected ( id ) ) {
1136
1137 if( g_iStatus [ id ] == LOGED ) {
1138
1139 new szNewName [ 33 ];
1140
1141 engfunc ( EngFunc_InfoKeyValue, szBuffer, "name", szNewName, sizeof ( szNewName ) );
1142
1143 if ( !equal ( g_sPlayerName [ id ], szNewName ) ){
1144
1145 engfunc ( EngFunc_SetClientKeyValue, id, szBuffer, "name", g_sPlayerName [ id ] );
1146 client_cmd2 ( id, "name ^"%s^"", g_sPlayerName [ id ] );
1147 PrintText ( id, "%s Salà del servidor para cambiar de nombre.", g_sCommunity );
1148 }
1149 }
1150
1151 }
1152
1153 return FMRES_IGNORED;
1154}
1155
1156public client_putinserver ( id ) {
1157
1158 get_user_name ( id, g_sPlayerName [ id ], 31 );
1159}
1160
1161public client_disconnected ( id ) {
1162
1163 if ( g_iStatus [ id ] == LOGED ) {
1164
1165 guardar_datos ( id );
1166
1167 g_iStatus [ id ] = OFFLINE;
1168 }
1169
1170 g_usuario[ id ][ 0 ] = '^0';
1171 g_password[ id ][ 0 ] = '^0';
1172}
1173
1174public MySQLx_Init ( ) {
1175
1176 g_hTuple = mysql_makehost( g_sDatos [ 0 ], g_sDatos [ 1 ], g_sDatos [ 2 ], g_sDatos [ 3 ] )
1177
1178 if ( !g_hTuple ) {
1179
1180 log_to_file ( "SQL_ERROR.txt", "No se pudo conectar con la base de datos." );
1181 return pause ( "a" );
1182 }
1183
1184 return PLUGIN_CONTINUE;
1185}
1186
1187//public plugin_end ( ) mysql_free ( g_hTuple );
1188
1189stock PrintText ( const iIndex, const Text [ ], any:... ) {
1190
1191 new szText [ 192 ];
1192
1193 vformat ( szText, sizeof ( szText ), Text, 3 );
1194
1195
1196 replace_all ( szText, sizeof ( szText ), "!y", "^1" );
1197 replace_all ( szText, sizeof ( szText ), "!g", "^4" );
1198 replace_all ( szText, sizeof ( szText ), "!t", "^3" );
1199
1200 static iLen = sizeof ( szText );
1201
1202
1203 replace_all ( szText, iLen, "á", "á" );
1204 replace_all ( szText, iLen, "Ã", "Ã" );
1205 replace_all ( szText, iLen, "é", "é" );
1206 replace_all ( szText, iLen, "É", "É" );
1207 replace_all ( szText, iLen, "Ã", "Ã*" );
1208 replace_all ( szText, iLen, "Ã", "Ã" );
1209 replace_all ( szText, iLen, "ó", "ó" );
1210 replace_all ( szText, iLen, "Ó", "Ó" );
1211 replace_all ( szText, iLen, "ú", "ú" );
1212 replace_all ( szText, iLen, "Ú", "Ú" );
1213 replace_all ( szText, iLen, "ñ", "ñ" );
1214 replace_all ( szText, iLen, "Ñ", "Ñ" );
1215
1216
1217 message_begin ( iIndex ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, get_user_msgid ( "SayText" ), .player = iIndex );
1218 write_byte ( iIndex ? iIndex : 33 );
1219 write_string ( szText );
1220 message_end ( );
1221}
1222
1223stock ScreenFade(plr, Float:fDuration, red, green, blue, alpha) {
1224
1225 new i = plr ? plr : get_maxplayers();
1226 if( !i )
1227 {
1228 return 0;
1229 }
1230
1231 message_begin(plr ? MSG_ONE : MSG_ALL, get_user_msgid( "ScreenFade"), {0, 0, 0}, plr);
1232 write_short(floatround(4096.0 * fDuration, floatround_round));
1233 write_short(floatround(4096.0 * fDuration, floatround_round));
1234 write_short(4096);
1235 write_byte(red);
1236 write_byte(green);
1237 write_byte(blue);
1238 write_byte(alpha);
1239 message_end();
1240
1241 return 1;
1242}
1243
1244stock client_cmd2(id, const command[], {Float,Sql,Result,_}:...){
1245
1246
1247 new cmd[256];
1248 vformat(cmd, 255, command, 3);
1249
1250
1251
1252 if(id <= 0){
1253
1254 for(new id2 = 1; id2 <= 33;id2++){
1255 if(is_user_connected(id2)){
1256 message_begin( MSG_ONE, 51, _, id2 )
1257 write_byte( strlen(cmd) + 2 )
1258 write_byte( 10 )
1259 write_string( cmd )
1260 message_end()
1261 }
1262 }
1263 }else{
1264 message_begin( MSG_ONE, 51, _, id )
1265 write_byte( strlen(cmd) + 2 )
1266 write_byte( 10 )
1267 write_string( cmd )
1268 message_end()
1269 }
1270
1271}