· 7 years ago · Nov 04, 2018, 06:50 PM
1#include <amxmodx>
2#include <cstrike>
3#include <colorchat>
4#include <fun>
5#include <fakemeta>
6#include <hamsandwich>
7
8//#define USE_SQL
9
10#if defined USE_SQL
11 #include <sqlx>
12 #include <geoip>
13#endif
14
15#define KZ_LEVEL ADMIN_KICK
16#define MSG MSG_ONE_UNRELIABLE
17#define MAX_ENTITYS 900+15*32
18#define IsOnLadder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
19#define VERSION "2.31"
20
21#define SCOREATTRIB_NONE 0
22#define SCOREATTRIB_DEAD ( 1 << 0 )
23#define SCOREATTRIB_BOMB ( 1 << 1 )
24#define SCOREATTRIB_VIP ( 1 << 2 )
25
26
27new g_iPlayers[32], g_iNum, g_iPlayer
28new const g_szAliveFlags[] = "a"
29#define RefreshPlayersList() get_players(g_iPlayers, g_iNum, g_szAliveFlags)
30
31new const FL_ONGROUND2 = ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT )
32new const KZ_STARTFILE[] = "start.ini"
33new const KZ_STARTFILE_TEMP[] = "temp_start.ini"
34
35#if defined USE_SQL
36new Handle:g_SqlTuple
37new Handle:SqlConnection
38new g_Error[512]
39new kz_sql_host
40new kz_sql_user
41new kz_sql_pass
42new kz_sql_db
43new kz_sql_name
44new kz_sql_files
45#else
46new Float:Pro_Times[24]
47new Pro_AuthIDS[24][32]
48new Pro_Names[24][32]
49new Pro_Date[24][32]
50new Float:Noob_Tiempos[24]
51new Noob_AuthIDS[24][32]
52new Noob_Names[24][32]
53new Noob_Date[24][32]
54new Noob_CheckPoints[24]
55new Noob_GoChecks[24]
56new Noob_Weapon[24][32]
57#endif
58
59new Float:Checkpoints[33][2][3]
60new Float:timer_time[33]
61new Float:g_pausetime[33]
62new Float:antihookcheat[33]
63new Float:SpecLoc[33][3]
64new Float:NoclipPos[33][3]
65new Float:PauseOrigin[33][3]
66new Float:SavedStart[33][3]
67new hookorigin[33][3]
68new Float:DefaultStartPos[3]
69
70new Float:SavedTime[33]
71new SavedChecks[33]
72new SavedGoChecks[33]
73new SavedScout[33]
74new SavedOrigins[33][3]
75
76new bool:g_bCpAlternate[33]
77new bool:timer_started[33]
78new bool:IsPaused[33]
79new bool:WasPaused[33]
80new bool:firstspawn[33]
81new bool:canusehook[33]
82new bool:ishooked[33]
83new bool:user_has_scout[33]
84new bool:NightVisionUse[33]
85new bool:HealsOnMap
86new bool:gViewInvisible[33]
87new bool:gMarkedInvisible[33] = { true, ...};
88new bool:gWaterInvisible[33]
89new bool:gWaterEntity[MAX_ENTITYS]
90new bool:gWaterFound
91new bool:DefaultStart
92new bool:AutoStart[33]
93
94new Trie:g_tStarts
95new Trie:g_tStops;
96
97// Comando End
98new g_Mapname[64], g_Filename[128];
99
100new checknumbers[33]
101new gochecknumbers[33]
102new chatorhud[33]
103new ShowTime[33]
104new MapName[64]
105new Kzdir[128]
106new SavePosDir[128]
107new prefix[33]
108#if !defined USE_SQL
109new Topdir[128]
110#endif
111
112new kz_checkpoints
113new kz_cheatdetect
114new kz_spawn_mainmenu
115new kz_show_timer
116new kz_chatorhud
117new kz_hud_color
118new kz_chat_prefix
119new hud_message
120new kz_other_weapons
121new kz_maxspeedmsg
122new kz_drop_weapons
123new kz_remove_drops
124new kz_pick_weapons
125new kz_reload_weapons
126new kz_use_radio
127new kz_hook_prize
128new kz_hook_sound
129new kz_hook_speed
130new kz_pause
131new kz_noclip_pause
132new kz_nvg
133new kz_nvg_colors
134new kz_vip
135new kz_respawn_ct
136new kz_save_pos
137new kz_save_pos_gochecks
138new kz_semiclip
139new kz_semiclip_transparency
140new kz_spec_saves
141new kz_save_autostart
142new kz_top15_authid
143new Sbeam = 0
144
145new const SONIDO_WAV[] = { "ahye.wav" }
146
147new const other_weapons[8] =
148{
149 CSW_SCOUT, CSW_P90, CSW_FAMAS, CSW_SG552,
150 CSW_M4A1, CSW_M249, CSW_AK47, CSW_AWP
151}
152
153new const other_weapons_name[8][] =
154{
155 "weapon_scout", "weapon_p90", "weapon_famas", "weapon_sg552",
156 "weapon_m4a1", "weapon_m249", "weapon_ak47", "weapon_awp"
157}
158
159new const g_weaponsnames[][] =
160{
161 "", // NULL
162 "p228", "shield", "scout", "hegrenade", "xm1014", "c4",
163 "mac10", "aug", "smokegrenade", "elite", "fiveseven",
164 "ump45", "sg550", "galil", "famas", "usp", "glock18",
165 "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1",
166 "flashbang", "deagle", "sg552", "ak47", "knife", "p90",
167 "glock", "elites", "fn57", "mp5", "vest", "vesthelm",
168 "flash", "hegren", "sgren", "defuser", "nvgs", "primammo",
169 "secammo", "km45", "9x19mm", "nighthawk", "228compact",
170 "12gauge", "autoshotgun", "mp", "c90", "cv47", "defender",
171 "clarion", "krieg552", "bullpup", "magnum", "d3au1",
172 "krieg550"
173}
174
175new const g_block_commands[][]=
176{
177 "buy", "buyammo1", "buyammo2", "buyequip",
178 "cl_autobuy", "cl_rebuy", "cl_setautobuy", "cl_setrebuy"
179
180}
181
182#if defined USE_SQL
183enum
184{
185 TOP_NULL,
186 PRO_TOP,
187 NUB_TOP,
188 LAST_PRO10,
189 PRO_RECORDS,
190 PLAYERS_RANKING,
191 MAPS_STATISTIC
192}
193#endif
194
195// =================================================================================================
196
197public plugin_init()
198{
199 register_plugin("ProKreedz", VERSION, "nucLeaR & p4ddY")
200
201 kz_checkpoints = register_cvar("kz_checkpoints","1")
202 kz_cheatdetect = register_cvar("kz_cheatdetect","1")
203 kz_spawn_mainmenu = register_cvar("kz_spawn_mainmenu", "1")
204 kz_show_timer = register_cvar("kz_show_timer", "1")
205 kz_chatorhud = register_cvar("kz_chatorhud", "2")
206 kz_chat_prefix = register_cvar("kz_chat_prefix", "[KZ]")
207 kz_hud_color = register_cvar("kz_hud_color", "12 122 221")
208 kz_other_weapons = register_cvar("kz_other_weapons","1")
209 kz_drop_weapons = register_cvar("kz_drop_weapons", "0")
210 kz_remove_drops = register_cvar("kz_remove_drops", "1")
211 kz_pick_weapons = register_cvar("kz_pick_weapons", "0")
212 kz_reload_weapons = register_cvar("kz_reload_weapons", "0")
213 kz_maxspeedmsg = register_cvar("kz_maxspeedmsg","1")
214 kz_hook_prize = register_cvar("kz_hook_prize","1")
215 kz_hook_sound = register_cvar("kz_hook_sound","1")
216 kz_hook_speed = register_cvar("kz_hook_speed", "300.0")
217 kz_use_radio = register_cvar("kz_use_radio", "0")
218 kz_pause = register_cvar("kz_pause", "1")
219 kz_noclip_pause = register_cvar("kz_noclip_pause", "1")
220 kz_nvg = register_cvar("kz_nvg","1")
221 kz_nvg_colors = register_cvar("kz_nvg_colors","5 0 255")
222 kz_vip = register_cvar("kz_vip","1")
223 kz_respawn_ct = register_cvar("kz_respawn_ct", "1")
224 kz_semiclip = register_cvar("kz_semiclip", "1")
225 kz_semiclip_transparency = register_cvar ("kz_semiclip_transparency", "85")
226 kz_spec_saves = register_cvar("kz_spec_saves", "1")
227 kz_save_autostart = register_cvar("kz_save_autostart", "1")
228 kz_top15_authid = register_cvar("kz_top15_authid", "1")
229 kz_save_pos = register_cvar("kz_save_pos", "1")
230 kz_save_pos_gochecks = register_cvar("kz_save_pos_gochecks", "1")
231
232 #if defined USE_SQL
233 kz_sql_host = register_cvar("kz_sql_host", "") // Host of DB
234 kz_sql_user = register_cvar("kz_sql_user", "") // Username of DB
235 kz_sql_pass = register_cvar("kz_sql_pass", "", FCVAR_PROTECTED) // Password for DB user
236 kz_sql_db = register_cvar("kz_sql_db", "") // DB Name for the top 15
237 kz_sql_name = register_cvar("kz_sql_server", "") // Name of server
238 kz_sql_files = register_cvar("kz_sql_files", "") // Path of the PHP files
239 #endif
240
241 // comando end
242 kz_register_saycmd("end", "EndQuestion",0);
243 kz_register_saycmd("setend", "setEnd", KZ_LEVEL);
244 kz_register_saycmd("delend", "delEnd", KZ_LEVEL);
245 get_mapname(g_Mapname, 63);
246 format(g_Filename, 127, "addons/amxmodx/configs/end/%s.txt", g_Mapname);
247
248 register_clcmd("/cp","CheckPoint")
249 register_clcmd("drop", "BlockDrop")
250 register_clcmd("/gc", "GoCheck")
251 register_clcmd("+hook","hook_on",KZ_LEVEL)
252 register_clcmd("-hook","hook_off",KZ_LEVEL)
253 register_concmd("kz_hook","give_hook", KZ_LEVEL, "<name|#userid|steamid|@ALL> <on/off>")
254 register_concmd("nightvision","ToggleNVG")
255 register_clcmd("radio1", "BlockRadio")
256 register_clcmd("radio2", "BlockRadio")
257 register_clcmd("radio3", "BlockRadio")
258 register_clcmd("chooseteam", "kz_menu")
259 register_clcmd("/tp","GoCheck")
260
261 kz_register_saycmd("cp","CheckPoint",0)
262 kz_register_saycmd("chatorhud", "ChatHud", 0)
263 kz_register_saycmd("tt","ct",0)
264 kz_register_saycmd("gc", "GoCheck",0)
265 kz_register_saycmd("gocheck", "GoCheck",0)
266 kz_register_saycmd("god", "GodMode",0)
267 kz_register_saycmd("godmode", "GodMode", 0)
268 kz_register_saycmd("invis", "InvisMenu", 0)
269 kz_register_saycmd("kz", "kz_menu", 0)
270 kz_register_saycmd("menu","kz_menu", 0)
271 kz_register_saycmd("nc", "noclip", 0)
272 kz_register_saycmd("noclip", "noclip", 0)
273 kz_register_saycmd("noob10", "NoobTop_show", 0)
274 kz_register_saycmd("noob15", "NoobTop_show", 0)
275 kz_register_saycmd("nub10", "NoobTop_show", 0)
276 kz_register_saycmd("nub15", "NoobTop_show", 0)
277 kz_register_saycmd("pause", "Pause", 0)
278 kz_register_saycmd("pinvis", "cmdInvisible", 0)
279 kz_register_saycmd("pro10", "ProTop_show", 0)
280 kz_register_saycmd("pro15", "ProTop_show", 0)
281 kz_register_saycmd("reset", "reset_checkpoints", 0)
282 kz_register_saycmd("respawn", "goStart", 0)
283 kz_register_saycmd("savepos", "SavePos", 0)
284 kz_register_saycmd("scout", "cmdScout", 0)
285 kz_register_saycmd("setstart", "setStart", KZ_LEVEL)
286 kz_register_saycmd("showtimer", "ShowTimer_Menu", 0)
287 kz_register_saycmd("spec", "ct", 0)
288 kz_register_saycmd("start", "goStart", 0)
289 kz_register_saycmd("stuck", "Stuck", 0)
290 kz_register_saycmd("teleport", "GoCheck", 0)
291 kz_register_saycmd("timer", "ShowTimer_Menu", 0)
292 kz_register_saycmd("top15", "top15menu",0)
293 kz_register_saycmd("top10", "top15menu",0)
294 kz_register_saycmd("tp", "GoCheck",0)
295 kz_register_saycmd("usp", "cmdUsp", 0)
296 kz_register_saycmd("weapons", "weapons", 0)
297 kz_register_saycmd("guns", "weapons", 0)
298 kz_register_saycmd("winvis", "cmdWaterInvisible", 0)
299
300 #if defined USE_SQL
301 kz_register_saycmd("prorecords", "ProRecs_show", 0)
302 kz_register_saycmd("prorecs", "ProRecs_show", 0)
303 #endif
304
305 register_event("CurWeapon", "curweapon", "be", "1=1")
306 register_event( "StatusValue", "EventStatusValue", "b", "1>0", "2>0" );
307
308 register_forward(FM_AddToFullPack, "FM_client_AddToFullPack_Post", 1)
309
310 RegisterHam( Ham_Player_PreThink, "player", "Ham_CBasePlayer_PreThink_Post", 1)
311 RegisterHam( Ham_Use, "func_button", "fwdUse", 0)
312 RegisterHam( Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
313 RegisterHam( Ham_Touch, "weaponbox", "FwdSpawnWeaponbox" )
314 RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 )
315 RegisterHam( Ham_Touch, "weaponbox", "GroundWeapon_Touch")
316
317 register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" )
318 register_dictionary("prokreedz.txt")
319 get_pcvar_string(kz_chat_prefix, prefix, 31)
320 get_mapname(MapName, 63)
321 set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
322 set_task(0.5,"timer_task",2000,"",0,"ab")
323 #if defined USE_SQL
324 set_task(0.2, "plugin_sql")
325 #endif
326
327 new kreedz_cfg[128], ConfigDir[64]
328 get_configsdir( ConfigDir, 64)
329 formatex(Kzdir,128, "%s/kz", ConfigDir)
330 if( !dir_exists(Kzdir) )
331 mkdir(Kzdir)
332
333 #if !defined USE_SQL
334 formatex(Topdir,128, "%s/top15", Kzdir)
335 if( !dir_exists(Topdir) )
336 mkdir(Topdir)
337 #endif
338
339 formatex(SavePosDir, 128, "%s/savepos", Kzdir)
340 if( !dir_exists(SavePosDir) )
341 mkdir(SavePosDir)
342
343 formatex(kreedz_cfg,128,"%s/kreedz.cfg", Kzdir)
344
345 if( file_exists( kreedz_cfg ) )
346 {
347 server_exec()
348 server_cmd("exec %s",kreedz_cfg)
349 }
350
351 for(new i = 0; i < sizeof(g_block_commands) ; i++)
352 register_clcmd(g_block_commands[i], "BlockBuy")
353
354 g_tStarts = TrieCreate( )
355 g_tStops = TrieCreate( )
356
357 new const szStarts[ ][ ] =
358 {
359 "counter_start", "clockstartbutton", "firsttimerelay", "but_start", "counter_start_button",
360 "multi_start", "timer_startbutton", "start_timer_emi", "gogogo"
361 }
362
363 new const szStops[ ][ ] =
364 {
365 "counter_off", "clockstopbutton", "clockstop", "but_stop", "counter_stop_button",
366 "multi_stop", "stop_counter", "m_counter_end_emi"
367 }
368
369 for( new i = 0; i < sizeof szStarts; i++ )
370 TrieSetCell( g_tStarts, szStarts[ i ], 1 )
371
372 for( new i = 0; i < sizeof szStops; i++ )
373 TrieSetCell( g_tStops, szStops[ i ], 1 )
374}
375
376#if defined USE_SQL
377public plugin_sql()
378{
379 new host[64], user[64], pass[64], db[64]
380
381 get_pcvar_string(kz_sql_host, host, 63)
382 get_pcvar_string(kz_sql_user, user, 63)
383 get_pcvar_string(kz_sql_pass, pass, 63)
384 get_pcvar_string(kz_sql_db, db, 63)
385
386 g_SqlTuple = SQL_MakeDbTuple(host, user, pass, db)
387
388 new ErrorCode
389 SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
390
391 if(!SqlConnection)
392 {
393 server_print("[KZ] TOP15 SQL: Could not connect to SQL database.!")
394 log_amx("[KZ] TOP15 SQL: Could not connect to SQL database.")
395 return pause("a")
396 }
397
398 new createinto[1001]
399 formatex(createinto, 1000, "CREATE TABLE IF NOT EXISTS `kz_pro15` (`mapname` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL, `country` varchar(6) NOT NULL, `name` varchar(64) NOT NULL, `time` decimal(65,2) NOT NULL, `date` datetime NOT NULL, `weapon` varchar(64) NOT NULL, `server` varchar(64) NOT NULL)")
400 SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
401 formatex(createinto, 1000, "CREATE TABLE IF NOT EXISTS `kz_nub15` (`mapname` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL, `country` varchar(6) NOT NULL, `name` varchar(64) NOT NULL, `time`decimal(65,2) NOT NULL, `date` datetime NOT NULL, `weapon` varchar(64) NOT NULL, `server` varchar(64) NOT NULL, `checkpoints` real NOT NULL, `gocheck` real NOT NULL)")
402 SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
403
404 return PLUGIN_CONTINUE
405}
406
407public QueryHandle(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
408{
409 if( iFailState != TQUERY_SUCCESS )
410 {
411 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
412 ColorChat(0, GREEN, "[KZ]^x01: Warning the SQL Tops can not be saved.")
413 }
414
415 server_print("[KZ] Server Sending Info to SQL Server")
416
417 return PLUGIN_CONTINUE
418}
419#endif
420
421public plugin_precache()
422{
423 hud_message = CreateHudSyncObj()
424 RegisterHam( Ham_Spawn, "func_door", "FwdHamDoorSpawn", 1 )
425 precache_sound("weapons/xbow_hit2.wav")
426 Sbeam = precache_model("sprites/laserbeam.spr")
427 precache_sound(SONIDO_WAV)
428}
429
430public plugin_cfg()
431{
432 #if !defined USE_SQL
433 for (new i = 0 ; i < 15; ++i)
434 {
435 Pro_Times[i] = 999999999.00000;
436 Noob_Tiempos[i] = 999999999.00000;
437 }
438
439 read_pro15()
440 read_Noob15()
441 #endif
442
443 new startcheck[100], data[256], map[64], x[13], y[13], z[13];
444 formatex(startcheck, 99, "%s/%s", Kzdir, KZ_STARTFILE)
445 new f = fopen(startcheck, "rt" )
446 while( !feof( f ) )
447 {
448 fgets( f, data, sizeof data - 1 )
449 parse( data, map, 63, x, 12, y, 12, z, 12)
450
451 if( equali( map, MapName ) )
452 {
453 DefaultStartPos[0] = str_to_float(x)
454 DefaultStartPos[1] = str_to_float(y)
455 DefaultStartPos[2] = str_to_float(z)
456
457 DefaultStart = true
458 break;
459 }
460 }
461 fclose(f)
462
463 new ent = -1;
464 while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_water") ) != 0 )
465 {
466 if( !gWaterFound )
467 {
468 gWaterFound = true;
469 }
470
471 gWaterEntity[ent] = true;
472 }
473
474 ent = -1;
475 while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_illusionary") ) != 0 )
476 {
477 if( pev( ent, pev_skin ) == CONTENTS_WATER )
478 {
479 if( !gWaterFound )
480 {
481 gWaterFound = true;
482 }
483
484 gWaterEntity[ent] = true;
485 }
486 }
487
488 ent = -1;
489 while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_conveyor") ) != 0 )
490 {
491 if( pev( ent, pev_spawnflags ) == 3 )
492 {
493 if( !gWaterFound )
494 {
495 gWaterFound = true;
496 }
497
498 gWaterEntity[ent] = true;
499 }
500 }
501}
502
503public client_command(id)
504{
505
506 new sArg[13];
507 if( read_argv(0, sArg, 12) > 11 )
508 {
509 return PLUGIN_CONTINUE;
510 }
511
512 for( new i = 0; i < sizeof(g_weaponsnames); i++ )
513 {
514 if( equali(g_weaponsnames[i], sArg, 0) )
515 {
516 return PLUGIN_HANDLED;
517 }
518 }
519 return PLUGIN_CONTINUE;
520}
521
522// =================================================================================================
523// Comando End
524// =================================================================================================
525public EndQuestion(id)
526{
527 if (timer_started[id])
528 {
529 MenuEnd(id)
530 }
531 else
532 {
533 goEnd(id)
534 }
535}
536
537
538public MenuEnd(id)
539{
540 new gMenu = menu_create("\r[KZ] \wTiempo Corriendo,deseas ir al final?^n\dSe reiniciará tu tiempo y Checkpoints", "handlerMenuEnd")
541
542 menu_additem(gMenu, "\wSi", "1")
543 menu_additem(gMenu, "\wNo", "2")
544
545 menu_display(id, gMenu, 0)
546}
547
548public handlerMenuEnd(id, menu, item)
549{
550 if ( item == MENU_EXIT )
551 {
552 menu_destroy(menu)
553 return PLUGIN_HANDLED;
554 }
555 switch(item)
556 {
557 case 0:
558 {
559 goEnd(id)
560 }
561 case 1:
562 {
563 ColorChat(id, GREEN, "[KZ]^x01 Puedes seguir con el mapa.")
564 }
565 }
566 return PLUGIN_HANDLED;
567}
568
569public goEnd(id)
570{
571 reset_checkpoints(id)
572
573 if (file_exists(g_Filename))
574 {
575 new temp[64], pos[3], str1[13], str2[13], str3[13];
576 new file = fopen(g_Filename, "rt");
577 while(!feof(file))
578 {
579 fgets(file, temp, 63);
580 parse(temp, str1, 12, str2, 12, str3, 12);
581
582 pos[0] = str_to_num(str1);
583 pos[1] = str_to_num(str2);
584 pos[2] = str_to_num(str3);
585
586 engfunc(EngFunc_SetOrigin, id, pos);
587 }
588 kz_chat(id, "%L", id, "KZ_TO_END")
589 fclose(file);
590 }
591 else
592 {
593 kz_chat(id, "%L", id, "KZ_TO_NOEND")
594 }
595}
596
597public setEnd(id)
598{
599 if (! (get_user_flags( id ) & KZ_LEVEL ))
600 {
601 kz_chat(id, "%L", id, "KZ_NO_ACCESS")
602 return PLUGIN_HANDLED
603 }
604
605 if (file_exists(g_Filename))
606 {
607 ColorChat(id, GREEN, "%s^x01 Este mapa ya tiene seteado,Escribe ^x04 /delend ^x01para borrar.", prefix)
608 }
609 else
610 {
611 new i[3], temp[128];
612 pev(id, pev_origin, i);
613 format(temp, 127, "%d %d %d", i[0], i[1], i[2]);
614 write_file(g_Filename, temp, 0);
615 ColorChat(id, GREEN, "%s^x01 Posición final seteada con éxito.", prefix)
616 }
617 return PLUGIN_HANDLED;
618}
619
620public delEnd(id)
621{
622 if (! (get_user_flags( id ) & KZ_LEVEL ))
623 {
624 kz_chat(id, "%L", id, "KZ_NO_ACCESS")
625 return PLUGIN_HANDLED
626 }
627
628 if (file_exists(g_Filename))
629 {
630 delete_file(g_Filename);
631 ColorChat(id, GREEN, "%s^x01 Posición final borrada con éxito.", prefix)
632 }
633 else
634 {
635 ColorChat(id, GREEN, "%s^x01 El mapa no tiene seteado.", prefix)
636 }
637 return PLUGIN_HANDLED;
638}
639// =================================================================================================
640// Global Functions
641// =================================================================================================
642
643public Pause(id)
644{
645
646 if (get_pcvar_num(kz_pause) == 0)
647 {
648 kz_chat(id, "%L", id, "KZ_PAUSE_DISABLED")
649
650 return PLUGIN_HANDLED
651 }
652
653 if(! is_user_alive(id) )
654 {
655 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
656
657 return PLUGIN_HANDLED
658 }
659
660
661 if(!IsPaused[id])
662 {
663 if(! timer_started[id])
664 {
665 kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
666 return PLUGIN_HANDLED
667 }
668
669 g_pausetime[id] = get_gametime() - timer_time[id]
670 timer_time[id] = 0.0
671 IsPaused[id] = true
672 kz_chat(id, "%L", id, "KZ_PAUSE_ON")
673 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
674 pev(id, pev_origin, PauseOrigin[id])
675
676 }
677 else
678 {
679 if(timer_started[id])
680 {
681 kz_chat(id, "%L", id, "KZ_PAUSE_OFF")
682 if(get_user_noclip(id))
683 noclip(id)
684 timer_time[id] = get_gametime() - g_pausetime[id]
685 }
686 IsPaused[id] = false
687 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
688 }
689
690 return PLUGIN_HANDLED
691}
692
693public timer_task()
694{
695 if ( get_pcvar_num(kz_show_timer) > 0 )
696 {
697 new Alive[32], Dead[32], alivePlayers, deadPlayers;
698 get_players(Alive, alivePlayers, "ach")
699 get_players(Dead, deadPlayers, "bch")
700 for(new i=0;i<alivePlayers;i++)
701 {
702 if( timer_started[Alive[i]])
703 {
704 new Float:kreedztime = get_gametime() - (IsPaused[Alive[i]] ? get_gametime() - g_pausetime[Alive[i]] : timer_time[Alive[i]])
705
706 if( ShowTime[Alive[i]] == 1 )
707 {
708 new colors[12], r[4], g[4], b[4];
709 new imin = floatround(kreedztime / 60.0,floatround_floor)
710 new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
711 get_pcvar_string(kz_hud_color, colors, 11)
712 parse(colors, r, 3, g, 3, b, 4)
713
714 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, 1)
715 show_hudmessage(Alive[i], "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec,checknumbers[Alive[i]], gochecknumbers[Alive[i]], IsPaused[Alive[i]] ? "| *Paused*" : "")
716 }
717 else
718 if( ShowTime[Alive[i]] == 2 )
719 {
720 kz_showtime_roundtime(Alive[i], floatround(kreedztime))
721 }
722 }
723
724 }
725 for(new i=0;i<deadPlayers;i++)
726 {
727 new specmode = pev(Dead[i], pev_iuser1)
728 if(specmode == 2 || specmode == 4)
729 {
730 new target = pev(Dead[i], pev_iuser2)
731 if(target != Dead[i])
732 if(is_user_alive(target) && timer_started[target])
733 {
734 new name[32], colors[12], r[4], g[4], b[4];
735 get_user_name (target, name, 31)
736
737 new Float:kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
738 new imin = floatround(kreedztime / 60.0,floatround_floor)
739 new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
740
741 get_pcvar_string(kz_hud_color, colors, 11)
742 parse(colors, r, 3, g, 3, b, 4)
743
744 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), -1.0, 0.46, 0, 0.0, 1.0, 0.0, 0.0, 1)
745 show_hudmessage(Dead[i], "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec, checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")
746 }
747 }
748 }
749 }
750}
751
752// ============================ Block Commands ================================
753
754
755public BlockRadio(id)
756{
757 if (get_pcvar_num(kz_use_radio) == 1)
758 return PLUGIN_CONTINUE
759 return PLUGIN_HANDLED
760}
761
762public BlockDrop(id)
763{
764 if (get_pcvar_num(kz_drop_weapons) == 1)
765 return PLUGIN_CONTINUE
766 return PLUGIN_HANDLED
767}
768
769public BlockBuy(id)
770{
771 return PLUGIN_HANDLED
772}
773
774public CmdRespawn(id)
775{
776 if ( get_user_team(id) == 3 )
777 return PLUGIN_HANDLED
778 else
779 ExecuteHamB(Ham_CS_RoundRespawn, id)
780
781 return PLUGIN_HANDLED
782}
783
784public ChatHud(id)
785{
786 if(get_pcvar_num(kz_chatorhud) == 0)
787 {
788 ColorChat(id, GREEN, "%s^x01 %L", id, "KZ_CHECKPOINT_OFF", prefix)
789 return PLUGIN_HANDLED
790 }
791 if(chatorhud[id] == -1)
792 ++chatorhud[id];
793
794 ++chatorhud[id];
795
796 if(chatorhud[id] == 3)
797 chatorhud[id] = 0;
798 else
799 kz_chat(id, "%L", id, "KZ_CHATORHUD", chatorhud[id] == 1 ? "Chat" : "HUD")
800
801 return PLUGIN_HANDLED
802}
803
804public ct(id)
805{
806 new CsTeams:team = cs_get_user_team(id)
807 if (team == CS_TEAM_T)
808 {
809 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && timer_started[id] )
810 return PLUGIN_HANDLED
811
812 if (get_pcvar_num(kz_spec_saves) == 1)
813 {
814 pev(id, pev_origin, SpecLoc[id])
815
816 if ( timer_started[id] )
817 {
818 if ( IsPaused[id] )
819 {
820 Pause(id)
821 WasPaused[id]=true
822 }
823
824 g_pausetime[id] = get_gametime() - timer_time[id]
825 timer_time[id] = 0.0
826 kz_chat(id, "%L", id, "KZ_PAUSE_ON")
827 }
828 }
829
830 if(gViewInvisible[id])
831 gViewInvisible[id] = false
832
833 cs_set_user_team(id,CS_TEAM_SPECTATOR)
834 set_pev(id, pev_solid, SOLID_NOT)
835 set_pev(id, pev_movetype, MOVETYPE_FLY)
836 set_pev(id, pev_effects, EF_NODRAW)
837 set_pev(id, pev_deadflag, DEAD_DEAD)
838 }
839 else
840 {
841 cs_set_user_team(id,CS_TEAM_T)
842 set_pev(id, pev_effects, 0)
843 set_pev(id, pev_movetype, MOVETYPE_WALK)
844 set_pev(id, pev_deadflag, DEAD_NO)
845 set_pev(id, pev_takedamage, DAMAGE_AIM)
846 CmdRespawn(id)
847 give_item(id,"weapon_knife")
848 give_item(id,"weapon_usp")
849 cs_set_user_bpammo(id, CSW_USP, 36)
850
851 if (get_pcvar_num(kz_spec_saves) == 1)
852 {
853 set_pev(id, pev_origin, SpecLoc[id])
854 if ( timer_started [id] )
855 timer_time[id] = get_gametime() - g_pausetime[id] + timer_time[id]
856 if( WasPaused[id] )
857 {
858 Pause(id)
859 WasPaused[id]=false
860 }
861 }
862 }
863 return PLUGIN_HANDLED
864}
865
866
867//=================== Weapons ==============
868public curweapon(id)
869{
870/*
871 if(get_pcvar_num(kz_maxspeedmsg) == 1 && is_user_alive(id))
872 {
873 new clip, ammo, speed,
874 switch(get_user_weapon(id,clip,ammo))
875 {
876 case CSW_SCOUT: speed = 260
877 case CSW_C4, CSW_P228, CSW_MAC10, CSW_MP5NAVY, CSW_USP, CSW_TMP, CSW_FLASHBANG, CSW_DEAGLE, CSW_GLOCK18, CSW_SMOKEGRENADE, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_HEGRENADE, CSW_KNIFE: speed = 250
878 case CSW_P90: speed = 245
879 case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS: speed = 240
880 case CSW_SG552: speed = 235
881 case CSW_M3, CSW_M4A1: speed= 230
882 case CSW_AK47: speed = 221
883 case CSW_M249: speed = 220
884 case CSW_G3SG1, CSW_SG550, CSW_AWP: speed = 210
885 }
886 kz_hud_message(id,"%L",id, "KZ_WEAPONS_SPEED",speed)
887 }
888 */
889 static last_weapon[33];
890 static weapon_active, weapon_num
891 weapon_active = read_data(1)
892 weapon_num = read_data(2)
893
894 if( ( weapon_num != last_weapon[id] ) && weapon_active && get_pcvar_num(kz_maxspeedmsg) == 1)
895 {
896 last_weapon[id] = weapon_num;
897
898 static Float:maxspeed;
899 pev(id, pev_maxspeed, maxspeed );
900
901 if( maxspeed < 0.0 )
902 maxspeed = 250.0;
903
904 kz_hud_message(id,"%L",id, "KZ_WEAPONS_SPEED",floatround( maxspeed, floatround_floor ));
905 }
906 return PLUGIN_HANDLED
907}
908
909public weapons(id)
910{
911 if(!is_user_alive(id))
912 {
913 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
914 return PLUGIN_HANDLED
915 }
916
917 if(get_pcvar_num(kz_other_weapons) == 0)
918 {
919 kz_chat(id, "%L", id, "KZ_OTHER_WEAPONS_ZERO")
920 return PLUGIN_HANDLED
921 }
922
923 if (timer_started[id])
924 {
925 kz_chat(id, "%L", id, "KZ_WEAPONS_IN_RUN")
926 return PLUGIN_HANDLED
927 }
928
929 for(new i = 0; i < 8; i++)
930 if( !user_has_weapon(id, other_weapons[i]) )
931 {
932 new item;
933 item = give_item(id, other_weapons_name[i] );
934 cs_set_weapon_ammo(item, 0);
935 }
936
937 if( !user_has_weapon(id, CSW_USP) )
938 cmdUsp(id)
939
940 return PLUGIN_HANDLED
941}
942
943
944// ========================= Scout =======================
945public cmdScout(id)
946{
947 if (timer_started[id])
948 user_has_scout[id] = true
949
950 strip_user_weapons(id)
951 give_item(id,"weapon_usp")
952 give_item(id,"weapon_knife")
953 if( !user_has_weapon(id, CSW_SCOUT))
954 give_item(id,"weapon_scout")
955
956 return PLUGIN_HANDLED
957}
958
959public cmdUsp(id)
960{
961 give_item(id,"weapon_usp")
962 give_item(id,"weapon_knife")
963
964 return PLUGIN_HANDLED
965}
966
967// ========================== Start location =================
968
969public goStart(id)
970{
971 if( !is_user_alive( id ) )
972 {
973 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
974 return PLUGIN_HANDLED
975 }
976
977 if (IsPaused[id])
978 {
979 kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
980 return PLUGIN_HANDLED
981 }
982
983 if(get_pcvar_num(kz_save_autostart) == 1 && AutoStart [id] )
984 {
985 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
986 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
987 set_pev(id, pev_origin, SavedStart [id] )
988
989 kz_chat(id, "%L", id, "KZ_START")
990 }
991 else if ( DefaultStart )
992 {
993 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
994 set_pev(id, pev_origin, DefaultStartPos)
995
996 kz_chat(id, "%L", id, "KZ_START")
997 }
998 else
999 {
1000 kz_chat(id, "%L", id, "KZ_NO_START")
1001
1002 CmdRespawn(id)
1003 }
1004
1005 return PLUGIN_HANDLED
1006}
1007
1008public setStart(id)
1009{
1010 if (! (get_user_flags( id ) & KZ_LEVEL ))
1011 {
1012 kz_chat(id, "%L", id, "KZ_NO_ACCESS")
1013 return PLUGIN_HANDLED
1014 }
1015
1016 new Float:origin[3]
1017 pev(id, pev_origin, origin)
1018 kz_set_start(MapName, origin)
1019 AutoStart[id] = false;
1020 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_SET_START")
1021
1022 return PLUGIN_HANDLED
1023}
1024
1025// ========= Respawn CT if dies ========
1026
1027public Ham_CBasePlayer_Killed_Post(id)
1028{
1029 if(get_pcvar_num(kz_respawn_ct) == 1)
1030 {
1031 if( cs_get_user_team(id) == CS_TEAM_T )
1032 {
1033 set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
1034 cs_set_user_deaths(id, 0)
1035 set_user_frags(id, 0)
1036 }
1037 }
1038}
1039
1040
1041// ============================= NightVision ================================================
1042
1043public ToggleNVG(id)
1044{
1045
1046 if( get_pcvar_num(kz_nvg) == 0 || !is_user_alive(id))
1047 return PLUGIN_CONTINUE;
1048
1049 if ( NightVisionUse[id] )
1050 StopNVG(id)
1051 else
1052 StartNVG(id)
1053
1054 return PLUGIN_HANDLED
1055}
1056
1057public StartNVG(id)
1058{
1059 emit_sound(id,CHAN_ITEM,"items/nvg_on.wav",1.0,ATTN_NORM,0,PITCH_NORM)
1060 set_task(0.1,"RunNVG",id+111111,_,_,"b")
1061 NightVisionUse[id] = true;
1062
1063 return PLUGIN_HANDLED
1064}
1065
1066public StopNVG(id)
1067{
1068 emit_sound(id,CHAN_ITEM,"items/nvg_off.wav",1.0,ATTN_NORM,0,PITCH_NORM)
1069 remove_task(id+111111)
1070 NightVisionUse[id] = false;
1071
1072 return PLUGIN_HANDLED
1073}
1074
1075
1076public RunNVG(taskid)
1077{
1078 new id = taskid - 111111
1079
1080 if (!is_user_alive(id)) return
1081
1082 new origin[3]
1083 get_user_origin(id,origin,3)
1084
1085 new color[17];
1086 get_pcvar_string(kz_nvg_colors,color,16);
1087
1088 new iRed[5], iGreen[7], iBlue[5]
1089 parse(color,iRed,4,iGreen ,6,iBlue,4)
1090
1091 message_begin(MSG, SVC_TEMPENTITY, _, id)
1092 write_byte(TE_DLIGHT)
1093 write_coord(origin[0])
1094 write_coord(origin[1])
1095 write_coord(origin[2])
1096 write_byte(80)
1097 write_byte(str_to_num(iRed))
1098 write_byte(str_to_num(iGreen))
1099 write_byte(str_to_num(iBlue))
1100 write_byte(2)
1101 write_byte(0)
1102 message_end()
1103}
1104
1105// ============================ Hook ==============================================================
1106
1107public give_hook(id)
1108{
1109 if (!( get_user_flags( id ) & KZ_LEVEL ))
1110 return PLUGIN_HANDLED
1111
1112 new szarg1[32], szarg2[8], bool:mode
1113 read_argv(1,szarg1,32)
1114 read_argv(2,szarg2,32)
1115 if(equal(szarg2,"on"))
1116 mode = true
1117
1118 if(equal(szarg1,"@ALL"))
1119 {
1120 new Alive[32], alivePlayers
1121 get_players(Alive, alivePlayers, "ach")
1122 for(new i;i<alivePlayers;i++)
1123 {
1124 canusehook[i] = mode
1125 if(mode)
1126 ColorChat(i, GREEN, "%s^x01, %L.", prefix, i, "KZ_HOOK")
1127 }
1128 }
1129 else
1130 {
1131 new pid = find_player("bl",szarg1);
1132 if(pid > 0)
1133 {
1134 canusehook[pid] = mode
1135 if(mode)
1136 {
1137 ColorChat(pid, GREEN, "%s^x01 %L.", prefix, pid, "KZ_HOOK")
1138 }
1139 }
1140 }
1141
1142 return PLUGIN_HANDLED
1143}
1144
1145public hook_on(id)
1146{
1147 if( !canusehook[id] && !( get_user_flags( id ) & ADMIN_LEVEL_H ) || !is_user_alive(id) )
1148 return PLUGIN_HANDLED
1149
1150 if (IsPaused[id])
1151 {
1152 kz_chat(id, "%L", id, "KZ_HOOK_PAUSE")
1153 return PLUGIN_HANDLED
1154 }
1155
1156 detect_cheat(id,"Hook")
1157 get_user_origin(id,hookorigin[id],3)
1158 ishooked[id] = true
1159 antihookcheat[id] = get_gametime()
1160
1161 if (get_pcvar_num(kz_hook_sound) == 1)
1162 emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
1163
1164 set_task(0.1,"hook_task",id,"",0,"ab")
1165 hook_task(id)
1166
1167 return PLUGIN_HANDLED
1168}
1169
1170public hook_off(id)
1171{
1172 remove_hook(id)
1173
1174 return PLUGIN_HANDLED
1175}
1176
1177public hook_task(id)
1178{
1179 if(!is_user_connected(id) || !is_user_alive(id))
1180 remove_hook(id)
1181
1182 remove_beam(id)
1183 draw_hook(id)
1184
1185 new origin[3], Float:velocity[3]
1186 get_user_origin(id,origin)
1187 new distance = get_distance(hookorigin[id],origin)
1188 velocity[0] = (hookorigin[id][0] - origin[0]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
1189 velocity[1] = (hookorigin[id][1] - origin[1]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
1190 velocity[2] = (hookorigin[id][2] - origin[2]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
1191
1192 set_pev(id,pev_velocity,velocity)
1193}
1194
1195public draw_hook(id)
1196{
1197 message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
1198 write_byte(1) // TE_BEAMENTPOINT
1199 write_short(id) // entid
1200 write_coord(hookorigin[id][0]) // origin
1201 write_coord(hookorigin[id][1]) // origin
1202 write_coord(hookorigin[id][2]) // origin
1203 write_short(Sbeam) // sprite index
1204 write_byte(0) // start frame
1205 write_byte(0) // framerate
1206 write_byte(random_num(1,100)) // life
1207 write_byte(random_num(1,20)) // width
1208 write_byte(random_num(1,0)) // noise
1209 write_byte(random_num(1,255)) // r
1210 write_byte(random_num(1,255)) // g
1211 write_byte(random_num(1,255)) // b
1212 write_byte(random_num(1,500)) // brightness
1213 write_byte(random_num(1,200)) // speed
1214 message_end()
1215}
1216
1217public remove_hook(id)
1218{
1219 if(task_exists(id))
1220 remove_task(id)
1221 remove_beam(id)
1222 ishooked[id] = false
1223}
1224
1225public remove_beam(id)
1226{
1227 message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
1228 write_byte(99) // TE_KILLBEAM
1229 write_short(id)
1230 message_end()
1231}
1232
1233
1234//============================ VIP In ScoreBoard =================================================
1235
1236public MessageScoreAttrib( iMsgID, iDest, iReceiver )
1237{
1238 if( get_pcvar_num(kz_vip) )
1239 {
1240 new iPlayer = get_msg_arg_int( 1 )
1241 if( is_user_alive( iPlayer ) && ( get_user_flags( iPlayer ) & KZ_LEVEL ) )
1242 {
1243 set_msg_arg_int( 2, ARG_BYTE, SCOREATTRIB_VIP );
1244 }
1245 }
1246}
1247
1248public EventStatusValue( const id )
1249{
1250
1251 new szMessage[ 34 ], Target, aux
1252 get_user_aiming(id, Target, aux)
1253 if (is_user_alive(Target))
1254 {
1255 formatex( szMessage, 33, "1 %s: %%p2", get_user_flags( Target ) & KZ_LEVEL ? "VIP" : "Player" )
1256 message_begin( MSG, get_user_msgid( "StatusText" ) , _, id )
1257 write_byte( 0 )
1258 write_string( szMessage )
1259 message_end( )
1260 }
1261}
1262
1263public detect_cheat(id,reason[])
1264{
1265 if(timer_started[id] && get_pcvar_num(kz_cheatdetect) == 1)
1266 {
1267 timer_started[id] = false
1268 if(IsPaused[id])
1269 {
1270 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1271 IsPaused[id] = false
1272 }
1273 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
1274 kz_showtime_roundtime(id, 0)
1275 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_CHEAT_DETECT", reason)
1276 }
1277}
1278
1279// =================================================================================================
1280// Cmds
1281// =================================================================================================
1282
1283public CheckPoint(id)
1284{
1285
1286 if( !is_user_alive( id ) )
1287 {
1288 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1289 return PLUGIN_HANDLED
1290 }
1291
1292 if(get_pcvar_num(kz_checkpoints) == 0)
1293 {
1294 kz_chat(id, "%L", id, "KZ_CHECKPOINT_OFF")
1295 return PLUGIN_HANDLED
1296 }
1297
1298 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && !IsOnLadder(id))
1299 {
1300 kz_chat(id, "%L", id, "KZ_CHECKPOINT_AIR")
1301 return PLUGIN_HANDLED
1302 }
1303
1304 if( IsPaused[id] )
1305 {
1306 kz_chat(id, "%L", id, "KZ_CHECKPOINT_PAUSE")
1307 return PLUGIN_HANDLED
1308 }
1309
1310 pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id] ? 1 : 0])
1311 g_bCpAlternate[id] = !g_bCpAlternate[id]
1312 checknumbers[id]++
1313
1314 kz_chat(id, "%L", id, "KZ_CHECKPOINT", checknumbers[id])
1315
1316 return PLUGIN_HANDLED
1317}
1318
1319public GoCheck(id)
1320{
1321 if( !is_user_alive( id ) )
1322 {
1323 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1324 return PLUGIN_HANDLED
1325 }
1326
1327 if( checknumbers[id] == 0 )
1328 {
1329 kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
1330 return PLUGIN_HANDLED
1331 }
1332
1333 if( IsPaused[id] )
1334 {
1335 kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
1336 return PLUGIN_HANDLED
1337 }
1338
1339 set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} );
1340 set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 } );
1341 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING );
1342 set_pev( id, pev_fuser2, 0.0 );
1343 engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } );
1344 set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ] )
1345 gochecknumbers[id]++
1346
1347 kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
1348
1349 return PLUGIN_HANDLED
1350}
1351
1352public Stuck(id)
1353{
1354 if( !is_user_alive( id ) )
1355 {
1356 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1357 return PLUGIN_HANDLED
1358 }
1359
1360 if( checknumbers[id] < 2 )
1361 {
1362 kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
1363 return PLUGIN_HANDLED
1364 }
1365
1366 set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} )
1367 set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1368 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
1369 set_pev( id, pev_fuser2, 0.0 )
1370 engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } )
1371 set_pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id]] )
1372 g_bCpAlternate[id] = !g_bCpAlternate[id];
1373 gochecknumbers[id]++
1374
1375 kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
1376
1377 return PLUGIN_HANDLED;
1378}
1379
1380// =================================================================================================
1381
1382public reset_checkpoints(id)
1383{
1384 checknumbers[id] = 0
1385 gochecknumbers[id] = 0
1386 timer_started[id] = false
1387 timer_time[id] = 0.0
1388 user_has_scout[id] = false
1389 if(IsPaused[id])
1390 {
1391 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1392 IsPaused[id] = false
1393 }
1394 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
1395 kz_showtime_roundtime(id, 0)
1396
1397 return PLUGIN_HANDLED
1398}
1399
1400//===== Invis =======
1401
1402public cmdInvisible(id)
1403{
1404
1405 gViewInvisible[id] = !gViewInvisible[id]
1406 if(gViewInvisible[id])
1407 kz_chat(id, "%L", id, "KZ_INVISIBLE_PLAYERS_ON")
1408 else
1409 kz_chat(id, "%L", id, "KZ_INVISIBLE_PLAYERS_OFF")
1410
1411 return PLUGIN_HANDLED
1412}
1413
1414public cmdWaterInvisible(id)
1415{
1416 if( !gWaterFound )
1417 {
1418 kz_chat(id, "%L", id, "KZ_INVISIBLE_NOWATER")
1419 return PLUGIN_HANDLED
1420 }
1421
1422 gWaterInvisible[id] = !gWaterInvisible[id]
1423 if(gWaterInvisible[id])
1424 kz_chat(id, "%L", id, "KZ_INVISIBLE_WATER_ON")
1425 else
1426 kz_chat(id, "%L", id, "KZ_INVISIBLE_WATER_OFF")
1427
1428 return PLUGIN_HANDLED
1429}
1430
1431//======================Semiclip / Invis==========================
1432
1433public FM_client_AddToFullPack_Post(es, e, ent, host, hostflags, player, pSet)
1434{
1435 if( player )
1436 {
1437 if (get_pcvar_num(kz_semiclip) == 1)
1438 {
1439 if ( host != ent && get_orig_retval() && is_user_alive(host) )
1440 {
1441 set_es(es, ES_Solid, SOLID_NOT)
1442 set_es(es, ES_RenderMode, kRenderTransAlpha)
1443 set_es(es, ES_RenderAmt, get_pcvar_num(kz_semiclip_transparency))
1444 }
1445 }
1446 if(gMarkedInvisible[ent] && gViewInvisible[host])
1447 {
1448 set_es(es, ES_RenderMode, kRenderTransTexture)
1449 set_es(es, ES_RenderAmt, 0)
1450 set_es(es, ES_Origin, { 999999999.0, 999999999.0, 999999999.0 } )
1451 }
1452 }
1453 else if( gWaterInvisible[host] && gWaterEntity[ent] )
1454 {
1455 set_es(es, ES_Effects, get_es( es, ES_Effects ) | EF_NODRAW )
1456 }
1457
1458 return FMRES_IGNORED
1459}
1460
1461public Ham_CBasePlayer_PreThink_Post(id)
1462{
1463 if( !is_user_alive(id) )
1464 {
1465 return
1466 }
1467
1468 RefreshPlayersList()
1469
1470 if (get_pcvar_num(kz_semiclip) == 1)
1471 {
1472 for(new i = 0; i<g_iNum; i++)
1473 {
1474 g_iPlayer = g_iPlayers[i]
1475 if( id != g_iPlayer )
1476 {
1477 set_pev(g_iPlayer, pev_solid, SOLID_NOT)
1478 }
1479 }
1480 }
1481}
1482
1483public client_PostThink(id)
1484{
1485 if( !is_user_alive(id) )
1486 return
1487
1488 RefreshPlayersList()
1489
1490 if (get_pcvar_num(kz_semiclip) == 1)
1491 for(new i = 0; i<g_iNum; i++)
1492 {
1493 g_iPlayer = g_iPlayers[i]
1494 if( g_iPlayer != id )
1495 set_pev(g_iPlayer, pev_solid, SOLID_SLIDEBOX)
1496 }
1497}
1498
1499public noclip(id)
1500{
1501 if(!is_user_alive(id))
1502 {
1503 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1504 return PLUGIN_HANDLED
1505 }
1506 new noclip = !get_user_noclip(id)
1507 set_user_noclip(id, noclip)
1508 if(IsPaused[id] && (get_pcvar_num(kz_noclip_pause) == 1))
1509 {
1510 if(noclip)
1511 {
1512 pev(id, pev_origin, NoclipPos[id])
1513 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1514 }
1515 else
1516 {
1517 set_pev(id, pev_origin, NoclipPos[id])
1518 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1519 }
1520 }
1521 else if(noclip)
1522 detect_cheat(id,"Noclip")
1523 kz_chat(id, "%L", id, "KZ_NOCLIP" , noclip ? "ON" : "OFF")
1524
1525 return PLUGIN_HANDLED
1526}
1527
1528public GodMode(id)
1529{
1530 if(!is_user_alive(id))
1531 {
1532 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1533 return PLUGIN_HANDLED
1534 }
1535
1536 new godmode = !get_user_godmode(id)
1537 set_user_godmode(id, godmode)
1538 if(godmode)
1539 detect_cheat(id,"God Mode")
1540 kz_chat(id, "%L", id, "KZ_GODMODE" , godmode ? "ON" : "OFF")
1541
1542 return PLUGIN_HANDLED
1543}
1544
1545// =================================================================================================
1546
1547stock kz_set_start(const map[], Float:origin[3])
1548{
1549 new realfile[128], tempfile[128], formatorigin[50]
1550 formatex(realfile, 127, "%s/%s", Kzdir, KZ_STARTFILE)
1551 formatex(tempfile, 127, "%s/%s", Kzdir, KZ_STARTFILE_TEMP)
1552 formatex(formatorigin, 49, "%f %f %f", origin[0], origin[1], origin[2])
1553
1554 DefaultStartPos = origin
1555 DefaultStart = true
1556
1557 new file = fopen(tempfile, "wt")
1558 new vault = fopen(realfile, "rt")
1559
1560 new data[128], key[64]
1561 new bool:replaced = false
1562
1563 while( !feof(vault) )
1564 {
1565 fgets(vault, data, 127)
1566 parse(data, key, 63)
1567
1568 if( equal(key, map) && !replaced )
1569 {
1570 fprintf(file, "%s %s^n", map, formatorigin)
1571
1572 replaced = true
1573 }
1574 else
1575 {
1576 fputs(file, data)
1577 }
1578 }
1579
1580 if( !replaced )
1581 {
1582 fprintf(file, "%s %s^n", map, formatorigin)
1583 }
1584
1585 fclose(file)
1586 fclose(vault)
1587
1588 delete_file(realfile)
1589 while( !rename_file(tempfile, realfile, 1) ) {}
1590}
1591
1592stock kz_showtime_roundtime(id, time)
1593{
1594 if( is_user_connected(id) )
1595 {
1596 message_begin(MSG, get_user_msgid( "RoundTime" ), _, id);
1597 write_short(time + 1);
1598 message_end();
1599 }
1600}
1601
1602stock kz_chat(id, const message[], {Float,Sql,Result,_}:...)
1603{
1604 new cvar = get_pcvar_num(kz_chatorhud)
1605 if(cvar == 0)
1606 return PLUGIN_HANDLED
1607
1608 new msg[180], final[192]
1609 if (cvar == 1 && chatorhud[id] == -1 || chatorhud[id] == 1)
1610 {
1611 vformat(msg, 179, message, 3)
1612 formatex(final, 191, "%s^x01 %s", prefix, msg)
1613 kz_remplace_colors(final, 191)
1614 ColorChat(id, GREEN, "%s", final)
1615 }
1616 else if( cvar == 2 && chatorhud[id] == -1 || chatorhud[id] == 2)
1617 {
1618 vformat(msg, 179, message, 3)
1619 replace_all(msg, 191, "^x01", "")
1620 replace_all(msg, 191, "^x03", "")
1621 replace_all(msg, 191, "^x04", "")
1622 replace_all(msg, 191, ".", "")
1623 kz_hud_message(id, "%s", msg)
1624 }
1625
1626 return 1
1627}
1628
1629stock kz_print_config(id, const msg[])
1630{
1631 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, id);
1632 write_byte(id);
1633 write_string(msg);
1634 message_end();
1635}
1636
1637stock kz_remplace_colors(message[], len)
1638{
1639 replace_all(message, len, "!g", "^x04")
1640 replace_all(message, len, "!t", "^x03")
1641 replace_all(message, len, "!y", "^x01")
1642}
1643
1644stock kz_hud_message(id, const message[], {Float,Sql,Result,_}:...)
1645{
1646 static msg[192], colors[12], r[4], g[4], b[4];
1647 vformat(msg, 191, message, 3);
1648
1649 get_pcvar_string(kz_hud_color, colors, 11)
1650 parse(colors, r, 3, g, 3, b, 4)
1651
1652 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), -1.0, 0.90, 0, 0.0, 2.0, 0.0, 1.0, -1);
1653 ShowSyncHudMsg(id, hud_message, msg);
1654}
1655
1656stock kz_register_saycmd(const saycommand[], const function[], flags)
1657{
1658 new temp[64]
1659 formatex(temp, 63, "say /%s", saycommand)
1660 register_clcmd(temp, function, flags)
1661 formatex(temp, 63, "say .%s", saycommand)
1662 register_clcmd(temp, function, flags)
1663 formatex(temp, 63, "say_team /%s", saycommand)
1664 register_clcmd(temp, function, flags)
1665 formatex(temp, 63, "say_team .%s", saycommand)
1666 register_clcmd(temp, function, flags)
1667}
1668
1669stock get_configsdir(name[],len)
1670{
1671 return get_localinfo("amxx_configsdir",name,len);
1672}
1673
1674#if defined USE_SQL
1675stock GetNewRank(id, type)
1676{
1677 new createinto[1001]
1678
1679 new cData[2]
1680 cData[0] = id
1681 cData[1] = type
1682
1683 formatex(createinto, 1000, "SELECT authid FROM `%s` WHERE mapname='%s' ORDER BY time LIMIT 15", type == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName)
1684 SQL_ThreadQuery(g_SqlTuple, "GetNewRank_QueryHandler", createinto, cData, 2)
1685}
1686
1687stock kz_update_plrname(id)
1688{
1689 new createinto[1001], authid[32], name[32]
1690 get_user_authid(id, authid, 31)
1691 get_user_name(id, name, 31)
1692
1693 replace_all(name, 31, "\", "")
1694 replace_all(name, 31, "`", "")
1695 replace_all(name, 31, "'", "")
1696
1697 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
1698 return 0;
1699 else
1700 {
1701 formatex(createinto, 1000, "UPDATE `kz_pro15` SET name='%s' WHERE authid='%s'", name, authid)
1702 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1703 formatex(createinto, 1000, "UPDATE `kz_nub15` SET name='%s' WHERE authid='%s'", name, authid)
1704 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1705 }
1706 return 1
1707}
1708#endif
1709
1710public FwdSpawnWeaponbox( iEntity )
1711{
1712 if(get_pcvar_num(kz_remove_drops) == 1)
1713 {
1714 set_pev( iEntity, pev_flags, FL_KILLME )
1715 dllfunc( DLLFunc_Think, iEntity )
1716 }
1717
1718 return HAM_IGNORED
1719}
1720
1721public FwdHamDoorSpawn( iEntity )
1722{
1723 static const szNull[ ] = "common/null.wav";
1724
1725 new Float:flDamage;
1726 pev( iEntity, pev_dmg, flDamage );
1727
1728 if( flDamage < -999.0 ) {
1729 set_pev( iEntity, pev_noise1, szNull );
1730 set_pev( iEntity, pev_noise2, szNull );
1731 set_pev( iEntity, pev_noise3, szNull );
1732
1733 if( !HealsOnMap )
1734 HealsOnMap = true
1735 }
1736}
1737
1738public FwdHamPlayerSpawn( id )
1739{
1740
1741 if( !is_user_alive( id ) )
1742 return;
1743
1744 if(firstspawn[id])
1745 {
1746 ColorChat(id, GREEN, "%s^x01 Bienvenido ^x03KZ Server ^x01", prefix)
1747
1748 if(get_pcvar_num(kz_checkpoints) == 0)
1749 ColorChat(id, GREEN, "%s^x01 %L", id, "KZ_CHECKPOINT_OFF", prefix)
1750
1751
1752 if(Verif(id,1) && get_pcvar_num(kz_save_pos) == 1)
1753 savepos_menu(id)
1754 else if(get_pcvar_num(kz_spawn_mainmenu) == 1)
1755 kz_menu (id)
1756 }
1757 firstspawn[id] = false
1758
1759
1760 if( !user_has_weapon(id,CSW_KNIFE) )
1761 give_item( id,"weapon_knife" )
1762
1763 if( HealsOnMap )
1764 set_user_health(id, 50175)
1765
1766 if( IsPaused[id] )
1767 {
1768 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1769 set_pev(id, pev_origin, PauseOrigin[id])
1770 }
1771
1772 if(get_pcvar_num(kz_use_radio) == 0)
1773 {
1774 #define XO_PLAYER 5
1775 #define m_iRadiosLeft 192
1776 set_pdata_int(id, m_iRadiosLeft, 0, XO_PLAYER)
1777 }
1778}
1779
1780public GroundWeapon_Touch(iWeapon, id)
1781{
1782 if( is_user_alive(id) && timer_started[id] && get_pcvar_num(kz_pick_weapons) == 0 )
1783 return HAM_SUPERCEDE
1784
1785 return HAM_IGNORED
1786}
1787
1788
1789
1790// ==================================Save positions=================================================
1791
1792public SavePos(id)
1793{
1794
1795 new authid[33];
1796 get_user_authid(id, authid, 32)
1797 if(get_pcvar_num(kz_save_pos) == 0)
1798 {
1799 kz_chat(id, "%L", id, "KZ_SAVEPOS_DISABLED")
1800 return PLUGIN_HANDLED
1801 }
1802
1803 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
1804 {
1805 ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
1806
1807 return PLUGIN_HANDLED
1808 }
1809
1810 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) )
1811 {
1812 kz_chat(id, "%L", id, "KZ_NOT_ON_GROUND")
1813
1814 return PLUGIN_HANDLED
1815 }
1816
1817 if(!timer_started[id])
1818 {
1819 kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
1820 return PLUGIN_HANDLED
1821 }
1822
1823 if(Verif(id,1))
1824 {
1825 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_ALREADY")
1826 savepos_menu(id)
1827 return PLUGIN_HANDLED
1828 }
1829
1830 if(get_user_noclip(id))
1831 {
1832 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_NOCLIP")
1833 return PLUGIN_HANDLED
1834 }
1835
1836 new Float:origin[3], scout
1837 pev(id, pev_origin, origin)
1838 new Float:Time,check,gocheck
1839 if(IsPaused[id])
1840 {
1841 Time = g_pausetime[id]
1842 Pause(id)
1843 }
1844 else
1845 Time=get_gametime() - timer_time[id]
1846 check=checknumbers[id]
1847 gocheck=gochecknumbers[id]
1848 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS")
1849 if (user_has_scout[id])
1850 scout=1
1851 else
1852 scout=0
1853 kz_savepos(id, Time, check, gocheck, origin, scout)
1854 reset_checkpoints(id)
1855
1856 return PLUGIN_HANDLED
1857}
1858
1859public GoPos(id)
1860{
1861 remove_hook(id)
1862 set_user_godmode(id, 0)
1863 set_user_noclip(id, 0)
1864 if(Verif(id,0))
1865 {
1866 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1867 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
1868 set_pev(id, pev_origin, SavedOrigins[id] )
1869 }
1870
1871 checknumbers[id]=SavedChecks[id]
1872 gochecknumbers[id]=SavedGoChecks[id]+((get_pcvar_num(kz_save_pos_gochecks)>0) ? 1 : 0)
1873 CheckPoint(id)
1874 CheckPoint(id)
1875 strip_user_weapons(id)
1876 give_item(id,"weapon_usp")
1877 give_item(id,"weapon_knife")
1878 if(SavedScout[id])
1879 {
1880 give_item(id, "weapon_scout")
1881 user_has_scout[id] = true
1882 }
1883 timer_time[id]=get_gametime()-SavedTime[id]
1884 timer_started[id]=true
1885 Pause(id)
1886
1887}
1888
1889public Verif(id, action)
1890{
1891 new realfile[128], tempfile[128], authid[32], map[64]
1892 new bool:exist = false
1893 get_mapname(map, 63)
1894 get_user_authid(id, authid, 31)
1895 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
1896 formatex(tempfile, 127, "%s/temp.ini", SavePosDir)
1897
1898 if( !file_exists(realfile) )
1899 return 0
1900
1901 new file = fopen(tempfile, "wt")
1902 new vault = fopen(realfile, "rt")
1903 new data[150], sid[32], time[25], checks[5], gochecks[5], x[25], y[25], z[25], scout[5]
1904 while( !feof(vault) )
1905 {
1906 fgets(vault, data, 149)
1907 parse(data, sid, 31, time, 24, checks, 4, gochecks, 4, x, 24, y, 24, z, 24, scout, 4)
1908
1909 if( equal(sid, authid) && !exist) // ma aflu in fisier?
1910 {
1911 if(action == 1)
1912 fputs(file, data)
1913 exist= true
1914 SavedChecks[id] = str_to_num(checks)
1915 SavedGoChecks[id] = str_to_num(gochecks)
1916 SavedTime[id] = str_to_float(time)
1917 SavedOrigins[id][0]=str_to_num(x)
1918 SavedOrigins[id][1]=str_to_num(y)
1919 SavedOrigins[id][2]=str_to_num(z)
1920 SavedScout[id] = str_to_num(scout)
1921 }
1922 else
1923 {
1924 fputs(file, data)
1925 }
1926 }
1927
1928 fclose(file)
1929 fclose(vault)
1930
1931 delete_file(realfile)
1932 if(file_size(tempfile) == 0)
1933 delete_file(tempfile)
1934 else
1935 while( !rename_file(tempfile, realfile, 1) ) {}
1936
1937
1938 if(!exist)
1939 return 0
1940
1941 return 1
1942}
1943public kz_savepos (id, Float:time, checkpoints, gochecks, Float:origin[3], scout)
1944{
1945 new realfile[128], formatorigin[128], map[64], authid[32]
1946 get_mapname(map, 63)
1947 get_user_authid(id, authid, 31)
1948 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
1949 formatex(formatorigin, 127, "%s %f %d %d %d %d %d %d", authid, time, checkpoints, gochecks, origin[0], origin[1], origin[2], scout)
1950
1951 new vault = fopen(realfile, "rt+")
1952 write_file(realfile, formatorigin) // La sfarsit adaug datele mele
1953
1954 fclose(vault)
1955
1956}
1957
1958// =================================================================================================
1959// Events / Forwards
1960// =================================================================================================
1961
1962//=================================================================================================
1963
1964public client_disconnect(id)
1965{
1966 checknumbers[id] = 0
1967 gochecknumbers[id] = 0
1968 antihookcheat[id] = 0.0
1969 chatorhud[id] = -1
1970 timer_started[id] = false
1971 ShowTime[id] = get_pcvar_num(kz_show_timer)
1972 firstspawn[id] = true
1973 NightVisionUse[id] = false
1974 IsPaused[id] = false
1975 WasPaused[id] = false
1976 user_has_scout[id] = false
1977 SavePos(id)
1978 remove_hook(id)
1979}
1980
1981public client_putinserver(id)
1982{
1983 checknumbers[id] = 0
1984 gochecknumbers[id] = 0
1985 antihookcheat[id] = 0.0
1986 chatorhud[id] = -1
1987 timer_started[id] = false
1988 ShowTime[id] = get_pcvar_num(kz_show_timer)
1989 firstspawn[id] = true
1990 NightVisionUse[id] = false
1991 IsPaused[id] = false
1992 WasPaused[id] = false
1993 user_has_scout[id] = false
1994 remove_hook(id)
1995}
1996
1997// =================================================================================================
1998// Menu
1999// =================================================================================================
2000
2001
2002public kz_menu(id)
2003{
2004 new title[64];
2005 formatex(title, 63, "\r[Menu] \wKZ Server")
2006 new menu = menu_create(title, "MenuHandler")
2007
2008 new msgcheck[64], msggocheck[64], msgpause[64]
2009 formatex(msgcheck, 63, "Checkpoint - \y#%i", checknumbers[id])
2010 formatex(msggocheck, 63, "Gocheck - \y#%i", gochecknumbers[id])
2011 formatex(msgpause, 63, "Pausa - %s^n", IsPaused[id] ? "\yON" : "\rOFF" )
2012
2013 menu_additem( menu, msgcheck, "1" )
2014 menu_additem( menu, msggocheck, "2" )
2015 menu_additem( menu, msgpause, "3" )
2016 menu_additem( menu, "Inicio", "4")
2017 menu_additem( menu, "Final", "5")
2018 menu_additem( menu, "Destrabar^n", "6")
2019
2020 menu_additem( menu, "Opciones", "7")
2021 //menu_additem( menu, "\rKreedz \yServer^n", "8")
2022
2023 //menu_additem( menu, "Exit", "MENU_EXIT" )
2024 //menu_setprop(menu, MPROP_EXIT, 0)
2025 menu_display(id, menu, 0)
2026 return PLUGIN_HANDLED
2027}
2028
2029public MenuHandler(id , menu, item)
2030{
2031 if( item == MENU_EXIT ) {
2032 menu_destroy(menu)
2033 return PLUGIN_HANDLED
2034 }
2035
2036
2037 switch(item) {
2038 case 0:{
2039 CheckPoint(id)
2040 kz_menu(id)
2041 }
2042 case 1:{
2043 GoCheck(id)
2044 kz_menu(id)
2045 }
2046 case 2:{
2047 Pause(id)
2048 kz_menu(id)
2049
2050 }
2051 case 3:{
2052 goStart(id)
2053 kz_menu(id)
2054 }
2055 case 4:{
2056
2057 EndQuestion(id)
2058 }
2059 case 5:{
2060 Stuck(id)
2061 kz_menu(id)
2062 }
2063 case 6:{
2064 kz_opciones(id)
2065 }/*
2066 case 7:{
2067 client_cmd(id, "say /cmd")
2068 }*/
2069 }
2070
2071 return PLUGIN_HANDLED
2072}
2073
2074public kz_opciones(id)
2075{
2076 new title[64];
2077 formatex(title, 63, "\r[Menu] \wKZ Opciones")
2078 new menu = menu_create(title, "MenuHandlerOpciones")
2079
2080
2081 menu_additem( menu, "Timer", "1" )
2082 menu_additem( menu, "Invisibilidad", "2" )
2083 menu_additem( menu, "Espectador/CT", "3" )
2084 menu_additem( menu, "Reiniciar Tiempo^n", "4")
2085 menu_additem( menu, "Top 15^n", "5")
2086 menu_additem( menu, "\rKreedz \yServer^n", "6")
2087
2088
2089 menu_additem( menu, "Volver", "7" )
2090
2091 menu_setprop(menu, MPROP_PERPAGE, 0)
2092 menu_display(id, menu, 0)
2093 return PLUGIN_HANDLED
2094}
2095
2096public MenuHandlerOpciones(id , menu, item)
2097{
2098 if( item == MENU_EXIT ) {
2099 menu_destroy(menu)
2100 return PLUGIN_HANDLED
2101 }
2102
2103
2104 switch(item) {
2105 case 0:{
2106 ShowTimer_Menu(id)
2107 }
2108 case 1:{
2109 InvisMenu(id)
2110 }
2111 case 2:{
2112 ct(id)
2113 kz_opciones(id)
2114
2115 }
2116 case 3:{
2117 reset_checkpoints(id)
2118 kz_opciones(id)
2119 }
2120 case 4:{
2121 top15menu(id)
2122 }
2123 case 5:{
2124 client_cmd(id, "say /cmd")
2125 }
2126 case 6:{
2127 kz_menu(id)
2128 }
2129
2130 }
2131
2132 return PLUGIN_HANDLED
2133}
2134
2135public InvisMenu(id)
2136{
2137 new menu = menu_create("\r[Menu] \wInvis\w", "InvisMenuHandler")
2138 new msginvis[64], msgwaterinvis[64]
2139
2140 formatex(msginvis, 63, "Jugadores - %s", gViewInvisible[id] ? "\yON" : "\rOFF" )
2141 formatex(msgwaterinvis, 63, "Agua - %s^n", gWaterInvisible[id] ? "\yON" : "\rOFF" )
2142
2143 menu_additem( menu, msginvis, "1" )
2144 menu_additem( menu, msgwaterinvis, "2" )
2145 menu_additem( menu, "Menu Principal", "3" )
2146
2147 menu_display(id, menu, 0)
2148 return PLUGIN_HANDLED
2149}
2150
2151public InvisMenuHandler (id, menu, item)
2152{
2153 if( item == MENU_EXIT )
2154 {
2155 menu_destroy(menu)
2156 return PLUGIN_HANDLED
2157 }
2158
2159 switch(item)
2160 {
2161 case 0:
2162 {
2163 cmdInvisible(id)
2164 InvisMenu(id)
2165 }
2166 case 1:
2167 {
2168 cmdWaterInvisible(id)
2169 InvisMenu(id)
2170 }
2171 case 2:
2172 {
2173 kz_menu(id)
2174 }
2175 }
2176 return PLUGIN_HANDLED
2177}
2178
2179public ShowTimer_Menu(id)
2180{
2181 if (get_pcvar_num(kz_show_timer) == 0 )
2182 {
2183 kz_chat(id, "%L", id, "KZ_TIMER_DISABLED")
2184 return PLUGIN_HANDLED
2185 }
2186 else
2187 {
2188 new menu = menu_create("\yTimer Menu\w", "TimerHandler")
2189
2190 new roundtimer[64], hudtimer[64], notimer[64];
2191
2192 formatex(roundtimer, 63, "Round Timer %s", ShowTime[id] == 2 ? "\y x" : "" )
2193 formatex(hudtimer, 63, "HUD Timer %s", ShowTime[id] == 1 ? "\y x" : "" )
2194 formatex(notimer, 63, "No Timer %s^n", ShowTime[id] == 0 ? "\y x" : "" )
2195
2196 menu_additem( menu, roundtimer, "1" )
2197 menu_additem( menu, hudtimer, "2" )
2198 menu_additem( menu, notimer, "3" )
2199 menu_additem( menu, "Menu Principal", "4" )
2200
2201 menu_display(id, menu, 0)
2202 return PLUGIN_HANDLED
2203 }
2204
2205 return PLUGIN_HANDLED
2206}
2207
2208public TimerHandler (id, menu, item)
2209{
2210 if( item == MENU_EXIT )
2211 {
2212 menu_destroy(menu)
2213 return PLUGIN_HANDLED
2214 }
2215
2216 switch(item)
2217 {
2218
2219 case 0:
2220 {
2221 ShowTime[id]= 2
2222 ShowTimer_Menu(id)
2223 }
2224 case 1:
2225 {
2226 ShowTime[id]= 1
2227 ShowTimer_Menu(id)
2228 if (timer_started[id])
2229 kz_showtime_roundtime(id, 0)
2230 }
2231 case 2:
2232 {
2233 ShowTime[id]= 0
2234 ShowTimer_Menu(id)
2235 if (timer_started[id])
2236 kz_showtime_roundtime(id, 0)
2237 }
2238 case 3:
2239 {
2240 kz_menu(id)
2241 }
2242 }
2243 return PLUGIN_HANDLED
2244}
2245
2246public savepos_menu(id)
2247{
2248 new menu = menu_create("Menu de SavePos", "SavePosHandler")
2249
2250 menu_additem( menu, "Cargar run anterior", "1" )
2251 menu_additem( menu, "Empezar nuevo Run", "2" )
2252
2253 menu_display(id, menu, 0)
2254 return PLUGIN_HANDLED
2255}
2256
2257public SavePosHandler(id, menu, item)
2258{
2259
2260 switch(item)
2261 {
2262 case 0:
2263 {
2264 GoPos(id)
2265 }
2266 case 1:
2267 {
2268 Verif(id,0)
2269 }
2270 }
2271 return PLUGIN_HANDLED
2272}
2273
2274public top15menu(id)
2275{
2276 new menu = menu_create("\rProKreedz \yTop15 \w", "top15handler")
2277 menu_additem(menu, "\wPro 15", "1", 0)
2278 menu_additem(menu, "\wNoob 15^n^n", "2", 0)
2279 #if defined USE_SQL
2280 menu_additem(menu, "Pro Records","3")
2281 menu_additem(menu, "Players Rankings^n","4")
2282 menu_additem(menu, "Last 10 Pro Entries", "5")
2283 menu_additem(menu, "Maps Statistic","6")
2284 menu_additem(menu, "Main Menu", "7")
2285 #else
2286 menu_additem(menu, "\wMain Menu", "3", 0)
2287 #endif
2288
2289 menu_display(id, menu, 0);
2290
2291 return PLUGIN_HANDLED;
2292}
2293
2294public top15handler(id, menu, item)
2295{
2296 if(item == MENU_EXIT)
2297 {
2298 menu_destroy(menu)
2299 return PLUGIN_HANDLED
2300 }
2301 #if defined USE_SQL
2302 switch(item)
2303 {
2304 case 0:
2305 {
2306 ProTop_show(id)
2307 }
2308 case 1:
2309 {
2310 NoobTop_show(id)
2311 }
2312 case 2:
2313 {
2314 kz_showhtml_motd(id, PRO_RECORDS, "")
2315 }
2316 case 3:
2317 {
2318 kz_showhtml_motd(id, PLAYERS_RANKING, "")
2319 }
2320 case 4:
2321 {
2322 kz_showhtml_motd(id, LAST_PRO10, "")
2323 }
2324 case 5:
2325 {
2326 kz_showhtml_motd(id, MAPS_STATISTIC, "")
2327 }
2328 case 6:
2329 {
2330 kz_menu(id)
2331 }
2332 }
2333 #else
2334 switch(item)
2335 {
2336 case 0:
2337 {
2338 ProTop_show(id)
2339 }
2340 case 1:
2341 {
2342 NoobTop_show(id)
2343 }
2344 case 2:
2345 {
2346 kz_menu(id)
2347 }
2348 }
2349 #endif
2350
2351 return PLUGIN_HANDLED;
2352}
2353
2354// =================================================================================================
2355
2356//
2357// Timersystem
2358// =================================================================================================
2359public fwdUse(ent, id)
2360{
2361 if( !ent || id > 32 )
2362 {
2363 return HAM_IGNORED;
2364 }
2365
2366 if( !is_user_alive(id) )
2367 {
2368 return HAM_IGNORED;
2369 }
2370
2371
2372 new name[32]
2373 get_user_name(id, name, 31)
2374
2375 new szTarget[ 32 ];
2376 pev(ent, pev_target, szTarget, 31);
2377
2378 if( TrieKeyExists( g_tStarts, szTarget ) )
2379 {
2380
2381 if ( get_gametime() - antihookcheat[id] < 3.0 )
2382 {
2383 kz_hud_message( id, "%L", id, "KZ_HOOK_PROTECTION" );
2384 return PLUGIN_HANDLED
2385 }
2386
2387 if(Verif(id,1))
2388 {
2389 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_SAVED")
2390 savepos_menu(id)
2391 return HAM_IGNORED
2392 }
2393
2394 if ( reset_checkpoints(id) && !timer_started[id] )
2395 {
2396 start_climb(id)
2397 new wpn=get_user_weapon(id)
2398 for(new i = 0; i < 8; i++)
2399 if( user_has_weapon(id, other_weapons[i]) )
2400 {
2401 strip_user_weapons(id)
2402 give_item(id,"weapon_knife")
2403 give_item(id,"weapon_usp")
2404 set_pdata_int(id, 382, 24, 5)
2405 if(wpn==CSW_SCOUT)
2406 {
2407 user_has_scout[id]=true
2408 give_item(id,"weapon_scout")
2409 }
2410 else
2411 user_has_scout[id]=false
2412 }
2413
2414 if( get_user_health(id) < 100 )
2415 set_user_health(id, 100)
2416
2417 pev(id, pev_origin, SavedStart[id])
2418 if(get_pcvar_num(kz_save_autostart) == 1)
2419 AutoStart[id] = true;
2420
2421 if( !DefaultStart )
2422 {
2423 kz_set_start(MapName, SavedStart[id])
2424 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SET_START")
2425 }
2426
2427 remove_hook(id)
2428 }
2429
2430 }
2431
2432 if( TrieKeyExists( g_tStops, szTarget ) )
2433 {
2434 if( timer_started[id] )
2435 {
2436 if(get_user_noclip(id))
2437 return PLUGIN_HANDLED
2438
2439 finish_climb(id)
2440
2441 if(get_pcvar_num(kz_hook_prize) == 1 && !canusehook[id])
2442 {
2443 canusehook[id] = true
2444 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_HOOK")
2445 }
2446 }
2447 else
2448 kz_hud_message(id, "%L", id, "KZ_TIMER_NOT_STARTED")
2449
2450 }
2451 return HAM_IGNORED
2452}
2453
2454public start_climb(id)
2455{
2456 kz_chat(id, "%L", id, "KZ_START_CLIMB")
2457
2458 if (get_pcvar_num(kz_reload_weapons) == 0)
2459 {
2460 strip_user_weapons(id)
2461 give_item(id,"weapon_knife")
2462 }
2463
2464 if (ShowTime[id] == 2)
2465 kz_showtime_roundtime(id, 0)
2466 set_pev(id, pev_gravity, 1.0);
2467 set_pev(id, pev_movetype, MOVETYPE_WALK)
2468 set_user_godmode(id, 0)
2469 reset_checkpoints(id)
2470 IsPaused[id] = false
2471 timer_started[id] = true
2472 timer_time[id] = get_gametime()
2473}
2474
2475public finish_climb(id)
2476{
2477 if (!is_user_alive (id))
2478 {
2479 return;
2480 }
2481
2482 if ( (get_pcvar_num(kz_top15_authid) > 1) || (get_pcvar_num(kz_top15_authid) < 0) )
2483 {
2484 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_TOP15_DISABLED")
2485 return;
2486 }
2487
2488 #if defined USE_SQL
2489 new Float: time, wpn
2490 time = get_gametime() - timer_time[id]
2491 show_finish_message(id, time)
2492 timer_started[id] = false
2493 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
2494 kz_showtime_roundtime(id, 0)
2495 new checkpoints=checknumbers[id]
2496 new gocheck=gochecknumbers[id]
2497 if(user_has_scout[id])
2498 wpn=CSW_SCOUT
2499 else
2500 wpn=get_user_weapon( id )
2501
2502 new steam[32], name[32]
2503 get_user_name(id, name, 31)
2504 get_user_authid(id, steam, 31 )
2505 client_cmd(0, "spk buttons/bell1")
2506 new createinto[1001]
2507
2508 new cData[192]
2509 cData[0] = id
2510 formatex(cData[2], charsmax(cData)-2, "^"%f^" ^"%d^" ^"%d^" ^"%d^"", time, wpn, checkpoints ,gocheck)
2511
2512
2513 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2514 {
2515 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2516 {
2517 cData[1] = PRO_TOP
2518 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND name='%s'", MapName, name)
2519 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2520 }
2521 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2522 {
2523 cData[1] = NUB_TOP
2524 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND name='%s'", MapName, name)
2525 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2526 }
2527 } else
2528 {
2529
2530 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2531 {
2532 cData[1] = PRO_TOP
2533 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
2534 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2535 }
2536 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2537 {
2538 cData[1] = NUB_TOP
2539 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
2540 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2541 }
2542 }
2543 #else
2544 new Float: time, authid[32]
2545 time = get_gametime() - timer_time[id]
2546 get_user_authid(id, authid, 31)
2547 show_finish_message(id, time)
2548 timer_started[id] = false
2549 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
2550 kz_showtime_roundtime(id, 0)
2551
2552 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2553 ProTop_update(id, time)
2554 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2555 NoobTop_update(id, time, checknumbers[id], gochecknumbers[id])
2556 #endif
2557 user_has_scout[id] = false
2558
2559}
2560
2561public show_finish_message(id, Float:kreedztime)
2562{
2563 new name[32]
2564 new imin,isec,ims, wpn
2565 if(user_has_scout[id])
2566 wpn=CSW_SCOUT
2567 else
2568 wpn=get_user_weapon( id )
2569 get_user_name(id, name, 31)
2570 imin = floatround(kreedztime / 60.0, floatround_floor)
2571 isec = floatround(kreedztime - imin * 60.0,floatround_floor)
2572 ims = floatround( ( kreedztime - ( imin * 60.0 + isec ) ) * 100.0, floatround_floor )
2573
2574 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x04 %02i:%02i.%02i ^x03(^x01 CPs: ^x04%d^x03 | ^x01 TPs: ^x04%d^x03 | ^x01 %L: ^x04%s^x03) ^x01 !", prefix, name, LANG_PLAYER, "KZ_FINISH_MSG", imin, isec, ims, checknumbers[id], gochecknumbers[id], LANG_PLAYER, "KZ_WEAPON", g_weaponsnames[wpn])
2575}
2576
2577//==========================================================
2578#if defined USE_SQL
2579public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
2580{
2581 new id = cData[0]
2582 new style = cData[1]
2583 if( iFailState != TQUERY_SUCCESS )
2584 {
2585 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
2586 ColorChat(0, GREEN, "%s^x01 %F", prefix, LANG_PLAYER, "KZ_TOP15_SQL_ERROR")
2587 }
2588
2589 server_print("[KZ] Server Geting Info of SQL Server")
2590
2591 new createinto[1001]
2592 new x1[16], x2[4], x3[5], x4[5]
2593 parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
2594
2595 new dia[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32]
2596 new Float:newtime = str_to_float(x1)
2597 new iMin, iSec, iMs, server[64]
2598 get_pcvar_string(kz_sql_name, server, 63)
2599 get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1)
2600 get_user_authid(id, steam, 31)
2601 get_user_name(id, name, sizeof name - 1)
2602 get_user_ip (id, ip, sizeof ip - 1, 1)
2603 geoip_code2_ex( ip, country)
2604
2605 replace_all(name, 31, "\", "")
2606 replace_all(name, 31, "`", "")
2607 replace_all(name, 31, "'", "")
2608
2609
2610 if( SQL_NumResults(hQuery) == 0 )
2611 {
2612 formatex(checkpoints, 31, ", '%d'", str_to_num(x3))
2613 formatex(gochecks, 31, ", '%d'", str_to_num(x4))
2614 formatex( createinto, sizeof createinto - 1, "INSERT INTO `%s` VALUES('%s', '%s','%s','%s','%f','%s','%s','%s'%s%s)", style == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName, steam, country, name, newtime, dia, g_weaponsnames[str_to_num(x2)], server, style == PRO_TOP ? "" : checkpoints, style == PRO_TOP ? "" : gochecks)
2615 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
2616 GetNewRank(id, style)
2617 }
2618 else
2619 {
2620 new Float:oldtime, Float:thetime
2621 SQL_ReadResult(hQuery, 0, oldtime)
2622
2623 if(newtime < oldtime)
2624 {
2625 thetime = oldtime - newtime
2626 iMin = floatround(thetime / 60.0, floatround_floor)
2627 iSec = floatround(thetime - iMin * 60.0,floatround_floor)
2628 iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
2629 ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i^x01 in ^x03%s", id, "KZ_IMPROVE", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
2630 formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3))
2631 formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4))
2632 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2633 formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE name='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, name, MapName)
2634 else
2635 formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE authid='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, steam, MapName)
2636
2637 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto )
2638 GetNewRank(id, style)
2639 }
2640 else
2641 {
2642 thetime = newtime - oldtime
2643 iMin = floatround(thetime / 60.0, floatround_floor)
2644 iSec = floatround(thetime - iMin * 60.0,floatround_floor)
2645 iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
2646 ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i ^x01in ^x03%s", id, "KZ_SLOWER", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
2647 }
2648 }
2649
2650 return PLUGIN_CONTINUE
2651
2652}
2653
2654public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
2655{
2656 new id = cData[0]
2657 if( iFailState != TQUERY_SUCCESS )
2658 {
2659 return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
2660 }
2661
2662 new steam[32], authid[32], namez[32], name[32], i = 0
2663 get_user_authid(id, steam, 31)
2664 get_user_name(id, namez, 31)
2665
2666 while( SQL_MoreResults(hQuery) )
2667 {
2668 i++
2669 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2670 {
2671 SQL_ReadResult(hQuery, 0, name, 31)
2672 if( equal(name, namez) )
2673 {
2674 ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
2675 break;
2676 }
2677 }
2678 else
2679 {
2680 SQL_ReadResult(hQuery, 0, authid, 31)
2681 if( equal(authid, steam) )
2682 {
2683 ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
2684 break;
2685 }
2686 }
2687 SQL_NextRow(hQuery)
2688 }
2689
2690 return PLUGIN_CONTINUE
2691}
2692
2693public ProTop_show(id)
2694{
2695 kz_showhtml_motd(id, PRO_TOP, MapName)
2696
2697 return PLUGIN_HANDLED
2698}
2699
2700public NoobTop_show(id)
2701{
2702
2703 kz_showhtml_motd(id, NUB_TOP, MapName)
2704
2705 return PLUGIN_HANDLED
2706}
2707
2708public ProRecs_show(id)
2709{
2710 new authid[32]
2711 get_user_authid(id, authid, 31)
2712
2713 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
2714 {
2715 ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
2716 return PLUGIN_HANDLED
2717 }
2718
2719 kz_showhtml_motd(id, PRO_RECORDS, MapName)
2720
2721 return PLUGIN_HANDLED
2722}
2723
2724stock kz_showhtml_motd(id, type, const map[])
2725{
2726 new buffer[1001], namebuffer[64], filepath[96]
2727 get_pcvar_string(kz_sql_files, filepath, 95)
2728 new authid[32]
2729 get_user_authid(id, authid, 31)
2730
2731 switch( type )
2732 {
2733 case PRO_TOP:
2734 {
2735 formatex(namebuffer, 63, "Pro 15 of %s", equal(map, "") ? "All Maps" : map)
2736 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/pro15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
2737 }
2738 case NUB_TOP:
2739 {
2740 formatex(namebuffer, 63, "Noob 15 of %s", equal(map, "") ? "All Maps" : map)
2741 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/nub15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
2742 }
2743 case PRO_RECORDS:
2744 {
2745 formatex(namebuffer, 63, "ProRecords and Rank")
2746 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/player.php?authid=%s^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
2747 }
2748 case PLAYERS_RANKING:
2749 {
2750 formatex(namebuffer, 63, "Players Ranking")
2751 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/players.php^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
2752 }
2753 case LAST_PRO10:
2754 {
2755 formatex(namebuffer, 63, "Last 10 Pro Entries")
2756 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/lastpro.php^"></head><body><p>LOADING...</p></body></html>", filepath)
2757 }
2758 case MAPS_STATISTIC:
2759 {
2760 formatex(namebuffer, 63, "Maps Statistic")
2761 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/map.php^"></head><body><p>LOADING...</p></body></html>", filepath)
2762 }
2763 }
2764
2765 show_motd(id, buffer, namebuffer)
2766}
2767#else
2768public ProTop_update(id, Float:time)
2769{
2770 new authid[32], name[32], thetime[32], Float: slower, Float: faster, Float:protiempo
2771 get_user_name(id, name, 31);
2772 get_user_authid(id, authid, 31);
2773 get_time(" %d/%m/%Y ", thetime, 31);
2774 new bool:Is_in_pro15
2775 Is_in_pro15 = false
2776
2777//Steam Players saves tops
2778 if (is_user_steam(authid)){
2779 for(new i = 0; i < 15; i++)
2780 {
2781 if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2782 {
2783 Is_in_pro15 = true
2784 slower = time - Pro_Times[i]
2785 faster = Pro_Times[i] - time
2786 protiempo = Pro_Times[i]
2787 }
2788 }
2789
2790 for (new i = 0; i < 15; i++)
2791 {
2792 if( time < Pro_Times[i])
2793 {
2794 new pos = i
2795 if ( get_pcvar_num(kz_top15_authid) == 0 )
2796 while( !equal(Pro_Names[pos], name) && pos < 15 )
2797 {
2798 pos++;
2799 }
2800 else if ( get_pcvar_num(kz_top15_authid) == 1)
2801 while( !equal(Pro_AuthIDS[pos], authid) && pos < 15 )
2802 {
2803 pos++;
2804 }
2805
2806 for (new j = pos; j > i; j--)
2807 {
2808 formatex(Pro_AuthIDS[j], 31, Pro_AuthIDS[j-1]);
2809 formatex(Pro_Names[j], 31, Pro_Names[j-1]);
2810 formatex(Pro_Date[j], 31, Pro_Date[j-1])
2811 Pro_Times[j] = Pro_Times[j-1];
2812 }
2813
2814 formatex(Pro_AuthIDS[i], 31, authid);
2815 formatex(Pro_Names[i], 31, name);
2816 formatex(Pro_Date[i], 31, thetime)
2817 Pro_Times[i] = time
2818
2819 save_pro15()
2820
2821 if( Is_in_pro15 )
2822 {
2823
2824 if( time < protiempo )
2825 {
2826 new min, Float:sec;
2827 min = floatround(faster, floatround_floor)/60;
2828 sec = faster - (60*min);
2829 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
2830
2831 if( (i + 1) == 1)
2832 {
2833 client_cmd(0, "spk %s", SONIDO_WAV);
2834 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2835 }
2836 else
2837 {
2838 client_cmd(0, "spk buttons/bell1");
2839 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2840 }
2841 }
2842 }
2843 else
2844 {
2845 if( (i + 1) == 1)
2846 {
2847 client_cmd(0, "spk %s", SONIDO_WAV);
2848 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2849 }
2850 else
2851 {
2852 client_cmd(0, "spk buttons/bell1");
2853 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2854 }
2855 }
2856
2857 return;
2858 }
2859
2860 if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2861 {
2862 if( time > protiempo )
2863 {
2864 new min, Float:sec;
2865 min = floatround(slower, floatround_floor)/60;
2866 sec = slower - (60*min);
2867 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
2868 return;
2869 }
2870 }
2871
2872 }
2873}
2874}
2875
2876public save_pro15()
2877{
2878 new profile[128]
2879 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
2880
2881 if( file_exists(profile) )
2882 {
2883 delete_file(profile)
2884 }
2885
2886 new Data[256];
2887 new f = fopen(profile, "at")
2888
2889 for(new i = 0; i < 15; i++)
2890 {
2891 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%s^"^n", Pro_Times[i], Pro_AuthIDS[i], Pro_Names[i], Pro_Date[i])
2892 fputs(f, Data)
2893 }
2894 fclose(f);
2895}
2896
2897public read_pro15()
2898{
2899 new profile[128], prodata[256]
2900 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
2901
2902 new f = fopen(profile, "rt" )
2903 new i = 0
2904 while( !feof(f) && i < 16)
2905 {
2906 fgets(f, prodata, 255)
2907 new totime[25]
2908 parse(prodata, totime, 24, Pro_AuthIDS[i], 31, Pro_Names[i], 31, Pro_Date[i], 31)
2909 Pro_Times[i] = str_to_float(totime)
2910 i++;
2911 }
2912 fclose(f)
2913}
2914
2915//==================================================================================================
2916
2917public NoobTop_update(id, Float:time, checkpoints, gochecks)
2918{
2919 new authid[32], name[32], thetime[32], wpn, Float: slower, Float: faster, Float:noobtiempo
2920 get_user_name(id, name, 31);
2921 get_user_authid(id, authid, 31);
2922 get_time(" %d/%m/%Y ", thetime, 31);
2923 new bool:Is_in_noob15
2924 Is_in_noob15 = false
2925 if(user_has_scout[id])
2926 wpn=CSW_SCOUT
2927 else
2928 wpn=get_user_weapon(id)
2929
2930 if (is_user_steam(authid)){
2931 for(new i = 0; i < 15; i++)
2932 {
2933 if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2934 {
2935 Is_in_noob15 = true
2936 slower = time - Noob_Tiempos[i];
2937 faster = Noob_Tiempos[i] - time;
2938 noobtiempo = Noob_Tiempos[i]
2939 }
2940 }
2941
2942 for (new i = 0; i < 15; i++)
2943 {
2944 if( time < Noob_Tiempos[i])
2945 {
2946 new pos = i
2947
2948 if ( get_pcvar_num(kz_top15_authid) == 0 )
2949 while( !equal(Noob_Names[pos], name) && pos < 15 )
2950 {
2951 pos++;
2952 }
2953 else if ( get_pcvar_num(kz_top15_authid) == 1)
2954 while( !equal(Noob_AuthIDS[pos], authid) && pos < 15 )
2955 {
2956 pos++;
2957 }
2958
2959 for (new j = pos; j > i; j--)
2960 {
2961 formatex(Noob_AuthIDS[j], 31, Noob_AuthIDS[j-1])
2962 formatex(Noob_Names[j], 31, Noob_Names[j-1])
2963 formatex(Noob_Date[j], 31, Noob_Date[j-1])
2964 formatex(Noob_Weapon[j], 31, Noob_Weapon[j-1])
2965 Noob_Tiempos[j] = Noob_Tiempos[j-1]
2966 Noob_CheckPoints[j] = Noob_CheckPoints[j-1]
2967 Noob_GoChecks[j] = Noob_GoChecks[j-1]
2968 }
2969
2970 formatex(Noob_AuthIDS[i], 31, authid);
2971 formatex(Noob_Names[i], 31, name);
2972 formatex(Noob_Date[i], 31, thetime)
2973 formatex(Noob_Weapon[i], 31, g_weaponsnames[wpn])
2974 Noob_Tiempos[i] = time
2975 Noob_CheckPoints[i] = checkpoints
2976 Noob_GoChecks[i] = gochecks
2977
2978 save_Noob15()
2979
2980 if( Is_in_noob15 )
2981 {
2982
2983 if( time < noobtiempo )
2984 {
2985 new min, Float:sec;
2986 min = floatround(faster, floatround_floor)/60;
2987 sec = faster - (60*min);
2988 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
2989
2990 if( (i + 1) == 1)
2991 {
2992 client_cmd(0, "spk %s", SONIDO_WAV);
2993 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2994 }
2995 else
2996 {
2997 client_cmd(0, "spk buttons/bell1");
2998 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2999 }
3000 }
3001 }
3002 else
3003 {
3004 if( (i + 1) == 1)
3005 {
3006 client_cmd(0, "spk %s", SONIDO_WAV);
3007 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
3008 }
3009 else
3010 {
3011 client_cmd(0, "spk buttons/bell1");
3012 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
3013 }
3014 }
3015 return;
3016 }
3017
3018 if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
3019 {
3020 if( time > noobtiempo )
3021 {
3022
3023 new min, Float:sec;
3024 min = floatround(slower, floatround_floor)/60;
3025 sec = slower - (60*min);
3026 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
3027 return;
3028 }
3029 }
3030
3031 }
3032}
3033}
3034
3035//Stock Steam Players
3036stock bool:is_user_steam(auth[])
3037return bool:(contain(auth, "STEAM_0:0:") != -1 || contain(auth, "STEAM_0:1:") != -1);
3038
3039
3040public save_Noob15()
3041{
3042 new profile[128]
3043 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
3044
3045 if( file_exists(profile) )
3046 {
3047 delete_file(profile)
3048 }
3049
3050 new Data[256];
3051 new f = fopen(profile, "at")
3052
3053 for(new i = 0; i < 15; i++)
3054 {
3055 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%i^" ^"%i^" ^"%s^" ^"%s^" ^n", Noob_Tiempos[i], Noob_AuthIDS[i], Noob_Names[i], Noob_CheckPoints[i], Noob_GoChecks[i],Noob_Date[i],Noob_Weapon[i])
3056 fputs(f, Data)
3057 }
3058 fclose(f);
3059}
3060
3061public read_Noob15()
3062{
3063 new profile[128], prodata[256]
3064 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
3065
3066 new f = fopen(profile, "rt" )
3067 new i = 0
3068 while( !feof(f) && i < 16)
3069 {
3070 fgets(f, prodata, 255)
3071 new totime[25], checks[5], gochecks[5]
3072 parse(prodata, totime, 24, Noob_AuthIDS[i], 31, Noob_Names[i], 31, checks, 4, gochecks, 4, Noob_Date[i], 31, Noob_Weapon[i], 31)
3073 Noob_Tiempos[i] = str_to_float(totime)
3074 Noob_CheckPoints[i] = str_to_num(checks)
3075 Noob_GoChecks[i] = str_to_num(gochecks)
3076 i++;
3077 }
3078 fclose(f)
3079}
3080
3081public ProTop_show(id)
3082{
3083 new buffer[2048], len, name[32]
3084
3085 len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
3086 len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#0052FF><th width=5%%> # <th width=45%% align=center> Player <th width=30%%> Time <th width=20%%> Date ")
3087
3088 for (new i = 0; i < 10; i++)
3089 {
3090 name = Pro_Names[i]
3091
3092 if( Pro_Times[i] > 9999999.0 )
3093 {
3094 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), "", "", "")
3095 }
3096
3097 else
3098 {
3099 new minutos, Float:segundos
3100 minutos = floatround(Pro_Times[i], floatround_floor)/60
3101 segundos = Pro_Times[i] - (60*minutos)
3102
3103 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> <b>%02d:%s%.2f <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), Pro_Names[i], minutos, segundos < 10 ? "0" : "", segundos, Pro_Date[i])
3104
3105 }
3106 }
3107
3108 len += formatex(buffer[len], 2047-len, "</table></body>")
3109 len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by nucLeaR - warpsedit :*")
3110
3111 show_motd(id, buffer, "Pro10 Climbers")
3112
3113 return PLUGIN_HANDLED
3114}
3115
3116public NoobTop_show(id)
3117{
3118 new buffer[2048], name[32], len
3119
3120 len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
3121 len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#0052FF><th width=5%%> # <th width=35%% align=center> Player <th width=20%%> Time <th width=10%%> CPs <th width=10%%> TPs <th width=10%%> Date")
3122
3123 for (new i = 0; i < 10; i++)
3124 {
3125 if( Noob_Tiempos[i] > 9999999.0 )
3126 {
3127 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), "", "", "", "", "")
3128 }
3129
3130 else
3131 {
3132 name = Noob_Names[i]
3133 new minutos, Float:segundos
3134 minutos = floatround(Noob_Tiempos[i], floatround_floor)/60
3135 segundos = Noob_Tiempos[i] - (60*minutos)
3136
3137 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s%s <td> <b>%02d:%s%.2f <td> %d <td> %d <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), Noob_Names[i], equal(Noob_Weapon[i],"scout") ? "(scout)" : "", minutos, segundos < 10 ? "0" : "", segundos, Noob_CheckPoints[i], Noob_GoChecks[i], Noob_Date[i], Noob_Weapon[i])
3138 }
3139 }
3140
3141 len += formatex(buffer[len], 2047-len, "</table></body>")
3142 len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by nucLeaR - warpsedit :*")
3143
3144 show_motd(id, buffer, "Noob10 Climbers")
3145
3146 return PLUGIN_HANDLED
3147}
3148#endif
3149
3150// You reached the end of file
3151// The original plugin was made by p4ddY
3152// This plugin was edited by nucLeaR
3153// Version 2.31