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