· 8 years ago · May 19, 2018, 06:06 AM
1#include <amxmodx>
2#include <amxmisc>
3#include <hamsandwich>
4#include <colorchat>
5#include <fakemeta>
6#include <sqlx>
7#include <nvault>
8#include <cstrike>
9#include <bfmod>
10#include <fun>
11
12#define PLUGIN_VERSION "2.0.7"
13#define g_szPrefixName "Battlefield"
14
15#define PRIMARY_WEAPON ((1 << CSW_SCOUT) | (1 << CSW_XM1014) | (1 << CSW_MAC10) | (1 << CSW_AUG) | (1 << CSW_UMP45) | (1 << CSW_SG550) | (1 << CSW_GALIL) | (1 << CSW_FAMAS) | (1 << CSW_AWP) | (1 << CSW_MP5NAVY) | (1 << CSW_M249) | (1 << CSW_M3) | (1 << CSW_M4A1) | (1 << CSW_TMP) | (1 << CSW_G3SG1) | (1 << CSW_SG552) | (1 << CSW_AK47) | (1 << CSW_P90))
16#define SECONDARY_WEAPON ((1 << CSW_P228) | (1 << CSW_ELITE) | (1 << CSW_FIVESEVEN) | (1 << CSW_USP) | (1 << CSW_GLOCK18) | (1 << CSW_DEAGLE))
17#define NO_BPAMMO ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
18#define NO_RELOAD ((1 << 2) | (1 << CSW_KNIFE) | (1 << CSW_C4) | (1 << CSW_M3) | (1 << CSW_XM1014) | (1 << CSW_HEGRENADE) | (1 << CSW_FLASHBANG) | (1 << CSW_SMOKEGRENADE))
19#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0))
20#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
21#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame
22
23#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
24
25const TASK_HEAL = 12345;
26const TASK_DISTANCE = 12346;
27const TASK_GIVE = 12347;
28const TASK_DISTGIVE = 12348;
29const BLEED_ENT = 25;
30
31const OFFSET_PRIMARYWEAPON = 116;
32const OFFSET_C4_SLOT = 372;
33const m_afButtonPressed = 246;
34const m_afButtonReleased = 247;
35const m_pActiveItem = 373;
36const m_iID = 43;
37const m_pPlayer = 41;
38const m_fInReload = 54;
39const m_iClip = 51;
40const m_LastHitGroup = 75;
41
42const MAX_PLAYERS = 32;
43
44enum _:CVARS
45{
46 CVAR_ENABLED, CVAR_SAVEMODE, CVAR_ANNOUNCE, CVAR_KNIFEBONUS, CVAR_KNIFESTREAK, CVAR_KNIFESTREAKBONUS, CVAR_HSSTREAKBONUS, CVAR_HSSTREAK, CVAR_KILLSTREAK,
47 CVAR_KILLSTREAKBONUS, CVAR_HSBONUS, CVAR_KILLXP, CVAR_BOMBBONUS, CVAR_PLANTBONUS,
48 CVAR_EXPBONUS, CVAR_DEFUSEBONUS, CVAR_TARGSAVBONUS, CVAR_HOSTRESBONUS, CVAR_HOSTNRESBONUS,CVAR_TK, CVAR_TKXP, CVAR_KNIFE,
49 CVAR_HEALAMOUNT, CVAR_HEALWAIT, CVAR_HEALMIN, CVAR_HEALTIME, CVAR_CALLWAIT,
50 CVAR_HEALBONUS, CVAR_GIVEWAIT, CVAR_MINAMMO, CVAR_GIVETIME, CVAR_AMMOBONUS,
51 CVAR_DEATHMATCH, CVAR_RESPAWNTIME, CVAR_SPTIME, CVAR_SPHUD, CVAR_SPGLOW,
52 CVAR_BLEEDTOGGLE, CVAR_STARTBLEED, CVAR_STOPBLEED, CVAR_BLEEDTIME,
53 CVAR_VFFMIRRORHURT, CVAR_VFFNADES, CVAR_SOUNDTOGGLE
54}
55
56enum _:CLASSES
57{
58 CLASS_NONE, CLASS_ASSAULT, CLASS_SPECOPS, CLASS_SNIPER,
59 CLASS_ENGINEER, CLASS_MEDIC, CLASS_SUPPORT
60}
61
62enum _:RANKS
63{
64 RANK_PVT, RANK_PFC, RANK_SPEC, RANK_CORP, RANK_SGT, RANK_SSGT,
65 RANK_SFC, RANK_MS, RANK_FS, RANK_SM, RANK_WO, RANK_CWO, RANK_SL,
66 RANK_FL, RANK_CAP, RANK_MAJ, RANK_LCOL, RANK_COL, RANK_BGEN,
67 RANK_MAJGEN, RANK_LTGEN, RANK_GEN
68}
69
70enum _:CLASSRANKCVAR
71{
72 CVAR_PWEP, CVAR_SWEP, CVAR_HEALTH, CVAR_ARMOR, CVAR_SPEED, CVAR_GRAVITY
73}
74
75enum _:XPDATA
76{
77 XPTotal, XP[CLASSES], Class, Rank
78}
79
80new const g_ClassDesc[CLASSES][] =
81{
82 "None", "Assault", "Special Ops", "Sniper", "Engineer", "Medic", "Support"
83};
84
85new const g_RankDesc[RANKS][] =
86{
87 "Private", "Private First Class", "Specialist", "Corporal", "Sergeant",
88 "Staff Sergeant", "Sergeant Firs Class", "Master Sergeant", "First Sergeant",
89 "Sergeant Major", "Warrant Officer", "Chief Warrant Officer", "Second Lieutenant",
90 "First Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel",
91 "Brigadier General", "Major General", "Lieutenant General", "General"
92};
93
94new const g_RankXP[RANKS][2] =
95{
96 {0, 6499},
97 {6500, 10999},
98 {11000, 18499},
99 {18500, 27999},
100 {28000, 39999},
101 {40000, 52999},
102 {53000, 67999},
103 {68000, 83999},
104 {84000, 99999},
105 {100000, 119999},
106 {120000, 137999},
107 {138000, 157999},
108 {158000, 178999},
109 {179000, 199999},
110 {200000, 223999},
111 {224000, 246999},
112 {247000, 271999},
113 {272000, 296999},
114 {297000, 322999},
115 {323000, 471999},
116 {472000, 999999},
117 {1000000, 5000000}
118};
119
120//Bot weapons Allowed
121new const g_WeaponNames[][] =
122{
123 "weapon_ak47", "weapon_m4a1", "weapon_aug", "weapon_galil", "weapon_famas", "weapon_scout", "weapon_m249", "weapon_m3", "weapon_mp5navy"
124};
125
126new const g_SettingsCvarDesc[CVARS][] =
127{
128 "toggle", "savemode", "announce", "knifebonus", "knifestreak", "knifestreakbonus", "hsmultixp", "hskills", "killstreak", "killstreakbonus", "hsxp", "killxp", "bomb_bonus", "plantxp", "expxp",
129 "defxp", "targxp", "hostrescxp", "hostnrescxp", "tk_punish", "tk_punishxp", "knifebonus", "healamount", "healwait", "healmin", "healtime", "callwait", "healbonus",
130 "giveammowait", "ammomin", "ammogivetime", "ammogivebonus", "deathmatch", "respawntime", "sptime", "sphud", "spglow", "bleedtoggle",
131 "startbleed", "stopbleed", "bleedtime", "vff_mirrorhurt", "vff_nades", "sound_toggle"
132};
133
134new const g_ClassCvarDesc[CLASSES][] =
135{
136 "", "Assault", "Special", "Sniper", "Engineer", "Medic", "Support"
137};
138
139new const classLimitDesc[CLASSES][] =
140{
141 "", "assault", "specop", "sniper", "engineer", "medic", "support"
142};
143new const classLimitDefault[CLASSES][] =
144{
145 "", "2", "2", "1", "1", "1", "3"
146};
147
148new const g_RankCvarDesc[RANKS][] =
149{
150 "pvt", "pfc", "spe", "cor", "ser", "sser", "sfc","ms", "fs", "sm", "wo", "cwo", "slt", "flt", "cpt", "maj", "ltcol", "col", "bg", "mg", "ltg", "g"
151};
152
153new const g_CvarDesc[CLASSRANKCVAR][] =
154{
155 "pwep", "swep", "Health", "Armor", "Speed", "Gravity"
156};
157
158new g_WeaponBPAmmo[] =
159{
160 0, 52, 0, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120, 30,
161 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, 0, 100
162};
163
164//Class information
165new g_XP[33][XPDATA];
166new g_ClassCounter[CsTeams][CLASSES];
167new CsTeams:g_iPlayerTeam[MAX_PLAYERS+1];
168
169new g_iMaxPlayers;
170
171//Bomb Map stff
172new bool:is_alive[MAX_PLAYERS+1];
173new g_bomb_targ;
174
175//Kill Streaks
176new g_kills[MAX_PLAYERS+1];
177new g_HS[MAX_PLAYERS+1];
178new g_Knifes[MAX_PLAYERS+1];
179
180//XP Stuff
181new gHudSync;
182new gHudSyncXp;
183new g_szAuthID[MAX_PLAYERS+1][35];
184new Handle:g_hTuple;
185new const szTables[][] =
186{
187 "CREATE TABLE IF NOT EXISTS `XpTable` (`player_id` varchar(32) NOT NULL, `player_name` varchar(32) NOT NULL,`player_total_xp` int(16) NOT NULL,`player_class_assault_xp` int(16) NOT NULL,`player_class_specops_xp` int(16) NOT NULL,`player_class_sniper_xp` int(16) NOT NULL,`player_class_engineer_xp` int(16) NOT NULL,`player_class_medic_xp` int(16) NOT NULL,`player_class_support_xp` int(16) NOT NULL,PRIMARY KEY(`player_id`));"
188}
189new g_iVault;
190
191//Menu Stuff
192new g_ClassMenu;
193new bool:g_NewClass[MAX_PLAYERS+1];
194
195//Respawn Stuff
196new bool:bBombPlanted;
197new iTeamInfoCounter[MAX_PLAYERS+1];
198
199//Virtual Reality
200new bool:Is_Bleeding[MAX_PLAYERS+1];
201new g_ent[MAX_PLAYERS+1];
202
203//Cvars
204new g_iFriendlyFirePointer;
205new g_iMirrorDamagePointer;
206new g_Cvar[CLASSRANKCVAR][CLASSES][RANKS];
207new g_Cvar2[CVARS];
208new g_Cvar3[CsTeams][CLASSES];
209
210//Medic And Support
211new gmsgBarTime;
212new g_iTarget[MAX_PLAYERS+1];
213
214//Medic
215new bool:g_bCompetedHeal[MAX_PLAYERS+1];
216new bool:IsHealing[MAX_PLAYERS+1];
217new bool:IsBeingHealed[MAX_PLAYERS+1];
218new g_iMedicCount[CsTeams];
219new g_iMedicID[CsTeams][MAX_PLAYERS+1];
220new Float:g_flLastHeal[MAX_PLAYERS+1];
221new Float:g_flLastMedicCall[MAX_PLAYERS+1];
222
223//Support
224new g_iSupportID[CsTeams][MAX_PLAYERS+1];
225new g_iSupportCount[CsTeams];
226new g_iTargetSecondaryWeapon[MAX_PLAYERS+1];
227new g_iTargetPrimaryWeapon[MAX_PLAYERS+1];
228new bool:g_bCompetedGive[MAX_PLAYERS+1];
229new bool:IsGiving[MAX_PLAYERS+1];
230new bool:IsGetting[MAX_PLAYERS+1];
231new Float:g_flLastAmmoCall[MAX_PLAYERS+1];
232new Float:g_flLastGive[MAX_PLAYERS+1];
233
234
235new const g_medic_calls[][] =
236{
237 "bf/bf_medic_call1.wav",
238 "bf/bf_medic_call2.wav",
239 "bf/bf_medic_call3.wav",
240 "bf/bf_medic_call4.wav"
241};
242
243new const g_medic_done[] = "bf/bf_medic_done.wav";
244new const g_medic_heal[] = "bf/bf_medic_healing.wav";
245
246new const g_Death_Sounds[][] =
247{
248 "bf/bf_death1.wav",
249 "bf/bf_death2.wav",
250 "bf/bf_death3.wav",
251 "bf/bf_death4.wav"
252};
253
254new const g_Ammo_Calls[][] =
255{
256 "bf/bf_needammo1.wav",
257 "bf/bf_needammo2.wav",
258 "bf/bf_needammo3.wav",
259 "bf/bf_needammo4.wav"
260};
261
262new const g_Reload_Sounds[][]=
263{
264 "bf/bf_reload1.wav",
265 "bf/bf_reload2.wav"
266};
267
268new const g_Take_Ammo[][] =
269{
270 "bf/bf_takeammo1.wav",
271 "bf/bf_takeammo2.wav"
272};
273
274new const g_level_up[] = "bf/bf_levelup.wav";
275
276public plugin_init()
277{
278 //Register Plugin and public var
279 register_plugin( "Battlefield Mod XP" , PLUGIN_VERSION , "SavSin" );
280 register_cvar("bfm_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_UNLOGGED); //Public var for seeing all servers and what version
281
282 //Multi Langual Support
283 register_dictionary_colored("bfdictionary.txt");
284
285 //Player Events
286 RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn", 1); //Player Spawn
287 RegisterHam(Ham_TakeDamage, "player", "fwdPlayerHurt"); //Player Hurt Pre (True Armor)
288 RegisterHam(Ham_TakeDamage, "player", "fwdPlayerHurtPost", 1); //Player Hurt Post
289 RegisterHam(Ham_Killed, "player", "fwdPlayerDeath", 1); //Player Death
290 RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fwdPlayerResetMaxSpeedPost", 1); // Player Speed change
291 RegisterHam(Ham_ObjectCaps, "player", "fwdObjectCaps"); // Player Presses Use
292 RegisterHam(Ham_Touch, "item_thighpack", "RemoveWeapons", 1);//Rmoves Thighpack
293 RegisterHam(Ham_Touch, "weaponbox", "RemoveWeapons", 1); //Weapon box spawn
294 RegisterHam(Ham_Touch, "armoury_entity", "RemoveWeapons", 1); //Armor entity Spawn
295
296 //Reload weapon Hook
297 new szWeaponName[20];
298 for(new i = CSW_P228; i <= CSW_P90; i++)
299 {
300 if(NO_RELOAD & (1 << i))
301 continue;
302
303 get_weaponname(i, szWeaponName, charsmax(szWeaponName));
304 RegisterHam(Ham_Weapon_Reload, szWeaponName, "fwdHamWeaponReload", 1);
305 }
306
307 //Checks team information (Switching teams)
308 register_event("TeamInfo", "eTeamInfo", "a");
309
310 //Events for various XP
311 register_logevent("ePlanted", 3, "2=Planted_The_Bomb");
312 register_logevent("eDefused", 3, "2=Defused_The_Bomb");
313 register_logevent("eExplosion", 6, "3=Target_Bombed");
314 register_logevent("eTargetSaved", 6, "3=Target_Saved");
315 register_logevent("eHostages", 6, "2=triggered");
316
317 //Calling for medic
318 register_clcmd("medic_call", "cmdMedicCall");
319 register_clcmd("say /medic", "cmdMedicCall");
320 register_clcmd("say_team /medic", "cmdMedicCall");
321
322 //Calling for Ammo
323 register_clcmd("ammo_call", "cmdAmmoCall");
324 register_clcmd("say /ammo", "cmdAmmoCall");
325 register_clcmd("say_team /ammo", "cmdAmmoCall");
326
327 //class CMDs and Blocking Drop and Suicide and Corpse
328 register_clcmd("say /class" , "cmdSayClass");
329 register_clcmd("say_team /class", "cmdSayClass");
330 register_clcmd("drop", "hookDrop");
331 register_forward(FM_ClientKill, "BlockSuicide");
332 set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
333 register_forward(FM_EmitSound, "FwdEmitSound"); //When sound is emited (blocks use sound)
334
335 //FF commands
336 register_clcmd("say /ff", "sayFFStatus");
337 register_clcmd("say ff", "sayFFStatus");
338 register_clcmd("say_team /ff", "sayFFStatus");
339 register_clcmd("say_team ff", "sayFFStatus");
340
341 //MD Commands
342 register_clcmd("say /md", "sayMDStatus");
343 register_clcmd("say md", "sayMDStatus");
344 register_clcmd("say_team /md", "sayMDStatus");
345 register_clcmd("say_team md", "sayMDStatus");
346
347 //Friendly Fire Pointer
348 g_iFriendlyFirePointer = get_cvar_pointer("mp_friendlyfire");
349 g_iMirrorDamagePointer = get_cvar_pointer("mp_mirrordamage");
350
351 //Sync the hud messages
352 gHudSync = CreateHudSyncObj();
353 gHudSyncXp = CreateHudSyncObj();
354
355 //Max Players
356 g_iMaxPlayers = get_maxplayers();
357
358 //Bar time fro Medic and Support
359 gmsgBarTime = get_user_msgid("BarTime");
360
361 //Find the bomb sites
362 if (fm_find_ent_by_class(-1, "func_bomb_target") || fm_find_ent_by_class(-1, "info_bomb_target"))
363 {
364 g_bomb_targ = true;
365 }
366
367 g_ClassMenu = menu_create("Battlefield" , "HandleClassMenu");
368 new szNum[3];
369
370 for (new i = 1 ; i < sizeof(g_ClassDesc); i++)
371 {
372 num_to_str(i , szNum , charsmax(szNum));
373 menu_additem(g_ClassMenu , g_ClassDesc[ i ] , szNum , 0);
374 }
375
376 menu_setprop(g_ClassMenu , MPROP_EXIT , MEXIT_NEVER);
377
378 RegisterSettingsCvars();
379 RegisterClassRankCvars();
380 MySQLx_Init();
381 g_iVault = nvault_open( "player_xp_data" );
382
383 static iEnt;
384 iEnt = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"));
385
386 set_pev(iEnt, pev_classname, "HudSyncEnt");
387 set_pev(iEnt, pev_nextthink, get_gametime());
388 RegisterHamFromEntity(Ham_Think, iEnt, "HudShow");
389}
390
391public plugin_natives()
392{
393 register_native("rem_user_xp", "_rem_user_xp");
394 register_native("add_user_xp", "_add_user_xp");
395 register_native("get_user_xp", "_get_user_xp");
396 register_native("get_user_totalxp", "_get_user_totalxp");
397 register_native("get_user_class", "_get_user_class");
398 register_native("get_user_rank", "_get_user_rank");
399}
400
401public cz_bot_ham_registerable(id)
402{
403 RegisterHamFromEntity(Ham_Killed, id, "fwdPlayerDeath", 1);
404 RegisterHamFromEntity(Ham_Spawn, id, "fwdPlayerSpawn", 1);
405}
406
407public plugin_precache()
408{
409 for(new i = 0; i < sizeof(g_medic_calls); i++)
410 {
411 precache_sound(g_medic_calls[i]);
412 }
413
414 for(new i = 0; i < sizeof(g_Death_Sounds); i++)
415 {
416 precache_sound(g_Death_Sounds[i]);
417 }
418
419 for(new i = 0; i < sizeof(g_Ammo_Calls); i++)
420 {
421 precache_sound(g_Ammo_Calls[i]);
422 }
423
424 for(new i = 0; i < sizeof(g_Take_Ammo); i++)
425 {
426 precache_sound(g_Take_Ammo[i]);
427 }
428
429 for(new i = 0; i < sizeof(g_Reload_Sounds); i++)
430 {
431 precache_sound(g_Reload_Sounds[i]);
432 }
433
434 precache_sound(g_level_up);
435 precache_sound(g_medic_done);
436 precache_sound(g_medic_heal);
437}
438
439public plugin_cfg()
440{
441 new szConfigDir[64];
442
443 get_configsdir(szConfigDir , charsmax(szConfigDir));
444 format(szConfigDir, charsmax(szConfigDir), "%s/battlefield.cfg", szConfigDir);
445 if(file_exists(szConfigDir))
446 {
447 server_cmd("exec %s" , szConfigDir);
448 server_exec();
449 }
450 else
451 {
452 set_fail_state("Error: CFG Not Found.");
453 }
454
455 register_message(get_user_msgid("StatusIcon") , "Message_StatusIcon");
456}
457
458public Message_StatusIcon(iMsgId, MSG_DEST, id)
459{
460 if(!get_pcvar_num(g_Cvar2[CVAR_ENABLED]))
461 return PLUGIN_HANDLED;
462 static szIcon[5];
463 get_msg_arg_string(2, szIcon, 4);
464 if(szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z')
465 {
466 if(get_msg_arg_int(1))
467 {
468 fm_cs_set_user_nobuy(id);
469 return PLUGIN_HANDLED;
470 }
471 }
472 return PLUGIN_CONTINUE;
473}
474
475public plugin_end()
476{
477 nvault_close( g_iVault );
478}
479
480public client_authorized(id)
481{
482 if(get_pcvar_num(g_Cvar2[CVAR_ENABLED]) && !is_user_bot(id))
483 {
484 get_user_authid(id , g_szAuthID[id] , charsmax(g_szAuthID[]));
485 LoadData(id);
486 }
487}
488
489public client_disconnect(id)
490{
491 if(get_pcvar_num(g_Cvar2[CVAR_ENABLED]) && !is_user_bot(id))
492 {
493 SaveData(id);
494
495 //Clear Medic Assignment
496 if(g_XP[id][Class] == CLASS_MEDIC)
497 {
498 --g_iMedicCount[g_iPlayerTeam[id]];
499 g_iMedicID[g_iPlayerTeam[id]][id] = 0;
500 }
501 //Clear Support Assingment
502 else if(g_XP[id][Class] == CLASS_SUPPORT)
503 {
504 --g_iSupportCount[g_iPlayerTeam[id]];
505 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
506 }
507
508 //Reset Team Info Counter
509 iTeamInfoCounter[id] = 0;
510
511 //Remove his class selection
512 --g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]];
513
514 g_XP[id][Class] = CLASS_NONE;
515 g_XP[id][Rank] = RANK_PVT;
516
517 //Reset his team id
518 g_iPlayerTeam[id] = CS_TEAM_UNASSIGNED;
519 }
520}
521
522public hookDrop(id)
523{
524 new weapon = get_user_weapon(id);
525
526 if(weapon != CSW_C4)
527 {
528 client_print(id, print_center, "%L", id, "HOOK_DROP");
529 return PLUGIN_HANDLED;
530 }
531 return PLUGIN_CONTINUE;
532}
533
534public RemoveWeapons(iEnt)
535{
536 if(pev_valid(iEnt))
537 {
538 new szModelName[32];
539 pev(iEnt, pev_model, szModelName, charsmax(szModelName));
540
541 if(containi(szModelName, "backpack") == -1)
542 {
543 set_pev(iEnt, pev_flags, FL_KILLME);
544 ExecuteHam(Ham_Think, iEnt);
545 }
546 }
547}
548
549public FwdEmitSound(id, iChannel, szSound[])
550{
551 return equal(szSound, "common/wpn_denyselect.wav") ? FMRES_SUPERCEDE:FMRES_IGNORED;
552}
553
554public sayFFStatus(id)
555{
556 client_print_color(0, DontChange, "%L", LANG_PLAYER, "FF_STATUS", get_cvar_float("mp_friendlyfire") ? "^4 ON" : "^3 OFF");
557 return PLUGIN_HANDLED;
558}
559
560public sayMDStatus(id)
561{
562 client_print_color(0, DontChange, "%L", LANG_PLAYER, "MD_STATUS", get_cvar_float("mp_mirrordamage") ? "^4 ON" : "^3 OFF");
563 return PLUGIN_HANDLED;
564}
565
566public BlockSuicide(id)
567{
568 client_print(id, print_center, "%L", id, "SUICIDE");
569 return FMRES_SUPERCEDE;
570}
571
572public fwdPlayerDeath(iVictim, iAttacker, iShouldGib)
573{
574 if(!get_pcvar_num(g_Cvar2[CVAR_ENABLED]))
575 return HAM_IGNORED;
576
577 new HitGroup = get_pdata_int(iVictim, m_LastHitGroup, 5);
578
579 if(get_pcvar_num(g_Cvar2[CVAR_DEATHMATCH]) && !bBombPlanted)
580 {
581 set_task(get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), "RespawnPlayer", iVictim);
582 set_task(0.01, "RespawnHud", iVictim);
583 }
584
585 if(is_user_bleeding(iVictim))
586 {
587 StopBleeding(iVictim);
588 }
589
590 set_pev(iVictim, pev_iuser1, 0);
591
592 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
593 {
594 emit_sound(iVictim, CHAN_VOICE, g_Death_Sounds[random(sizeof(g_Death_Sounds))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
595 }
596
597 g_kills[iVictim] = 0;
598 g_HS[iVictim] = 0;
599 g_Knifes[iVictim] = 0;
600
601 if(!IsPlayer(iAttacker) || is_user_bot(iAttacker))
602 return HAM_IGNORED;
603
604 new weapon = get_user_weapon(iAttacker);
605 new iTempXpHolder[MAX_PLAYERS+1];
606
607 //Checks if Friendly Fire and Subtracts XP
608 if(get_pcvar_num(g_Cvar2[ CVAR_TK ]))
609 {
610 if(get_user_team(iAttacker) == get_user_team(iVictim))
611 {
612 AlterExp(iAttacker, get_pcvar_num(g_Cvar2[ CVAR_TKXP ]), false);
613 }
614 }
615
616 if(g_XP[iAttacker][Rank] == RANK_GEN)
617 {
618 return HAM_IGNORED;
619 }
620
621 //Checks to make sure non Friendly Fire
622 if(cs_get_user_team(iAttacker) != cs_get_user_team(iVictim))
623 {
624 iTempXpHolder[iAttacker] += get_pcvar_num(g_Cvar2[CVAR_KILLXP]);
625 ++g_kills[iAttacker];
626
627 //Adds bonus for Knife Kill
628 if(weapon == CSW_KNIFE)
629 {
630 iTempXpHolder[iAttacker] += get_pcvar_num(g_Cvar2[ CVAR_KNIFEBONUS ]);
631 ++g_Knifes[iAttacker];
632 }
633
634 //Adds bonus for Headshot
635 if(HitGroup == HIT_HEAD)
636 {
637 iTempXpHolder[iAttacker] += get_pcvar_num(g_Cvar2[CVAR_HSBONUS]);
638 ++g_HS[iAttacker];
639 }
640
641 //Adds XP for Kill Streak Bonus
642 if(g_kills[iAttacker] >= get_pcvar_num(g_Cvar2[CVAR_KILLSTREAK]))
643 {
644 iTempXpHolder[iAttacker] += get_pcvar_num(g_Cvar2[CVAR_KILLSTREAKBONUS]);
645 g_kills[iAttacker] = 0;
646 }
647
648 //Adds XP for Knife Streak
649 if(g_Knifes[iAttacker] >= get_pcvar_num(g_Cvar2[CVAR_KNIFESTREAK]))
650 {
651 iTempXpHolder[iAttacker] += get_pcvar_num(g_Cvar2[ CVAR_KNIFESTREAKBONUS ]);
652 g_Knifes[iAttacker] = 0;
653 }
654
655 //Adds XP for HS Streak
656 if(g_HS[iAttacker] >= get_pcvar_num(g_Cvar2[CVAR_HSSTREAK]))
657 {
658 iTempXpHolder[iAttacker] += get_pcvar_num(g_Cvar2[CVAR_HSSTREAKBONUS]);
659 g_HS[iAttacker] = 0;
660 }
661
662 //Adds the XP to the players class
663 AlterExp(iAttacker, iTempXpHolder[iAttacker], true);
664 }
665
666
667 iTempXpHolder[iAttacker] = 0; //Removes the temp xp ammount once its been added to total
668
669 CheckLevel(iAttacker); //Checks the level of the player then saves there Info.
670 return HAM_IGNORED;
671}
672
673public CheckLevel(id)
674{
675 new PlayerName[32];
676 get_user_name(id, PlayerName, charsmax(PlayerName));
677
678 for (new i = 0 ; i < sizeof(g_RankXP) ; i++ )
679 {
680 if (g_RankXP[i][0] <= g_XP[id][XP][g_XP[id][Class]] <= g_RankXP[i][1] )
681 {
682 if(g_XP[id][Rank] != i)
683 {
684 if(g_XP[id][Rank] < i)
685 {
686 if(get_pcvar_num(g_Cvar2[CVAR_ANNOUNCE]) && g_XP[id][Class] != CLASS_NONE)
687 {
688 client_print_color(0, Red, "%L", LANG_PLAYER, "PROMOTION", g_szPrefixName, g_ClassDesc[g_XP[id][Class]], PlayerName, g_RankDesc[i]);
689 }
690 }
691 else
692 {
693 if(get_pcvar_num(g_Cvar2[CVAR_ANNOUNCE]) && g_XP[id][Class] != CLASS_NONE)
694 {
695 client_print_color(0, Red, "%L", LANG_PLAYER, "DEMOTION", g_szPrefixName, g_ClassDesc[g_XP[id][Class]], PlayerName, g_RankDesc[i]);
696 }
697 }
698
699 g_XP[id][Rank] = i;
700
701 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
702 {
703 new szSoundFile[32];
704 format(szSoundFile, charsmax(szSoundFile), "spk sound/%s", g_level_up);
705 client_cmd(id, szSoundFile);
706 }
707 break;
708 }
709 break;
710 }
711 }
712}
713
714public ePlanted()
715{
716 if(!g_Cvar2[CVAR_ENABLED])
717 return PLUGIN_HANDLED;
718
719 for(new i = 1; i <= g_iMaxPlayers; i++)
720 {
721 if(!IsPlayer(i) || g_XP[i][Rank] == RANK_GEN)
722 return PLUGIN_HANDLED;
723
724 if(is_user_alive(i) && get_user_team(i) == 1)
725 {
726 is_alive[i] = true;
727 AlterExp(i, get_pcvar_num(g_Cvar2[CVAR_PLANTBONUS]), true);
728 }
729 bBombPlanted = true;
730 CheckLevel(i);
731 }
732 return PLUGIN_CONTINUE;
733}
734
735public eDefused()
736{
737 if(!g_Cvar2[CVAR_ENABLED])
738 return PLUGIN_HANDLED;
739
740 for(new i = 1; i <= g_iMaxPlayers; i++)
741 {
742 if(!IsPlayer(i) || g_XP[i][Rank] == RANK_GEN)
743 return PLUGIN_HANDLED;
744
745 if(is_user_alive(i) && get_user_team(i) == 2)
746 {
747 AlterExp(i, get_pcvar_num(g_Cvar2[CVAR_DEFUSEBONUS]), true);
748 is_alive[i] = false;
749 }
750 CheckLevel(i);
751 }
752 return PLUGIN_CONTINUE;
753}
754
755public eExplosion()
756{
757 if(!g_Cvar2[CVAR_ENABLED])
758 return PLUGIN_HANDLED;
759
760 for(new i = 1; i <= g_iMaxPlayers; i++)
761 {
762 if(!IsPlayer(i) || g_XP[i][Rank] == RANK_GEN)
763 return PLUGIN_HANDLED;
764
765 if(is_alive[i] && get_user_team(i) == 1)
766 {
767 AlterExp(i, get_pcvar_num(g_Cvar2[CVAR_EXPBONUS]), true);
768 is_alive[i] = false;
769 }
770 CheckLevel(i);
771 }
772 return PLUGIN_CONTINUE;
773}
774
775public eTargetSaved()
776{
777 if(!g_Cvar2[CVAR_ENABLED])
778 return PLUGIN_HANDLED;
779
780 for(new i = 1; i <= g_iMaxPlayers; i++)
781 {
782 if(!IsPlayer(i) || g_XP[i][Rank] == RANK_GEN)
783 return PLUGIN_HANDLED;
784
785 if(is_user_alive(i) && get_user_team(i) == 2)
786 {
787 AlterExp(i, get_pcvar_num(g_Cvar2[CVAR_TARGSAVBONUS]), true);
788 }
789 CheckLevel(i);
790 }
791 return PLUGIN_CONTINUE;
792}
793
794public eHostages()
795{
796 new arg[64];
797 read_logargv(3, arg, 63);
798
799 if(equal(arg, "Hostages_Not_Rescued"))
800 {
801 if(!g_Cvar2[CVAR_ENABLED])
802 return PLUGIN_HANDLED;
803
804 for(new i = 1; i <= g_iMaxPlayers; i++)
805 {
806 if(!IsPlayer(i) || g_XP[i][Rank] == RANK_GEN)
807 return PLUGIN_HANDLED;
808
809 if(is_user_alive(i) && get_user_team(i) == 1)
810 {
811 AlterExp(i, get_pcvar_num(g_Cvar2[CVAR_HOSTNRESBONUS]), true);
812 }
813 CheckLevel(i);
814 }
815 }
816 else if(equal(arg, "All_Hostages_Rescued"))
817 {
818 if(!g_Cvar2[CVAR_ENABLED])
819 return PLUGIN_HANDLED;
820
821 for(new i = 1; i <= g_iMaxPlayers; i++)
822 {
823 if(!IsPlayer(i) || g_XP[i][Rank] == RANK_GEN)
824 return PLUGIN_HANDLED;
825
826 if(is_user_alive(i) && get_user_team(i) == 2)
827 {
828 AlterExp(i, get_pcvar_num(g_Cvar2[CVAR_HOSTRESBONUS]), true);
829 }
830 CheckLevel(i);
831 }
832 }
833
834 return PLUGIN_CONTINUE;
835}
836
837public eTeamInfo()
838{
839 new id = read_data(1);
840 new szTeam[2];
841 read_data(2, szTeam, charsmax(szTeam));
842 switch(szTeam[0])
843 {
844 case 'T':
845 {
846 if(++iTeamInfoCounter[id] == 2)
847 {
848 if(get_pcvar_num(g_Cvar2[CVAR_DEATHMATCH]) && !is_user_alive(id))
849 {
850 set_task(get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), "RespawnPlayer", id);
851 set_task(0.01, "RespawnHud", id);
852 }
853 }
854
855 if(g_iPlayerTeam[id] == CS_TEAM_SPECTATOR)
856 {
857 if(get_pcvar_num(g_Cvar2[CVAR_DEATHMATCH]) && !bBombPlanted)
858 {
859 set_task(get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), "RespawnPlayer", id);
860 set_task(0.01, "RespawnHud", id);
861 }
862 }
863 else if(g_iPlayerTeam[id] == CS_TEAM_CT)
864 {
865 --g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]];
866 if(g_XP[id][Class] == CLASS_MEDIC)
867 {
868 --g_iMedicCount[g_iPlayerTeam[id]];
869 g_iMedicID[g_iPlayerTeam[id]][id] = 0;
870 }
871 else if(g_XP[id][Class] == CLASS_SUPPORT)
872 {
873 --g_iSupportCount[g_iPlayerTeam[id]];
874 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
875 }
876
877 g_iPlayerTeam[id] = CS_TEAM_T;
878
879 if(g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]] >= get_pcvar_num(g_Cvar3[g_iPlayerTeam[id]][g_XP[id][Class]]))
880 {
881 g_XP[id][Class] = CLASS_NONE;
882 }
883 else
884 {
885 ++g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]];
886 if(g_XP[id][Class] == CLASS_MEDIC)
887 {
888 ++g_iMedicCount[g_iPlayerTeam[id]];
889 g_iMedicID[g_iPlayerTeam[id]][id] = id;
890 }
891 else if(g_XP[id][Class] == CLASS_SUPPORT)
892 {
893 ++g_iSupportCount[g_iPlayerTeam[id]];
894 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
895 }
896 }
897 }
898 g_iPlayerTeam[id] = CS_TEAM_T;
899 }
900 case 'C':
901 {
902 if(++iTeamInfoCounter[id] == 2)
903 {
904 if(get_pcvar_num(g_Cvar2[CVAR_DEATHMATCH]) && !is_user_alive(id))
905 {
906 set_task(get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), "RespawnPlayer", id);
907 set_task(0.01, "RespawnHud", id);
908 }
909 }
910
911 if(g_iPlayerTeam[id] == CS_TEAM_SPECTATOR)
912 {
913 if(get_pcvar_num(g_Cvar2[CVAR_DEATHMATCH]) && !bBombPlanted)
914 {
915 set_task(get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), "RespawnPlayer", id);
916 set_task(0.01, "RespawnHud", id);
917 }
918 }
919 else if(g_iPlayerTeam[id] == CS_TEAM_T)
920 {
921 --g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]];
922 if(g_XP[id][Class] == CLASS_MEDIC)
923 {
924 --g_iMedicCount[g_iPlayerTeam[id]];
925 g_iMedicID[g_iPlayerTeam[id]][id] = 0;
926 }
927 else if(g_XP[id][Class] == CLASS_SUPPORT)
928 {
929 --g_iSupportCount[g_iPlayerTeam[id]];
930 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
931 }
932 g_iPlayerTeam[id] = CS_TEAM_CT;
933
934 if(g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]] >= get_pcvar_num(g_Cvar3[g_iPlayerTeam[id]][g_XP[id][Class]]))
935 {
936 g_XP[id][Class] = CLASS_NONE;
937 }
938 else
939 {
940 ++g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]];
941 if(g_XP[id][Class] == CLASS_MEDIC)
942 {
943 ++g_iMedicCount[g_iPlayerTeam[id]];
944 g_iMedicID[g_iPlayerTeam[id]][id] = id;
945 }
946 else if(g_XP[id][Class] == CLASS_SUPPORT)
947 {
948 ++g_iMedicCount[g_iPlayerTeam[id]];
949 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
950 }
951 }
952 }
953 g_iPlayerTeam[id] = CS_TEAM_CT;
954 }
955 case 'S':
956 {
957 if(g_iPlayerTeam[id] == CS_TEAM_T || g_iPlayerTeam[id] == CS_TEAM_CT)
958 {
959 --g_ClassCounter[g_iPlayerTeam[id]][g_XP[id][Class]];
960 if(g_XP[id][Class] == CLASS_MEDIC)
961 {
962 --g_iMedicCount[g_iPlayerTeam[id]];
963 g_iMedicID[g_iPlayerTeam[id]][id] = 0;
964 }
965 else if(g_XP[id][Class] == CLASS_SUPPORT)
966 {
967 --g_iSupportCount[g_iPlayerTeam[id]];
968 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
969 }
970 remove_task(id);
971 }
972 g_iPlayerTeam[id] = CS_TEAM_SPECTATOR;
973 }
974 }
975}
976
977public fwdHamWeaponReload(const iWeapon)
978{
979 new id = get_pdata_cbase(iWeapon, m_pPlayer, 4);
980
981 if(!is_user_connected(id))
982 return HAM_IGNORED;
983
984 if(get_pdata_int(iWeapon, m_fInReload, 4))
985 {
986 if(pev(id, pev_button) & IN_RELOAD)
987 {
988 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
989 {
990 switch(random(10))
991 {
992 case 1, 3, 5, 7, 9: emit_sound(id, CHAN_VOICE, g_Reload_Sounds[random(sizeof(g_Reload_Sounds))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
993 }
994 }
995 set_pdata_int(iWeapon, m_iClip, 0, 4);
996 }
997 }
998 return HAM_IGNORED;
999}
1000
1001public fwdObjectCaps(id)
1002{
1003 if(!is_user_alive(id))
1004 {
1005 return HAM_IGNORED;
1006 }
1007
1008 if(g_XP[id][Class] == CLASS_MEDIC)
1009 {
1010 if(get_pdata_int(id, m_afButtonPressed, 5) & IN_USE)
1011 {
1012 static target, body;
1013 new Float:Distance = get_user_aiming(id, target, body);
1014
1015 new szClassname[32];
1016 pev(target, pev_classname, szClassname, charsmax(szClassname));
1017 if(!equal(szClassname, "player") && !equal(szClassname, "grenade"))
1018 {
1019 new Float:Time = get_gametime();
1020
1021 if(Time - get_pcvar_float(g_Cvar2[CVAR_HEALWAIT]) > g_flLastHeal[id])
1022 {
1023 new minHealth = floatround(get_pcvar_num(g_Cvar[CVAR_HEALTH][g_XP[id][Class]][g_XP[id][Rank]]) * get_pcvar_float(g_Cvar2[CVAR_HEALMIN]));
1024
1025 if(get_user_health(id) <= minHealth)
1026 {
1027 new healTime = get_pcvar_num(g_Cvar2[CVAR_HEALTIME]);
1028
1029 IsHealing[id] = true;
1030 set_pev(id, pev_maxspeed, 1.0);
1031 g_bCompetedHeal[id] = false;
1032 Create_BarTime(id, healTime, 0);
1033 set_task(float(healTime), "HealPlayer", id+TASK_HEAL);
1034 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
1035 {
1036 emit_sound(id, CHAN_VOICE, g_medic_heal, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1037 }
1038
1039 if(is_user_bleeding(id))
1040 {
1041 StopBleeding(id);
1042 }
1043
1044 g_iTarget[id] = id;
1045 g_flLastHeal[id] = Time;
1046 }
1047 else
1048 {
1049 client_print(id, print_center, "%L", id, "HEAL_SELF_NN_HP", minHealth);
1050 }
1051 }
1052 }
1053
1054 else if(!equal(szClassname, "grenade") && get_user_team(id) == get_user_team(target) && !is_user_bot(target))
1055 {
1056 new Float:Time = get_gametime();
1057
1058 if(Time - get_pcvar_float(g_Cvar2[CVAR_HEALWAIT]) > g_flLastHeal[id])
1059 {
1060 new iTargetClass = g_XP[target][Class];
1061 new iTargetRank = g_XP[target][Rank];
1062 new minHealth = floatround(get_pcvar_num(g_Cvar[CVAR_HEALTH][iTargetClass][iTargetRank]) * get_pcvar_float(g_Cvar2[CVAR_HEALMIN]));
1063
1064 if(Distance <= 50.0)
1065 {
1066 if(get_user_health(target) <= minHealth)
1067 {
1068
1069 new healTime = get_pcvar_num(g_Cvar2[CVAR_HEALTIME]);
1070
1071 IsBeingHealed[target] = true;
1072 IsHealing[id] = true;
1073 set_pev(target, pev_maxspeed, 1.0);
1074 set_pev(id, pev_maxspeed, 1.0);
1075 Create_BarTime(id, healTime, 0);
1076 Create_BarTime(target, healTime, 0);
1077 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
1078 {
1079 emit_sound(id, CHAN_VOICE, g_medic_heal, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1080 }
1081 g_bCompetedHeal[id] = false;
1082
1083 set_task(float(healTime), "HealPlayer", id+TASK_HEAL);
1084
1085 if(is_user_bleeding(target))
1086 {
1087 StopBleeding(target);
1088 }
1089
1090 g_iTarget[id] = target;
1091 g_flLastHeal[id] = Time;
1092 }
1093 else
1094 {
1095 client_print(id, print_center, "%L", id, "HEAL_TEAM_NN_HP");
1096 }
1097 }
1098 else
1099 {
1100 if(get_user_health(target) <= minHealth)
1101 {
1102 client_print(id, print_center, "%L", id, "HEAL_TEAM_N_HP");
1103 }
1104 else
1105 {
1106 client_print(id, print_center, "%L", id, "HEAL_TEAM_NN_HP");
1107 }
1108 }
1109 }
1110 else
1111 {
1112 new Result = floatround(g_flLastHeal[id] - (Time - get_pcvar_float(g_Cvar2[CVAR_HEALWAIT])));
1113
1114 client_print(id, print_center, "%L", id, "HEAL_COOL_DOWN", Result);
1115 }
1116 }
1117 }
1118 else if(get_pdata_int(id, m_afButtonReleased, 5) & IN_USE)
1119 {
1120 if(!g_bCompetedHeal[id])
1121 {
1122 g_flLastHeal[id] = 0.0;
1123 }
1124 StopHealing(id);
1125 return HAM_IGNORED;
1126 }
1127 }
1128
1129 if(g_XP[id][Class] == CLASS_SUPPORT)
1130 {
1131 if(get_pdata_int(id, m_afButtonPressed, 5) & IN_USE)
1132 {
1133 static target, body;
1134 new Float:Distance = get_user_aiming(id, target, body);
1135
1136 //Give Your self ammo
1137 new szClassname[32];
1138 pev(target, pev_classname, szClassname, charsmax(szClassname));
1139
1140 if(!equal(szClassname, "player") && !equal(szClassname, "grenade"))
1141 {
1142 new Float:Time = get_gametime();
1143
1144 if(Time - get_pcvar_float(g_Cvar2[CVAR_GIVEWAIT]) > g_flLastGive[id])
1145 {
1146 new currentPrimaryAmmo;
1147 new currentSecondaryAmmo;
1148 new maxPrimaryAmmo;
1149 new maxSecondaryAmmo;
1150 new szWeapon[32], iWeapons[32], iWeaponNum;
1151
1152 get_user_weapons(id, iWeapons, iWeaponNum);
1153
1154 for(new i = 0; i < iWeaponNum; i++)
1155 {
1156 get_weaponname(iWeapons[i], szWeapon, charsmax(szWeapon));
1157
1158 if(NO_BPAMMO & (1 << iWeapons[i]))
1159 continue;
1160
1161 if(PRIMARY_WEAPON & (1 << iWeapons[i]))
1162 {
1163 g_iTargetPrimaryWeapon[id] = iWeapons[i];
1164 currentPrimaryAmmo = cs_get_user_bpammo(id, iWeapons[i]);
1165 maxPrimaryAmmo = g_WeaponBPAmmo[iWeapons[i]];
1166 }
1167 if(SECONDARY_WEAPON & (1 << iWeapons[i]))
1168 {
1169 g_iTargetSecondaryWeapon[id] = iWeapons[i];
1170 currentSecondaryAmmo = cs_get_user_bpammo(id, iWeapons[i]);
1171 maxSecondaryAmmo = g_WeaponBPAmmo[iWeapons[i]];
1172 }
1173 }
1174
1175 new minPrimaryAmmo = floatround(maxPrimaryAmmo * get_pcvar_float(g_Cvar2[CVAR_MINAMMO]));
1176 new minSecondaryAmmo = floatround(maxSecondaryAmmo * get_pcvar_float(g_Cvar2[CVAR_MINAMMO]));
1177
1178 if(currentPrimaryAmmo <= minPrimaryAmmo || currentSecondaryAmmo <= minSecondaryAmmo)
1179 {
1180 new giveTime = get_pcvar_num(g_Cvar2[CVAR_GIVETIME]);
1181
1182 IsGiving[id] = true;
1183 set_pev(id, pev_maxspeed, 1.0);
1184 Create_BarTime(id, giveTime, 0);
1185 g_bCompetedGive[id] = false;
1186
1187 set_task(float(giveTime), "GivePlayerAmmo", id+TASK_GIVE);
1188
1189 g_iTarget[id] = id;
1190 g_flLastGive[id] = Time;
1191 }
1192 else
1193 {
1194 client_print(id, print_center, "%L", id, "AMMO_SELF_NN");
1195 }
1196 }
1197 else
1198 {
1199 new Result = floatround(g_flLastGive[id] - (Time - get_pcvar_float(g_Cvar2[CVAR_GIVEWAIT])));
1200
1201 client_print(id, print_center, "%L", id, "AMMO_COOL_DOWN", Result);//Same as Other Line
1202 }
1203 }
1204 else if(!equal(szClassname, "grenade") && get_user_team(id) == get_user_team(target) && !is_user_bot(target))
1205 {
1206 new Float:Time = get_gametime();
1207
1208 if(Time - get_pcvar_float(g_Cvar2[CVAR_GIVEWAIT]) > g_flLastGive[id])
1209 {
1210 new currentPrimaryAmmo;
1211 new currentSecondaryAmmo;
1212 new maxPrimaryAmmo;
1213 new maxSecondaryAmmo;
1214 new szWeapon[32], iWeapons[32], iWeaponNum;
1215
1216 get_user_weapons(target, iWeapons, iWeaponNum);
1217
1218 for(new i = 0; i < iWeaponNum; i++)
1219 {
1220 get_weaponname(iWeapons[i], szWeapon, charsmax(szWeapon));
1221
1222 if(NO_BPAMMO & (1 << iWeapons[i]))
1223 continue;
1224
1225 if(PRIMARY_WEAPON & (1 << iWeapons[i]))
1226 {
1227 g_iTargetPrimaryWeapon[target] = iWeapons[i];
1228 currentPrimaryAmmo = cs_get_user_bpammo(target, iWeapons[i]);
1229 maxPrimaryAmmo = g_WeaponBPAmmo[iWeapons[i]];
1230 }
1231 if(SECONDARY_WEAPON & (1 << iWeapons[i]))
1232 {
1233 g_iTargetSecondaryWeapon[target] = iWeapons[i];
1234 currentSecondaryAmmo = cs_get_user_bpammo(target, iWeapons[i]);
1235 maxSecondaryAmmo = g_WeaponBPAmmo[iWeapons[i]];
1236 }
1237 }
1238
1239 new minPrimaryAmmo = floatround(maxPrimaryAmmo * get_pcvar_float(g_Cvar2[CVAR_MINAMMO]));
1240 new minSecondaryAmmo = floatround(maxSecondaryAmmo * get_pcvar_float(g_Cvar2[CVAR_MINAMMO]));
1241
1242 if(currentPrimaryAmmo <= minPrimaryAmmo || currentSecondaryAmmo <= minSecondaryAmmo)
1243 {
1244 if(Distance <= 50.0)
1245 {
1246 new giveTime = get_pcvar_num(g_Cvar2[CVAR_GIVETIME]);
1247
1248 IsGiving[id] = true;
1249 IsGetting[target] = true;
1250 set_pev(id, pev_maxspeed, 1.0);
1251 set_pev(target, pev_maxspeed, 1.0);
1252 Create_BarTime(id, giveTime, 0);
1253 Create_BarTime(target, giveTime, 0);
1254 emit_sound(id, CHAN_VOICE, g_Take_Ammo[random(sizeof(g_Take_Ammo))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1255 g_bCompetedGive[id] = false;
1256 set_task(float(giveTime), "GivePlayerAmmo", id+TASK_GIVE);
1257
1258 g_iTarget[id] = target;
1259 g_flLastGive[id] = Time;
1260 }
1261 else
1262 {
1263 client_print(id, print_center, "%L", id, "AMMO_TEAM_N");
1264 }
1265 }
1266 else
1267 {
1268 client_print(id, print_center, "%L", id, "AMMO_TEAM_NN");
1269 }
1270 }
1271 else
1272 {
1273 new Result = floatround(g_flLastGive[id] - (Time - get_pcvar_float(g_Cvar2[CVAR_GIVEWAIT])));
1274
1275 client_print(id, print_center, "%L", id, "AMMO_COOL_DOWN", Result); //Same as 1189
1276 }
1277 }
1278 }
1279 else if(get_pdata_int(id, m_afButtonReleased, 5) & IN_USE)
1280 {
1281 StopGiving(id);
1282 if(!g_bCompetedGive[id])
1283 {
1284 g_flLastGive[id] = 0.0;
1285 }
1286 return HAM_IGNORED;
1287 }
1288 }
1289 return HAM_IGNORED;
1290}
1291
1292public GivePlayerAmmo(taskid)
1293{
1294 new id = taskid - TASK_GIVE;
1295
1296 cs_set_user_bpammo(g_iTarget[id], g_iTargetPrimaryWeapon[g_iTarget[id]], g_WeaponBPAmmo[g_iTargetPrimaryWeapon[g_iTarget[id]]]);
1297 cs_set_user_bpammo(g_iTarget[id], g_iTargetSecondaryWeapon[g_iTarget[id]], g_WeaponBPAmmo[g_iTargetSecondaryWeapon[g_iTarget[id]]]);
1298
1299
1300 if(g_iTarget[id] != id)
1301 {
1302 AlterExp(id, get_pcvar_num(g_Cvar2[CVAR_AMMOBONUS]), true);
1303
1304 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
1305 {
1306 emit_sound(id, CHAN_VOICE, g_medic_done, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1307 }
1308 }
1309 g_bCompetedGive[id] = true;
1310 StopGiving(id);
1311}
1312
1313public StopGiving(id)
1314{
1315 remove_task(id+TASK_DISTGIVE);
1316 remove_task(id+TASK_GIVE);
1317 Create_BarTime(id, 0, 0);
1318 Create_BarTime(g_iTarget[id], 0, 0);
1319 set_pev(id, pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][g_XP[id][Class]][g_XP[id][Rank]]));
1320 set_pev(g_iTarget[id], pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][g_XP[g_iTarget[id]][Class]][g_XP[g_iTarget[id]][Rank]]));
1321 IsGetting[g_iTarget[id]] = false;
1322 IsGiving[id] = false;
1323 g_iTarget[id] = 0;
1324}
1325
1326public HealPlayer(taskid)
1327{
1328 new id = taskid - TASK_HEAL;
1329
1330 new iRankTarget = g_XP[g_iTarget[id]][Rank];
1331 new iClassTarget = g_XP[g_iTarget[id]][Class];
1332
1333 new health = get_user_health(g_iTarget[id]);
1334 new healAmount = get_pcvar_num(g_Cvar2[CVAR_HEALAMOUNT]);
1335 new maxHealth = get_pcvar_num(g_Cvar[CVAR_HEALTH][iClassTarget][iRankTarget]);
1336
1337 if(health + healAmount > maxHealth)
1338 {
1339 set_user_health(g_iTarget[id], maxHealth);
1340 }
1341 else
1342 {
1343 set_user_health(g_iTarget[id], health + healAmount);
1344 }
1345
1346 if(g_iTarget[id] != id)
1347 {
1348 AlterExp(id, get_pcvar_num(g_Cvar2[ CVAR_HEALBONUS]), true);
1349
1350 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
1351 {
1352 emit_sound(id, CHAN_VOICE, g_medic_done, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1353 }
1354 }
1355 g_bCompetedHeal[id] = true;
1356 StopHealing(id);
1357}
1358
1359public StopHealing(id)
1360{
1361 remove_task(id+TASK_DISTANCE);
1362 remove_task(id+TASK_HEAL);
1363 Create_BarTime(id, 0, 0);
1364 Create_BarTime(g_iTarget[id], 0, 0);
1365 IsBeingHealed[g_iTarget[id]] = false;
1366 IsHealing[id] = false;
1367 set_pev(id, pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][g_XP[id][Class]][g_XP[id][Rank]]));
1368 set_pev(g_iTarget[id], pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][g_XP[g_iTarget[id]][Class]][g_XP[g_iTarget[id]][Rank]]));
1369 g_iTarget[id] = 0;
1370}
1371
1372public fwdPlayerResetMaxSpeedPost(id)
1373{
1374
1375 if(is_user_connected(id))
1376 {
1377 new weapon = get_pdata_cbase(id, m_pActiveItem, 5);
1378
1379 if(!pev_valid(weapon))
1380 return HAM_IGNORED;
1381
1382 new weaponid = get_pdata_int(weapon, m_iID, 4);
1383 new iClass = g_XP[id][Class];
1384 new iRank = g_XP[id][Rank];
1385
1386 if(iClass == CLASS_NONE)
1387 return HAM_IGNORED;
1388
1389 if(iClass == CLASS_SNIPER)
1390 {
1391 switch(weaponid)
1392 {
1393 case CSW_KNIFE:
1394 {
1395 set_pev(id, pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][iClass][iRank]) + 175.0);
1396 set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255);
1397 }
1398 case CSW_USP, CSW_DEAGLE:
1399 {
1400 set_pev(id, pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][iClass][iRank]) + 100.0);
1401 set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha, 150);
1402 }
1403 case CSW_AWP, CSW_SCOUT, CSW_G3SG1:
1404 {
1405 set_pev(id, pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][iClass][iRank]) + 70.0);
1406 set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha, 75);
1407 }
1408 }
1409 }
1410 else
1411 {
1412 set_pev(id, pev_maxspeed, get_pcvar_float(g_Cvar[CVAR_SPEED][iClass][iRank]));
1413 }
1414
1415 if(IsGiving[id] || IsGetting[id] || IsHealing[id] || IsBeingHealed[id])
1416 {
1417 set_pev(id, pev_maxspeed, 1.0);
1418 }
1419 }
1420
1421 return HAM_IGNORED;
1422}
1423
1424public fwdPlayerHurt(iVictim, iInflictor, iAttacker, Float:flDamage, iDmgBits)
1425{
1426 if(is_user_connected(iAttacker) // Makes sure valid target
1427 && get_user_team(iAttacker) == get_user_team(iVictim)) //Checks if the same team
1428 {
1429 new iVictimClass = g_XP[iVictim][Class];
1430
1431 if(iVictimClass == CLASS_NONE)
1432 return HAM_IGNORED;
1433 if(get_pcvar_float(g_iFriendlyFirePointer))
1434 {
1435 new Float:flNewDamage = (flDamage * 2.86 ) * floatclamp(get_pcvar_float(g_iFriendlyFirePointer), 0.0, 1.0);
1436 new Float:flMirrorDamage = (flDamage * 2.86 ) * floatclamp(get_pcvar_float(g_iMirrorDamagePointer), 0.0, 1.0);
1437
1438 if(!get_pcvar_num(g_Cvar2[CVAR_VFFNADES]))
1439 {
1440 if(get_pcvar_float(g_iMirrorDamagePointer))
1441 {
1442 if(get_pcvar_num(g_Cvar2[CVAR_VFFMIRRORHURT]))
1443 {
1444 if(iVictimClass == CLASS_SUPPORT)
1445 {
1446 SetHamParamFloat(4, float(TrueArmor(iVictim, flNewDamage)));
1447 }
1448 else
1449 {
1450 SetHamParamFloat(4, flNewDamage);
1451 }
1452 }
1453 else
1454 {
1455 SetHamParamFloat(4, 0.0);
1456 }
1457 ExecuteHam(Ham_TakeDamage, iAttacker, iInflictor, iAttacker, flMirrorDamage, iDmgBits);
1458 client_print(iAttacker, print_center, "%L", iAttacker, "MIRROR_NOTIF");
1459 return HAM_SUPERCEDE;
1460 }
1461 else
1462 {
1463 if(iVictimClass == CLASS_SUPPORT)
1464 {
1465 SetHamParamFloat(4, float(TrueArmor(iVictim, flNewDamage)));
1466 }
1467 else
1468 {
1469 SetHamParamFloat(4, flNewDamage);
1470 }
1471 return HAM_OVERRIDE;
1472 }
1473 }
1474 else
1475 {
1476 if(get_user_weapon(iAttacker) != CSW_HEGRENADE)
1477 {
1478 if(get_pcvar_float(g_iMirrorDamagePointer))
1479 {
1480 if(get_pcvar_num(g_Cvar2[CVAR_VFFMIRRORHURT]))
1481 {
1482 if(iVictimClass == CLASS_SUPPORT)
1483 {
1484 SetHamParamFloat(4, float(TrueArmor(iVictim, flNewDamage)));
1485 }
1486 else
1487 {
1488 SetHamParamFloat(4, flNewDamage);
1489 }
1490 }
1491 else
1492 {
1493 SetHamParamFloat(4, float(TrueArmor(iVictim, flNewDamage)));
1494 }
1495
1496 ExecuteHam(Ham_TakeDamage, iAttacker, iInflictor, iAttacker, flMirrorDamage, iDmgBits);
1497 client_print(iAttacker, print_center, "%L", iAttacker, "MIRROR_NOTIF");
1498 return HAM_SUPERCEDE;
1499 }
1500 else
1501 {
1502 if(iVictimClass == CLASS_SUPPORT)
1503 {
1504 SetHamParamFloat(4, float(TrueArmor(iVictim, flNewDamage)));
1505 }
1506 else
1507 {
1508 SetHamParamFloat(4, flNewDamage);
1509 }
1510 return HAM_OVERRIDE;
1511 }
1512 return HAM_OVERRIDE;
1513 }
1514 }
1515 }
1516 }
1517 return HAM_IGNORED;
1518}
1519
1520public TrueArmor(id, Float:flDamage)
1521{
1522 new CsArmorType:iPlayerArmorType;
1523 new Float:armor = float(cs_get_user_armor(id, iPlayerArmorType));
1524 if(armor > 0)
1525 {
1526 new Float:new_armor = armor - flDamage;
1527
1528 if(new_armor < 0)
1529 {
1530 cs_set_user_armor(id, 0, CS_ARMOR_NONE);
1531 return floatround(flDamage - armor);
1532 }
1533 else
1534 {
1535 cs_set_user_armor(id, floatround(new_armor, floatround_round), CS_ARMOR_VESTHELM);
1536 return 0;
1537 }
1538 }
1539 else
1540 {
1541 return floatround(flDamage);
1542 }
1543 return PLUGIN_CONTINUE;
1544}
1545
1546public fwdPlayerHurtPost(iVictim, iInflictor, iAttacker, Float:flDamage, iDmgbits)
1547{
1548 new iVictimClass = g_XP[iVictim][Class];
1549 new iVictimRank = g_XP[iVictim][Rank];
1550
1551 if(iVictimClass == CLASS_NONE)
1552 return HAM_IGNORED;
1553
1554 if(is_user_alive(iVictim) && get_pcvar_num(g_Cvar2[CVAR_BLEEDTOGGLE]) && !is_user_bleeding(iVictim))
1555 {
1556 new playerHealth = get_user_health(iVictim);
1557 new minHealth = floatround(get_pcvar_num(g_Cvar[CVAR_HEALTH][iVictimClass][iVictimRank]) * get_pcvar_float(g_Cvar2[CVAR_STARTBLEED]));
1558 if(playerHealth <= minHealth)
1559 {
1560 CreateFollowEnt(iVictim);
1561 }
1562 }
1563 return HAM_IGNORED;
1564}
1565
1566public fwdPlayerSpawn(id)
1567{
1568 if(!g_Cvar2[CVAR_ENABLED])
1569 return PLUGIN_HANDLED;
1570
1571 if(is_user_bot(id))
1572 {
1573 set_task(0.1, "protect", id);
1574 strip_user_weapons(id);
1575 give_item(id, "weapon_knife");
1576
1577 new iRandomWeapon = random(sizeof(g_WeaponNames) - 1);
1578 new iWeaponID = get_weaponid(g_WeaponNames[iRandomWeapon]);
1579
1580 give_item(id, g_WeaponNames[iRandomWeapon]);
1581 cs_set_user_bpammo(id, iWeaponID, g_WeaponBPAmmo[iWeaponID]);
1582 }
1583 else
1584 {
1585 bBombPlanted = false;
1586
1587 if(is_user_connected(id) && is_user_alive(id))
1588 {
1589
1590 IsBeingHealed[id] = false;
1591 IsHealing[id] = false;
1592 StripUserWeapons(id);
1593
1594 set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha, 255);
1595
1596 if(is_user_bleeding(id))
1597 {
1598 StopBleeding(id);
1599 }
1600
1601 if(g_NewClass[id])
1602 {
1603 --g_ClassCounter[cs_get_user_team(id)][g_XP[id][Class]];
1604 g_XP[id][Class] = CLASS_NONE;
1605 g_NewClass[id] = false;
1606 }
1607
1608 if(g_XP[id][Class] == CLASS_NONE)
1609 {
1610 menu_display(id , g_ClassMenu , 0);
1611 }
1612 else
1613 {
1614 set_task(0.01, "SetSkill", id);
1615 }
1616 if (g_bomb_targ && cs_get_user_team(id) == CS_TEAM_CT)
1617 {
1618 cs_set_user_defuse(id, 1);
1619 }
1620
1621 set_task(0.1, "protect", id);
1622 }
1623 }
1624 return PLUGIN_CONTINUE;
1625}
1626
1627public HandleClassMenu(id , iMenu , iItem)
1628{
1629 new szKey[3] , iSelectedClass , Dummy;
1630 menu_item_getinfo(iMenu , iItem , Dummy , szKey , 2 , "" , 0 , Dummy);
1631
1632 iSelectedClass = str_to_num(szKey);
1633
1634 if(iSelectedClass == CLASS_NONE)
1635 return PLUGIN_HANDLED;
1636
1637 if(g_ClassCounter[g_iPlayerTeam[id]][iSelectedClass] >= get_pcvar_num(g_Cvar3[g_iPlayerTeam[id]][iSelectedClass]))
1638 {
1639 menu_display(id, g_ClassMenu, 0);
1640 client_print_color(id, Red, "%L", id, "CLASS_FULL", g_szPrefixName, g_ClassDesc[iSelectedClass]);
1641 }
1642 else
1643 {
1644 ++g_ClassCounter[g_iPlayerTeam[id]][iSelectedClass];
1645 if(g_XP[id][Class] == CLASS_MEDIC)
1646 {
1647 g_iMedicID[g_iPlayerTeam[id]][id] = 0;
1648 --g_iMedicCount[g_iPlayerTeam[id]];
1649 }
1650 else if(g_XP[id][Class] == CLASS_SUPPORT)
1651 {
1652 --g_iSupportCount[g_iPlayerTeam[id]];
1653 g_iSupportID[g_iPlayerTeam[id]][id] = 0;
1654 }
1655
1656 ChangeClass(id, iSelectedClass);
1657
1658 if(iSelectedClass == CLASS_MEDIC)
1659 {
1660 g_iMedicID[g_iPlayerTeam[id]][id] = id;
1661 ++g_iMedicCount[g_iPlayerTeam[id]];
1662 }
1663 else if(iSelectedClass == CLASS_SUPPORT)
1664 {
1665 ++g_iSupportCount[g_iPlayerTeam[id]];
1666 g_iSupportID[g_iPlayerTeam[id]][id] = id;
1667 }
1668 client_print_color(id, Red, "%L", id, "CHANGE_CLASS", g_szPrefixName);
1669 }
1670
1671 return PLUGIN_HANDLED;
1672}
1673
1674public ChangeClass(id , NewClass)
1675{
1676 new i;
1677
1678 g_XP[id][Class] = NewClass;
1679 g_XP[id][Rank] = 0;
1680
1681
1682 for (i = 0 ; i < sizeof(g_RankXP) ; i++)
1683 {
1684 if (g_RankXP[i][0] <= g_XP[id][XP][NewClass] <= g_RankXP[i][1])
1685 {
1686 g_XP[id][Rank] = i;
1687 break;
1688 }
1689 }
1690
1691 SetSkill(id);
1692
1693 return PLUGIN_HANDLED;
1694}
1695
1696public cmdSayClass(id)
1697{
1698 if(!g_Cvar2[CVAR_ENABLED])
1699 return PLUGIN_HANDLED;
1700
1701 if(g_XP[id][Class] == CLASS_NONE)
1702 {
1703 menu_display(id , g_ClassMenu , 0);
1704 }
1705 else
1706 {
1707 g_NewClass[id] = true;
1708 client_print_color(id, Red, "%L", id, "CHANGE_CLASS_NOTIF", g_szPrefixName);
1709 }
1710 return PLUGIN_HANDLED;
1711}
1712
1713public HudShow(iEnt)
1714{
1715 for(new id = 1; id <= g_iMaxPlayers; id++)
1716 {
1717 ShowHud(id);
1718 }
1719 set_pev(iEnt, pev_nextthink, get_gametime() + 1.0);
1720}
1721
1722public ShowHud(id)
1723{
1724 if(IsPlayer(id) && is_user_connected(id))
1725 {
1726 if(g_XP[id][Class] != CLASS_NONE)
1727 {
1728 set_hudmessage(255, 0, 0, 0.02, 0.26, 0, 0.0, 1.0,_ ,_, -1);
1729 ShowSyncHudMsg(id, gHudSync, "[%L: %s] ^n[%L: %s] ^n[%L: %d / %d]", id, "HUD_CLASS", g_ClassDesc[g_XP[id][Class]], id, "HUD_RANK",g_RankDesc[g_XP[id][Rank]], id, "HUD_XP", g_XP[id][XP][g_XP[id][Class]], ( g_XP[ id ][ Rank ] + 1 )== RANKS ? g_RankXP[ g_XP[ id ][ Rank ] ][ 1 ] : g_RankXP[ g_XP[ id ][ Rank ] + 1 ][ 0 ] );
1730 }
1731 }
1732}
1733
1734public RespawnHud(id)
1735{
1736 set_hudmessage(255, 1, 1, -1.0, 0.3, 0, 6.0, get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), 0.1, 0.2, 4);
1737 show_hudmessage(id, "%L", id, "RESPAWN_HUD", get_pcvar_num(g_Cvar2[CVAR_RESPAWNTIME]));
1738}
1739
1740stock StripUserWeapons(id)
1741{
1742 new iC4Ent = get_pdata_cbase(id, OFFSET_C4_SLOT);
1743
1744 if( iC4Ent > 0 )
1745 {
1746 set_pdata_cbase(id, OFFSET_C4_SLOT, FM_NULLENT);
1747 }
1748
1749 strip_user_weapons(id);
1750 give_item(id, "weapon_knife");
1751 set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0);
1752
1753 if( iC4Ent > 0 )
1754 {
1755 set_pev(id, pev_weapons, pev(id, pev_weapons) | (1<<CSW_C4));
1756 set_pdata_cbase(id, OFFSET_C4_SLOT, iC4Ent);
1757 cs_set_user_bpammo(id, CSW_C4, 1);
1758 cs_set_user_plant(id, 1);
1759 }
1760 return PLUGIN_HANDLED;
1761}
1762
1763public RespawnPlayer(id)
1764{
1765 if(!is_user_connected(id))
1766 return PLUGIN_HANDLED;
1767
1768 ExecuteHamB(Ham_CS_RoundRespawn, id);
1769 return PLUGIN_CONTINUE;
1770}
1771
1772public protect(id)
1773{
1774 set_user_godmode(id, 1);
1775
1776 if(get_pcvar_num(g_Cvar2[CVAR_SPGLOW]))
1777 {
1778
1779 switch(cs_get_user_team(id))
1780 {
1781 case CS_TEAM_T: set_user_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25);
1782 case CS_TEAM_CT: set_user_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25);
1783 }
1784 }
1785
1786 if(get_pcvar_num(g_Cvar2[CVAR_SPHUD]))
1787 {
1788 set_hudmessage(255, 1, 1, -1.0, 0.3, 0, 6.0, get_pcvar_float(g_Cvar2[CVAR_SPTIME]), 0.1, 0.2, 4);
1789 show_hudmessage(id, "%L", id, "SPAWN_PROTECTION");
1790 }
1791
1792 set_task(get_pcvar_float(g_Cvar2[CVAR_SPTIME]), "sp_off", id);
1793 return PLUGIN_HANDLED;
1794}
1795
1796public sp_off(id)
1797{
1798 if(!is_user_connected(id))
1799 return PLUGIN_HANDLED;
1800
1801 set_user_godmode(id, 0);
1802 set_user_rendering(id, kRenderFxGlowShell, 0, 0,0, kRenderNormal, 0);
1803 return PLUGIN_HANDLED;
1804}
1805
1806stock Create_BarTime(id, duration, flag)
1807{
1808
1809 if( is_user_connected(id) && !is_user_bot(id))
1810 {
1811
1812 message_begin(MSG_ONE, gmsgBarTime, {0,0,0}, id);
1813 write_byte(duration); // duration
1814 write_byte(flag);
1815 message_end();
1816
1817 }
1818}
1819
1820public cmdMedicCall(id)
1821{
1822 new Float:Time = get_gametime();
1823 if(Time - g_flLastMedicCall[id] <= get_pcvar_float(g_Cvar2[CVAR_CALLWAIT]))
1824 {
1825 new Result = floatround(g_flLastMedicCall[id] - (Time - get_pcvar_float(g_Cvar2[CVAR_CALLWAIT])));
1826 client_print(id, print_center, "%L", id, "MEDIC_COOL_DOWN", Result);
1827 }
1828 else
1829 {
1830 new iClass = g_XP[id][Class];
1831 new iRank = g_XP[id][Rank];
1832
1833 if(iClass == CLASS_MEDIC)
1834 return PLUGIN_HANDLED;
1835
1836 new szPlayerName[32];
1837 get_user_name(id, szPlayerName, charsmax(szPlayerName));
1838
1839 new minHealth = floatround(get_pcvar_num(g_Cvar[CVAR_HEALTH][iClass][iRank]) * get_pcvar_float(g_Cvar2[CVAR_HEALMIN]));
1840
1841 if(g_iMedicCount[g_iPlayerTeam[id]])
1842 {
1843 if(get_user_health(id) <= minHealth)
1844 {
1845 for(new i = 0; i < g_iMedicCount[g_iPlayerTeam[id]]; i++)
1846 {
1847 client_print(g_iMedicID[g_iPlayerTeam[id]][i], print_center, "%L", id, "MEDIC_CALL_NOTIF", szPlayerName);
1848 }
1849 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
1850 {
1851 emit_sound(id, CHAN_VOICE, g_medic_calls[random(sizeof(g_medic_calls))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1852 }
1853 g_flLastMedicCall[id] = Time;
1854 }
1855 else
1856 {
1857 client_print(id, print_center, "%L", id, "MEDIC_CALL_NN_HP", g_szPrefixName, minHealth);
1858 }
1859 }
1860 else
1861 {
1862 client_print(id, print_center, "%L", id, "MEDIC_CALL_NO_MEDIC");
1863 }
1864 }
1865 return PLUGIN_CONTINUE;
1866}
1867
1868public cmdAmmoCall(id)
1869{
1870 new Float:Time = get_gametime();
1871 if(Time - g_flLastAmmoCall[id] <= get_pcvar_float(g_Cvar2[CVAR_CALLWAIT]))
1872 {
1873 new Result = floatround(g_flLastAmmoCall[id] - (Time - get_pcvar_float(g_Cvar2[CVAR_CALLWAIT])));
1874 client_print(id, print_center, "%L", id, "AMMO_CALL_COOL_DOWN", Result);
1875 }
1876 else
1877 {
1878 new iClass = g_XP[id][Class];
1879
1880 if(iClass == CLASS_SUPPORT)
1881 return PLUGIN_HANDLED;
1882
1883 new szPlayerName[32];
1884 get_user_name(id, szPlayerName, charsmax(szPlayerName));
1885
1886 new currentPrimaryAmmo;
1887 new currentSecondaryAmmo;
1888 new maxPrimaryAmmo;
1889 new maxSecondaryAmmo;
1890 new szWeapon[32], iWeapons[32], iWeaponNum;
1891
1892 get_user_weapons(id, iWeapons, iWeaponNum);
1893
1894 for(new i = 0; i < iWeaponNum; i++)
1895 {
1896 get_weaponname(iWeapons[i], szWeapon, charsmax(szWeapon));
1897
1898 if(NO_BPAMMO & (1 << iWeapons[i]))
1899 continue;
1900
1901 if(PRIMARY_WEAPON & (1 << iWeapons[i]))
1902 {
1903 g_iTargetPrimaryWeapon[id] = iWeapons[i];
1904 currentPrimaryAmmo = cs_get_user_bpammo(id, iWeapons[i]);
1905 maxPrimaryAmmo = g_WeaponBPAmmo[iWeapons[i]];
1906 }
1907 if(SECONDARY_WEAPON & (1 << iWeapons[i]))
1908 {
1909 g_iTargetSecondaryWeapon[id] = iWeapons[i];
1910 currentSecondaryAmmo = cs_get_user_bpammo(id, iWeapons[i]);
1911 maxSecondaryAmmo = g_WeaponBPAmmo[iWeapons[i]];
1912 }
1913 }
1914
1915 new minPrimaryAmmo = floatround(maxPrimaryAmmo * get_pcvar_float(g_Cvar2[CVAR_MINAMMO]));
1916 new minSecondaryAmmo = floatround(maxSecondaryAmmo * get_pcvar_float(g_Cvar2[CVAR_MINAMMO]));
1917
1918 if(g_iSupportCount[g_iPlayerTeam[id]])
1919 {
1920 if(currentPrimaryAmmo <= minPrimaryAmmo || currentSecondaryAmmo <= minSecondaryAmmo)
1921 {
1922 for(new i = 0; i < g_iSupportCount[g_iPlayerTeam[id]]; i++)
1923 {
1924 client_print(g_iSupportID[g_iPlayerTeam[id]][i], print_center, "%L", id, "AMMO_CALL_NOTIF", szPlayerName);
1925 }
1926 if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE]))
1927 {
1928 emit_sound(id, CHAN_VOICE, g_Ammo_Calls[random(sizeof(g_Ammo_Calls))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
1929 }
1930 g_flLastAmmoCall[id] = Time;
1931 }
1932 else
1933 {
1934 client_print(id, print_center, "%L", id, "AMMO_CALL_NN", g_szPrefixName);
1935 }
1936 }
1937 else
1938 {
1939 client_print(id, print_center, "%L", id, "AMMO_CALL_NO_SUPPORT");
1940 }
1941 }
1942 return PLUGIN_CONTINUE;
1943}
1944
1945public CreateFollowEnt(id)
1946{
1947 static ent, HamHook:Think;
1948 ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"));
1949
1950 if(pev_valid(ent))
1951 {
1952 set_pev(ent, pev_aiment, id);
1953 set_pev(ent, pev_movetype, MOVETYPE_FOLLOW);
1954 set_pev(ent, pev_owner, id);
1955 set_pev(ent, pev_iuser1, BLEED_ENT);
1956
1957 set_pev(ent, pev_nextthink, get_gametime() + 1.0);
1958
1959 g_ent[id] = ent;
1960 Is_Bleeding[id] = true;
1961
1962 if(!Think)
1963 {
1964 Think = RegisterHamFromEntity(Ham_Think, ent, "Think_Bleed");
1965 }
1966 }
1967}
1968
1969//Thinking part of ent
1970public Think_Bleed(ent)
1971{
1972 new id = pev(ent, pev_owner);
1973
1974 if(pev(ent, pev_iuser1) == BLEED_ENT && FakeBleed(id))
1975 {
1976 set_pev(ent, pev_nextthink, get_gametime() + random_float(1.0, get_pcvar_float(g_Cvar2[CVAR_BLEEDTIME])));
1977 }
1978}
1979
1980//Preform the bleeding
1981public FakeBleed(id)
1982{
1983 if(!is_user_alive(id) || !is_user_bleeding(id))
1984 return PLUGIN_HANDLED;
1985
1986 new Float:playerHealth;
1987 pev(id, pev_health, playerHealth);
1988 new minHealth = floatround(get_pcvar_num(g_Cvar[CVAR_HEALTH][g_XP[id][Class]][g_XP[id][Rank]]) * get_pcvar_float(g_Cvar2[CVAR_STOPBLEED]));
1989
1990 if(playerHealth <= minHealth)
1991 {
1992 StopBleeding(id);
1993 return PLUGIN_HANDLED;
1994 }
1995
1996 //Begin Connors Bleeding Fucntion
1997 new trace_handled;
1998 new Float:flFraction, Float:fDirection[3];
1999 new Float:start[3], Float:dest[3];
2000
2001 trace_handled = create_tr2();
2002 pev(id, pev_origin, start);
2003
2004 new iOrigin[3];
2005
2006 iOrigin[0] = floatround(start[0]);
2007 iOrigin[1] = floatround(start[1]);
2008 iOrigin[2] = floatround(start[2]);
2009
2010 dest[0] = start[0];
2011 dest[1] = start[1];
2012 dest[2] = start[2] - 9999.0;
2013
2014 engfunc(EngFunc_TraceLine, start, dest, IGNORE_MONSTERS, id, trace_handled);
2015 get_tr2(trace_handled, TR_flFraction, flFraction);
2016
2017 if( flFraction != 1.0 )
2018 {
2019 fDirection[0] = random_float(-1.0, 1.0);
2020 fDirection[1] = random_float(-1.0, 1.0);
2021 fDirection[2] = random_float(-1.0, 0.0);
2022 ExecuteHam(Ham_TraceBleed, id, 50.0, fDirection, trace_handled, DMG_BULLET);
2023 fxBleed(iOrigin);
2024 set_pev(id, pev_health, playerHealth - random_float(1.0, 3.0));
2025 }
2026
2027 free_tr2(trace_handled);
2028 //End Connors Bleeding Function
2029 return 1;
2030}
2031
2032//Blood Squirt effect
2033stock fxBleed(origin[3])
2034{
2035 message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
2036 write_byte(TE_BLOODSTREAM);
2037 write_coord(origin[0]);
2038 write_coord(origin[1]);
2039 write_coord(origin[2]+10);
2040 write_coord(random_num(-360,360));
2041 write_coord(random_num(-360,360));
2042 write_coord(-10);
2043 write_byte(70);
2044 write_byte(random_num(50,100));
2045 message_end();
2046}
2047
2048public bool:is_user_bleeding(id)
2049 return Is_Bleeding[id];
2050
2051public StopBleeding(id)
2052{
2053 if(!pev_valid(g_ent[id]))
2054 return PLUGIN_HANDLED;
2055
2056 set_pev(g_ent[id], pev_flags, FL_KILLME);
2057 g_ent[id] = 0;
2058 Is_Bleeding[id] = false;
2059
2060 return PLUGIN_CONTINUE;
2061}
2062
2063public RegisterSettingsCvars()
2064{
2065 new settingsCvar[64];
2066 for(new iCvar = 0; iCvar < CVARS; iCvar++)
2067 {
2068 formatex(settingsCvar, charsmax(settingsCvar), "bf_%s", g_SettingsCvarDesc[iCvar]);
2069 g_Cvar2[iCvar] = register_cvar(settingsCvar, "");
2070 }
2071
2072 new limitCvar[64];
2073 for(new CsTeams:team = CS_TEAM_T, class; team <= CS_TEAM_CT; team++)
2074 {
2075 for(class = 1; class < CLASSES; class++)
2076 {
2077 formatex(limitCvar, charsmax(limitCvar), "bf_%st%slimit", (team == CS_TEAM_T) ? "" : "c", classLimitDesc[class]);
2078 g_Cvar3[team][class] = register_cvar(limitCvar, classLimitDefault[class]);
2079 }
2080 }
2081}
2082
2083public RegisterClassRankCvars()
2084{
2085 new classRankCvar[64], cvarDesc[8], len, len2;
2086 for(new class = 1, rank, var; class < CLASSES; class++)
2087 {
2088 len = copy(classRankCvar, charsmax(classRankCvar), g_ClassCvarDesc[class]);
2089
2090 for(rank = 0; rank < RANKS; rank++)
2091 {
2092 len2 = len + formatex(classRankCvar[len], charsmax(classRankCvar) - len, "%s_", g_RankCvarDesc[rank]);
2093
2094 for(var = 0; var < CLASSRANKCVAR; var++)
2095 {
2096 copy(cvarDesc, charsmax(cvarDesc), g_CvarDesc[var]);
2097 copy(classRankCvar[len2], charsmax(classRankCvar) - len2, cvarDesc);
2098 g_Cvar[var][class][rank] = register_cvar(classRankCvar, "");
2099 }
2100 }
2101 }
2102}
2103
2104public SetSkill(id)
2105{
2106 new iClass, iRank;
2107 iClass = g_XP[id][Class];
2108 iRank = g_XP[id][Rank];
2109
2110 if(iClass == CLASS_NONE)
2111 return PLUGIN_HANDLED;
2112
2113 new szPwep[32], szSwep[32];
2114
2115 get_pcvar_string(g_Cvar[CVAR_PWEP][iClass][iRank], szPwep, 32);
2116 get_pcvar_string(g_Cvar[CVAR_SWEP][iClass][iRank], szSwep, 32);
2117 new iPrimaryWeaponId = get_weaponid(szPwep);
2118 new iSecondaryWeaponId = get_weaponid(szSwep);
2119
2120 give_item(id, szPwep);
2121 give_item(id, szSwep);
2122
2123 cs_set_user_bpammo(id , iPrimaryWeaponId, g_WeaponBPAmmo[iPrimaryWeaponId]);
2124 cs_set_user_bpammo(id , iSecondaryWeaponId, g_WeaponBPAmmo[iSecondaryWeaponId]);
2125
2126 set_user_health(id, get_pcvar_num( g_Cvar[ CVAR_HEALTH ][ iClass ][ iRank ] ));
2127
2128 cs_set_user_armor(id, get_pcvar_num( g_Cvar[ CVAR_ARMOR ][ iClass ][ iRank ] ), CS_ARMOR_VESTHELM);
2129
2130 set_user_maxspeed(id, get_pcvar_float( g_Cvar[ CVAR_SPEED ][ iClass ][ iRank ]));
2131
2132 set_user_gravity(id, get_pcvar_float(g_Cvar[ CVAR_GRAVITY ][ iClass ][ iRank ] ));
2133
2134 give_item(id, "weapon_hegrenade");
2135
2136 give_item(id, "weapon_flashbang");
2137 cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
2138
2139 give_item(id, "weapon_smokegrenade");
2140
2141 if(iClass == CLASS_SPECOPS || iClass == CLASS_SNIPER || iClass == CLASS_ENGINEER)
2142 {
2143 set_user_footsteps(id, 1);
2144 }
2145 else
2146 {
2147 set_user_footsteps(id, 0);
2148 }
2149 return PLUGIN_CONTINUE;
2150}
2151
2152//DATA SAVING
2153public MySQLx_Init()
2154{
2155 new szHost[64], szUser[32], szPass[32], szDB[128];
2156
2157 get_cvar_string("amx_sql_host", szHost, charsmax(szHost));
2158 get_cvar_string("amx_sql_user", szUser, charsmax(szUser));
2159 get_cvar_string("amx_sql_pass", szPass, charsmax(szPass));
2160 get_cvar_string("amx_sql_db", szDB, charsmax(szDB));
2161
2162 g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB);
2163
2164 for(new i=0; i<sizeof(szTables); i++)
2165 {
2166 SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i]);
2167 }
2168}
2169
2170public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
2171{
2172 if( iFailState == TQUERY_CONNECT_FAILED
2173 || iFailState == TQUERY_QUERY_FAILED )
2174 {
2175 log_amx( "%s", szError );
2176
2177 return;
2178 }
2179}
2180
2181public SaveData(id)
2182{
2183 if(g_Cvar2[CVAR_SAVEMODE])
2184 {
2185 new szName[32];
2186 get_user_name(id, szName, charsmax(szName));
2187 static szQuery[1024];
2188
2189 new pos;
2190 pos += formatex(szQuery[pos], charsmax(szQuery)-pos, "REPLACE INTO `XpTable` (`player_id`, `player_name`, `player_total_xp`, `player_class_assault_xp`, `player_class_specops_xp`,");
2191 pos += formatex(szQuery[pos], charsmax(szQuery)-pos, " `player_class_sniper_xp`, `player_class_engineer_xp`, `player_class_medic_xp`, `player_class_support_xp`)");
2192 pos += formatex(szQuery[pos], charsmax(szQuery)-pos, " VALUES ('%s', '%s', '%d', '%d',", g_szAuthID[id], szName, g_XP[id][XPTotal], g_XP[id][XP][CLASS_ASSAULT]);
2193 pos += formatex(szQuery[pos], charsmax(szQuery)-pos, " '%d', '%d', '%d', '%d', '%d');", g_XP[id][XP][CLASS_SPECOPS], g_XP[id][XP][CLASS_SNIPER], g_XP[id][XP][CLASS_ENGINEER], g_XP[id][XP][CLASS_MEDIC], g_XP[id][XP][CLASS_SUPPORT]);
2194
2195 SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery);
2196 }
2197 else
2198 {
2199 new iPos , szSave[ ( XPDATA * 10 ) + 1 ];
2200
2201 for ( new i = 0 ; i < XPDATA-2 ; i++ )
2202 iPos += formatex( szSave[ iPos ] ,charsmax( szSave ) , "%10d" , g_XP[ id ][ i ] );
2203
2204 nvault_set( g_iVault , g_szAuthID[ id ] , szSave );
2205 }
2206}
2207
2208public LoadData(id)
2209{
2210 if(get_pcvar_num(g_Cvar2[CVAR_SAVEMODE]))
2211 {
2212 static szQuery[400], iData[1];
2213 formatex(szQuery, charsmax(szQuery), "SELECT * FROM `XpTable` WHERE `player_id` = '%s';", g_szAuthID[id]);
2214
2215 iData[0] = id;
2216 SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, iData, 1);
2217 }
2218 else
2219 {
2220 new iPos , szNum[ 11 ] , szLoad[ ( XPDATA * 10 ) + 1 ];
2221
2222 nvault_get( g_iVault , g_szAuthID[ id ] , szLoad , charsmax( szLoad ) );
2223
2224 for (new i = 0 ; i < XPDATA-2 ; i++)
2225 {
2226 iPos += copy( szNum , 10 , szLoad[ iPos ] );
2227 g_XP[ id ][ i ] = str_to_num( szNum );
2228 }
2229 }
2230}
2231
2232public QuerySelectData(iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime)
2233{
2234 if(iFailState)
2235 {
2236 log_amx("%s", szError);
2237 return;
2238 }
2239
2240 new id = iData[0];
2241
2242 new TotalXP = SQL_FieldNameToNum(hQuery, "player_total_xp");
2243 new ClassAssaultXp = SQL_FieldNameToNum(hQuery, "player_class_assault_xp");
2244 new ClassSpecOpsXp = SQL_FieldNameToNum(hQuery, "player_class_specops_xp");
2245 new ClassSniperXp = SQL_FieldNameToNum(hQuery, "player_class_sniper_xp");
2246 new ClassEngineerXp = SQL_FieldNameToNum(hQuery, "player_class_engineer_xp");
2247 new ClassMedicXp = SQL_FieldNameToNum(hQuery, "player_class_medic_xp");
2248 new ClassSupportXp = SQL_FieldNameToNum(hQuery, "player_class_support_xp");
2249
2250 g_XP[id][XPTotal] = SQL_ReadResult(hQuery, TotalXP);
2251 g_XP[id][XP][CLASS_ASSAULT] = SQL_ReadResult(hQuery, ClassAssaultXp);
2252 g_XP[id][XP][CLASS_SPECOPS] = SQL_ReadResult(hQuery, ClassSpecOpsXp);
2253 g_XP[id][XP][CLASS_SNIPER] = SQL_ReadResult(hQuery, ClassSniperXp);
2254 g_XP[id][XP][CLASS_ENGINEER] = SQL_ReadResult(hQuery, ClassEngineerXp);
2255 g_XP[id][XP][CLASS_MEDIC] = SQL_ReadResult(hQuery, ClassMedicXp);
2256 g_XP[id][XP][CLASS_SUPPORT] = SQL_ReadResult(hQuery, ClassSupportXp);
2257
2258 CheckLevel(id);
2259}
2260
2261public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
2262{
2263 if( iFailState == TQUERY_CONNECT_FAILED
2264 || iFailState == TQUERY_QUERY_FAILED )
2265 {
2266 log_amx( "%s", szError );
2267
2268 return;
2269 }
2270}
2271
2272//Add/Subtract EXP
2273public AlterExp(id, iAmmount, bool:bAdd)
2274{
2275 if(bAdd)
2276 {
2277 if(g_XP[id][XP][g_XP[id][Class]] + iAmmount >= g_RankXP[RANK_GEN][1])
2278 {
2279 g_XP[id][XP][g_XP[id][Class]] = g_RankXP[RANK_GEN][1];
2280 g_XP[id][XPTotal] += (g_RankXP[RANK_GEN][1] - iAmmount);
2281 set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0);
2282 ShowSyncHudMsg(id, gHudSyncXp, "+ %d", (g_RankXP[RANK_GEN][1] - iAmmount));
2283 }
2284 else
2285 {
2286 g_XP[id][XP][g_XP[id][Class]] += iAmmount;
2287 g_XP[id][XPTotal] += iAmmount;
2288 set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0);
2289 ShowSyncHudMsg(id, gHudSyncXp, "+ %d", iAmmount);
2290 }
2291 }
2292 else
2293 {
2294 if(g_XP[id][XP][g_XP[id][Class]] - iAmmount <= g_RankXP[RANK_PVT][0])
2295 {
2296 g_XP[id][XP][g_XP[id][Class]] = g_RankXP[RANK_PVT][0];
2297 g_XP[id][XPTotal] -= (iAmmount - g_RankXP[RANK_PVT][0]);
2298 set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0);
2299 ShowSyncHudMsg(id, gHudSyncXp, "- %d", (iAmmount - g_RankXP[RANK_PVT][0]));
2300 }
2301 else
2302 {
2303 g_XP[id][XP][g_XP[id][Class]] -= iAmmount;
2304 g_XP[id][XPTotal] -= iAmmount;
2305 set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0);
2306 ShowSyncHudMsg(id, gHudSyncXp, "- %d", iAmmount);
2307 }
2308 }
2309
2310 CheckLevel(id);
2311}
2312
2313//Native
2314public _rem_user_xp(iPlugin, iParams)
2315{
2316 new id = get_param(1);
2317 new iAmmount = get_param(2);
2318
2319 AlterExp(id, iAmmount, false);
2320
2321 CheckLevel(id);
2322}
2323
2324public _add_user_xp(iPlugin, iParams)
2325{
2326 new id = get_param(1);
2327 new iAmmount = get_param(2);
2328
2329 AlterExp(id, iAmmount, true);
2330
2331 CheckLevel(id);
2332}
2333
2334public _get_user_totalxp(iPlugin, iParams)
2335{
2336 new id = get_param(1);
2337
2338 return g_XP[id][XPTotal];
2339}
2340
2341public _get_user_xp(iPlugin, iParams)
2342{
2343 new id = get_param(1);
2344
2345 return g_XP[id][XP][g_XP[id][Class]];
2346}
2347
2348public _get_user_class(iPlugin, iParams)
2349{
2350 new id = get_param(1);
2351 set_string(2, g_RankDesc[g_XP[id][Class]], get_param(3));
2352 return 2;
2353}
2354
2355public _get_user_rank(iPlugin, iParams)
2356{
2357 new id = get_param(1);
2358 set_string(2, g_RankDesc[g_XP[id][Rank]], get_param(2));
2359 return 2;
2360}