Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <orpheu_memory>
#include <orpheu>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <fun>
#include <gunxpmod>
new const MOD_VERSION[] = "1.25" /* If you make major changes to the plugin, please do not change the version number, just add "custom" at the end, thanks. */
/* --------------------------------------------------------------------------------------------
"Just Capture The Flag" - by Digi (aka Hunter-Digital)
Thread: http://forums.alliedmods.net/showthread.php?t=132115
------------------------
Change log:
v1.25:
- Changed ctf_moveflag to support red and blue inputs.
- Fade to black no longer affects spectators
- Added "ctf_returnflag <red/blue>" admin command that returns the specified flag if it was dropped for at least 15 seconds (configurable)
- Optimized some minor stuff
v1.24:
- Changed ctf_weaponstay's default value from 30 to 15 (seconds)
- Changed ctf_itempercent's default value from 30 to 25 (percent)
- Added Scout and G3SG1 as special weapons.
- Added the "configurable" flag in the source for weapon money and adrenaline costs
- Added configurable weapon and zoom-in running speeds
- Added cvars for controling sounds: ctf_sound_taken/dropped/returned/score
- Added how much money/adrenaline you need in the "Not enough money/adrenaline" message
v1.23:
- plugin no longer disables VGUI menu automatically but it notifies VGUI menu users upon spawn
- added new in-source configuration: CHAT_SHOW_COMMANDS
v1.22:
- fixed a bug where you'd get twice the adrenaline when using the jctf_add_adrenaline() native while using a reason
- fixed adrenaline HUD not updating when using jctf_add_adrenaline()
v1.21:
- added FLAG_MANUALDROP for jctf_flag() events
- fixed some example issues in jctf_addon_example.sma
- updated version check to 1.21 since jctf.inc was altered
- added a console print upon plugin load with plugin name and version
- forced to reset jctf_version to the current version if mod is updated while server is running
v1.2:
- added forwards and natives that other plugins could use
- added configurable spawning weapons using CVars, they're also forced to reset to prevent unwanted usage between maps
- minor adjustments in the code to fit the latest modifications
v1.13:
- fixed some issues with the autoteambalance
- fixed spawn protection countdown not stop when prematurely disabling protection
- fixed game name displaying version as number instead of string
- added mod version in quick help and help console message
- added checking of mp_forcechasecam too for the fade to black feature
- fixed the possiblity of not beeing blinded while in freelook after a respawn
v1.12:
- fixed a bug where transfered people (autoteambalance) would actually block the team they left from beeing joined, the "there are too many CTs/Ts" thing.
- added fade to black when mp_fadetoblack is disabled and mp_forcecamera is enabled while player is on free view (no teammates alive)
:
- fixed a rare bug where players won't respawn after beeing killed
- some optimizations in code
v1.1:
- removed previous round-end blocking and added new round blocking method via Orpheu module
- fixed various possible crashes caused by previous round-end blocking methods
v1.06:
- changed buy menu text so that items you can't afford are in red text
- fixed various speed issues with player zooming, shield and flag taking
- re-done player rendering system and altered some colors and values
- unforced most mod cvars, only two cvars remain forced
v1.05:
- fixed round-blocking player deaths's animations
- changed the sounds of medkit and adrenaline item pickup
- and of course, other small adjustments
v1.04:
- other small adjustments here and there
- removed the spectating bots, now players' deaths are blocked if they'll trigger round end, they wouldn't even notice
- altered C4 plant radio message to a be compatible with client modifications and other hooks
v1.03:
- added /help
- minor adjustments and code moved around
v1.02:
- fixed items not fading out
- fixed the simple auto-team balance
- fixed various possible errors
v1.01:
- minor fixes of typos and checks
------------------------
Configurable stuff - these are the default values that are FORCED TO RESET on each MAP !
ctf_respawntime (see below constant) - players respawn time
ctf_protection (see below constant) - players spawn protection time
ctf_spawn_prim (see below constant) - spawning primary weapon, set to "" to disable
ctf_spawn_sec (see below constant) - spawning secondary weapon, set to "" to disable
ctf_spawn_knife (see below constant) - toggle if players spawn with knife or not
Weapon names:
primary: m3,xm1014,tmp,mac10,mp5,ump45,p90,galil,ak47,famas,m4a1,aug,sg552,awp,scout,sg550,g3sg1,m249,shield
secondary: glock,usp,p228,deagle,elites,fiveseven
*/
const FORCE_ctf_respawntime = 10
const FORCE_ctf_protection = 5
new const FORCE_ctf_spawn_prim[] = "m3"
new const FORCE_ctf_spawn_sec[] = "glock"
const FORCE_ctf_spawn_knife = 1
/*
You should also set in your configurations:
ctf_weaponstay (default 30) - how long do weapons and items stay on ground
ctf_spawnmoney (default 1000) - money bonus when spawning (unless it's a suicide)
ctf_flagreturn (default 120) - flag auto-return time
ctf_itempercent (default 30) - chance that items spawn when a player is killed, 0-100
ctf_nospam_flash (default 20) - delay of rebuying two flashbangs in a life
ctf_nospam_he (default 20) - delay of rebuying a HE grenade in a life
ctf_nospam_smoke (default 20) - delay of rebuying a smoke grenade in a life
ctf_sound_taken (default 1) - toggles if the "flag taken" sounds can be heard
ctf_sound_dropped (default 1) - toggles if the "flag dropped" sounds can be heard
ctf_sound_returned (default 1) - toggles if the "flag returned" sounds can be heard
ctf_sound_score (default 1) - toggles if the "X team scores" sounds can be heard
mp_c4timer (recommended 20) - time before the C4 devices explode
mp_winlimit - first team who reaches this number wins
mp_timelimit - time limit for the map (displayed in the round timer)
mp_forcecamera - (0/1 - spectate enemies or not) mod fades to black if this is on and player is in free look (no teammates alive)
mp_forcechasecam - (0/1/2 - force chase cammera all/team/firstperson) same as above
mp_autoteambalance - enable/disable auto-team balance (checks at every player death)
Map configurations are made with;
ctf_moveflag red/blue at your position (even if dead/spec)
ctf_save to save flag origins in maps/<mapname>.ctf
[MONEY] [FRAGS] [ADRENALINE]
*/
#define REWARD_RETURN 500, 0, 10
#define REWARD_RETURN_ASSIST 500, 0, 10
#define REWARD_CAPTURE 3000, 3, 25
#define REWARD_CAPTURE_ASSIST 3000, 3, 25
#define REWARD_CAPTURE_TEAM 1000, 0, 10
#define REWARD_STEAL 1000, 1, 10
#define REWARD_PICKUP 500, 1, 5
#define PENALTY_DROP -1500, -1, -10
#define REWARD_KILL 0, 0, 5
#define REWARD_KILLCARRIER 500, 1, 10
#define PENALTY_SUICIDE 0, 0, -20
#define PENALTY_TEAMKILL 0, 0, -20
/*
For more configuration, find the "// CONFIGURABLE" defines below
*/
new const INFO_TARGET[] = "info_target"
new const ITEM_CLASSNAME[] = "ctf_item"
new const Float:ITEM_HULL_MIN[3] = {-1.0, -1.0, 0.0}
new const Float:ITEM_HULL_MAX[3] = {1.0, 1.0, 10.0}
const ADMIN_RETURN = ADMIN_RCON // CONFIGURABLE - access required for admins to return flags
const ADMIN_RETURNWAIT = 15 // CONFIGURABLE - time the flag needs to stay dropped before it can be returned by command
const ITEM_AMMO = 0
const ITEM_MEDKIT = 1
const ITEM_ADRENALINE = 2
const ITEM_MEDKIT_GIVE = 25 // CONFIGURABLE - medkit award health for picking up
const ITEM_ADRENALINE_GIVE = 5 // CONFIGURABLE - adrenaline award adrenalin for picking up
new const bool:CHAT_SHOW_COMMANDS = true // CONFIGURABLE - show commands (like /buy) in chat, true or false
new const ITEM_MODEL_AMMO[] = "models/w_chainammo.mdl"
new const ITEM_MODEL_MEDKIT[] = "models/w_medkit.mdl"
new const ITEM_MODEL_ADRENALINE[] = "models/can.mdl"
new const BASE_CLASSNAME[] = "ctf_flagbase"
new const Float:BASE_THINK = 0.25
new const Float:BASE_HEAL_DISTANCE = 100.0 // CONFIGURABLE - healing distance for flag
new const FLAG_CLASSNAME[] = "ctf_flag"
new const FLAG_MODEL[] = "models/th_jctf.mdl"
new const Float:FLAG_THINK = 0.1
new const Float:FLAG_HULL_MIN[3] = {-30.0, -30.0, 0.0}
new const Float:FLAG_HULL_MAX[3] = {30.0, 30.0, 80.0}
new const Float:FLAG_SPAWN_VELOCITY[3] = {0.0, 0.0, -500.0}
new const Float:FLAG_SPAWN_ANGLES[3] = {0.0, 0.0, 0.0}
new const Float:FLAG_DROP_VELOCITY[3] = {0.0, 0.0, 50.0}
const FLAG_LIGHT_RANGE = 12 // CONFIGURABLE - flag's light range
const FLAG_LIGHT_LIFE = 5 // CONFIGURABLE - flag's light life
const FLAG_LIGHT_DECAY = 1 // CONFIGURABLE - flag's light decay
const FLAG_ANI_DROPPED = 0
const FLAG_ANI_STAND = 1
const FLAG_ANI_BASE = 2
const FLAG_HOLD_BASE = 33
const FLAG_HOLD_DROPPED = 34
const ADRENALINE_SPEED = 1
const ADRENALINE_BERSERKER = 2
const ADRENALINE_REGENERATE = 3
const ADRENALINE_INVISIBILITY = 4
new const MENU_ADRENALINE[] = "menu_adrenaline"
new const MENU_KEYS_ADRENALINE = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<9)
new const MENU_ADRENALINE_CONTENT[] = "\rAdrenaline combos:^n^n\w1. \ySpeed\d (Faster movement)^n\w2. \yBerserker\d (Double damage and faster shooting)^n\w3. \yRegenerate\d (Regenerate health and armor)^n\w4. \yInvisibility\d (Barely visible)^n^n\d\w0. Exit"
new const MENU_BUY[] = "menu_buy"
new const MENU_KEYS_BUY = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
new const BUY_ITEM_DISABLED[] = "r"
new const BUY_ITEM_AVAILABLE[] = "w"
new const BUY_ITEM_AVAILABLE2[] = "y"
const INSTANTSPAWN_COST = 50 // CONFIGURABLE - instant spawn (/spawn) adrenaline cost
const Float:SPEED_FLAG = 0.9 // CONFIGURABLE - speed while carying the enemy flag
const Float:SPEED_ADRENALINE = 1.3 // CONFIGURABLE - speed while using "speed" adrenaline combo (it doesn't overwrite SPEED_FLAG, it adds to it)
const Float:BERSERKER_SPEED1 = 0.7 // CONFIGURABLE - primary weapon shooting speed percent while in berserk
const Float:BERSERKER_SPEED2 = 0.3 // CONFIGURABLE - secondary weapon shooting speed percent while in berserk
const Float:BERSERKER_DAMAGE = 2.0 // CONFIGURABLE - weapon damage percent while in berserk
new const SND_GETAMMO[] = "items/9mmclip1.wav"
new const SND_GETMEDKIT[] = "items/smallmedkit1.wav"
new const SND_GETADRENALINE[] = "items/medshot4.wav"
new const SND_ADRENALINE[] = "ambience/des_wind3.wav"
new const SND_C4DISARMED[] = "weapons/c4_disarmed.wav"
new const C4_RADIUS[] = "600" // CONFIGURABLE - c4 explosion radius - MUST BE STRING!
new const C4_DEFUSETIME = 3 // CONFIGURABLE - c4 defuse time
const FADE_OUT = 0x0000
const FADE_IN = 0x0001
const FADE_MODULATE = 0x0002
const FADE_STAY = 0x0004
const m_iUserPrefs = 510
const m_flNextPrimaryAttack = 46
const m_flNextSecondaryAttack = 47
new const PLAYER[] = "player"
new const WHITESPACE[] = " "
#define NULL ""
#define HUD_HINT 255, 255, 255, 0.15, -0.3, 0, 0.0, 10.0, 2.0, 10.0, 4
#define HUD_HELP 255, 255, 0, -1.0, 0.2, 2, 0.1, 2.0, 0.01, 2.0, 2
#define HUD_HELP2 255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3
#define HUD_ANNOUNCE -1.0, 0.3, 0, 0.0, 3.0, 0.1, 1.0, 4
#define HUD_RESPAWN 0, 255, 0, -1.0, 0.6, 2, 0.5, 0.1, 0.0, 1.0, 1
#define HUD_PROTECTION 255, 255, 0, -1.0, 0.6, 2, 0.5, 0.1, 0.0, 1.0, 1
#define HUD_ADRENALINE 255, 255, 255, -1.0, -0.1, 0, 0.0, 600.0, 0.0, 0.0, 1
#define entity_create(%1) create_entity(%1)
#define entity_spawn(%1) DispatchSpawn(%1)
#define entity_think(%1) call_think(%1)
#define entity_remove(%1) remove_entity(%1)
#define task_set(%1) set_task(%1)
#define task_remove(%1) remove_task(%1)
#define player_hasFlag(%1) (g_iFlagHolder[TEAM_RED] == %1 || g_iFlagHolder[TEAM_BLUE] == %1)
#define player_allowChangeTeam(%1) set_pdata_int(%1, 125, get_pdata_int(%1, 125) & ~(1<<8))
#define gen_color(%1,%2) %1 == TEAM_RED ? %2 : 0, 0, %1 == TEAM_RED ? 0 : %2
#define get_opTeam(%1) (%1 == TEAM_BLUE ? TEAM_RED : TEAM_BLUE)
enum
{
x,
y,
z
}
enum
{
pitch,
yaw,
roll
}
enum (+= 64)
{
TASK_RESPAWN = 64,
TASK_PROTECTION,
TASK_DAMAGEPROTECTION,
TASK_EQUIPAMENT,
TASK_PUTINSERVER,
TASK_TEAMBALANCE,
TASK_ADRENALINE,
TASK_DEFUSE
}
enum
{
TEAM_NONE = 0,
TEAM_RED,
TEAM_BLUE,
TEAM_SPEC
}
new const g_szCSTeams[][] =
{
NULL,
"TERRORIST",
"CT",
"SPECTATOR"
}
new const g_szTeamName[][] =
{
NULL,
"Red",
"Blue",
"Spectator"
}
enum
{
FLAG_STOLEN = 0,
FLAG_PICKED,
FLAG_DROPPED,
FLAG_MANUALDROP,
FLAG_RETURNED,
FLAG_CAPTURED,
FLAG_AUTORETURN
}
enum
{
EVENT_TAKEN = 0,
EVENT_DROPPED,
EVENT_RETURNED,
EVENT_SCORE,
}
new const g_szSounds[][][] =
{
{NULL, "red_flag_taken", "blue_flag_taken"},
{NULL, "red_flag_dropped", "blue_flag_dropped"},
{NULL, "red_flag_returned", "blue_flag_returned"},
{NULL, "red_team_scores", "blue_team_scores"}
}
new const g_szHints[][] =
{
"Your adrenaline gives you temporary combos, once you have 100, use adrenaline command.",
"The enemy flag can be captured only if your flag is in the base.",
"Sometimes killed players drop useful items, keep an eye out.",
"The C4 kills everything in it's range in a short time, however it's defusable",
"Both flags are constantly displayed as a blinking dot on all players radar.",
"Spawn protection will be disabled prematurely if you use a weapon.",
"When you're using an adrenalin combo, the adrenaline drains depending on the combo.",
"The machinegun, snipers, shield and C4 cost alot of money and adrenaline.^nThey can be found in Buy menu -> Special Weapons.",
"You can buy an instant respawn for 50 adrenaline, while dead just type /spawn",
"Ammo does not cost anything, feel free to resupply every time you pass by your buyzone.",
"Once you have the enemy flag you will be slown down, always have the team covering you.",
"To win your team needs to steal the enemy flag while defending their own flag."
}
new const g_szAdrenalineUse[][] =
{
NULL,
"Speed",
"Berserk",
"Regeneration",
"Invisbility"
}
enum
{
no_weapon,
primary,
secondary,
he,
flash,
smoke,
armor,
nvg
}
new const g_szRebuyCommands[][] =
{
NULL,
"PrimaryWeapon",
"SecondaryWeapon",
"HEGrenade",
"Flashbang",
"SmokeGrenade",
"Armor",
"NightVision"
}
new const g_szRemoveEntities[][] =
{
"func_buyzone",
"armoury_entity",
"func_bomb_target",
"info_bomb_target",
"hostage_entity",
"monster_scientist",
"func_hostage_rescue",
"info_hostage_rescue",
"info_vip_start",
"func_vip_safetyzone",
"func_escapezone",
"info_map_parameters",
"player_weaponstrip",
"game_player_equip"
}
enum
{
ZERO = 0,
W_P228,
W_SHIELD,
W_SCOUT,
W_HEGRENADE,
W_XM1014,
W_C4,
W_MAC10,
W_AUG,
W_SMOKEGRENADE,
W_ELITE,
W_FIVESEVEN,
W_UMP45,
W_SG550,
W_GALIL,
W_FAMAS,
W_USP,
W_GLOCK18,
W_AWP,
W_MP5NAVY,
W_M249,
W_M3,
W_M4A1,
W_TMP,
W_G3SG1,
W_FLASHBANG,
W_DEAGLE,
W_SG552,
W_AK47,
W_KNIFE,
W_P90,
W_VEST,
W_VESTHELM,
W_NVG
}
new const g_iClip[] =
{
0, // (unknown)
13, // P228
0, // SHIELD (not used)
10, // SCOUT
0, // HEGRENADE (not used)
7, // XM1014
0, // C4 (not used)
30, // MAC10
30, // AUG
0, // SMOKEGRENADE (not used)
30, // ELITE
20, // FIVESEVEN
25, // UMP45
30, // SG550
35, // GALIL
25, // FAMAS
12, // USP
20, // GLOCK18
10, // AWP
30, // MP5NAVY
100, // M249
8, // M3
30, // M4A1
30, // TMP
20, // G3SG1
0, // FLASHBANG (not used)
7, // DEAGLE
30, // SG552
30, // AK47
0, // KNIFE (not used)
50, // P90
0, // Kevlar (not used)
0, // Kevlar + Helm (not used)
0 // NVG (not used)
}
new const g_iBPAmmo[] =
{
0, // (unknown)
52, // P228
0, // SHIELD
90, // SCOUT
0, // HEGRENADE (not used)
32, // XM1014
0, // C4 (not used)
100, // MAC10
90, // AUG
0, // SMOKEGRENADE (not used)
120, // ELITE
100, // FIVESEVEN
100, // UMP45
90, // SG550
90, // GALIL
90, // FAMAS
100, // USP
120, // GLOCK18
30, // AWP
120, // MP5NAVY
200, // M249
32, // M3
90, // M4A1
120, // TMP
90, // G3SG1
0, // FLASHBANG (not used)
35, // DEAGLE
90, // SG552
90, // AK47
0, // KNIFE (not used)
100, // P90
0, // Kevlar (not used)
0, // Kevlar + Helm (not used)
0 // NVG (not used)
}
new const g_iWeaponPrice[] = // CONFIGURABLE - weapon money cost (edit the numbers in the list)
{
0, // (unknown)
600, // P228
10000, // SHIELD
6000, // SCOUT
300, // HEGRENADE
3000, // XM1014
15000, // C4
1400, // MAC10
3500, // AUG
100, // SMOKEGRENADE
1000, // ELITE
750, // FIVESEVEN
1700, // UMP45
6000, // SG550
2000, // GALIL
2250, // FAMAS
500, // USP
400, // GLOCK18
8000, // AWP
1500, // MP5NAVY
5000, // M249
1700, // M3
3100, // M4A1
1250, // TMP
7000, // G3SG1
200, // FLASHBANG
650, // DEAGLE
3500, // SG552
2500, // AK47
0, // KNIFE (not used)
2350, // P90
650, // Kevlar
1000, // Kevlar + Helm
1250 // NVG
}
new const g_iWeaponAdrenaline[] = // CONFIGURABLE - weapon adrenaline cost (edit the numbers in the list)
{
0, // (unknown)
0, // P228
50, // SHIELD
50, // SCOUT
0, // HEGRENADE
0, // XM1014
100, // C4
0, // MAC10
0, // AUG
0, // SMOKEGRENADE
0, // ELITE
0, // FIVESEVEN
0, // UMP45
30, // SG550
0, // GALIL
0, // FAMAS
0, // USP
0, // GLOCK18
50, // AWP
0, // MP5NAVY
10, // M249
0, // M3
0, // M4A1
0, // TMP
30, // G3SG1
0, // FLASHBANG
0, // DEAGLE
0, // SG552
0, // AK47
0, // KNIFE (not used)
0, // P90
0, // Kevlar
0, // Kevlar + Helm
0 // NVG
}
new const Float:g_fWeaponRunSpeed[] = // CONFIGURABLE - weapon running speed (edit the numbers in the list)
{
150.0, // Zoomed speed with any weapon
250.0, // P228
0.0, // SHIELD (not used)
260.0, // SCOUT
250.0, // HEGRENADE
240.0, // XM1014
250.0, // C4
250.0, // MAC10
240.0, // AUG
250.0, // SMOKEGRENADE
250.0, // ELITE
250.0, // FIVESEVEN
250.0, // UMP45
210.0, // SG550
240.0, // GALIL
240.0, // FAMAS
250.0, // USP
250.0, // GLOCK18
210.0, // AWP
250.0, // MP5NAVY
220.0, // M249
230.0, // M3
230.0, // M4A1
250.0, // TMP
210.0, // G3SG1
250.0, // FLASHBANG
250.0, // DEAGLE
235.0, // SG552
221.0, // AK47
250.0, // KNIFE
245.0, // P90
0.0, // Kevlar (not used)
0.0, // Kevlar + Helm (not used)
0.0 // NVG (not used)
}
new const g_iWeaponSlot[] =
{
0, // none
2, // P228
1, // SHIELD
1, // SCOUT
4, // HEGRENADE
1, // XM1014
5, // C4
1, // MAC10
1, // AUG
4, // SMOKEGRENADE
2, // ELITE
2, // FIVESEVEN
1, // UMP45
1, // SG550
1, // GALIL
1, // FAMAS
2, // USP
2, // GLOCK18
1, // AWP
1, // MP5NAVY
1, // M249
1, // M3
1, // M4A1
1, // TMP
1, // G3SG1
4, // FLASHBANG
2, // DEAGLE
1, // SG552
1, // AK47
3, // KNIFE (not used)
1, // P90
0, // Kevlar
0, // Kevlar + Helm
0 // NVG
}
new const g_szWeaponEntity[][24] =
{
NULL,
"weapon_p228",
"weapon_shield",
"weapon_scout",
"weapon_hegrenade",
"weapon_xm1014",
"weapon_c4",
"weapon_mac10",
"weapon_aug",
"weapon_smokegrenade",
"weapon_elite",
"weapon_fiveseven",
"weapon_ump45",
"weapon_sg550",
"weapon_galil",
"weapon_famas",
"weapon_usp",
"weapon_glock18",
"weapon_awp",
"weapon_mp5navy",
"weapon_m249",
"weapon_m3",
"weapon_m4a1",
"weapon_tmp",
"weapon_g3sg1",
"weapon_flashbang",
"weapon_deagle",
"weapon_sg552",
"weapon_ak47",
"weapon_knife",
"weapon_p90",
"item_kevlar",
"item_assaultsuit",
NULL
}
new const g_szWeaponCommands[][] =
{
{NULL, NULL},
{"p228", "228compact"},
{"shield", NULL},
{"scout", NULL},
{"hegren", NULL},
{"xm1014", "autoshotgun"},
{NULL, NULL},
{"mac10", NULL},
{"aug", "bullpup"},
{"sgren", NULL},
{"elites", NULL},
{"fiveseven", "fn57"},
{"ump45", "sm"},
{"sg550", "krieg550"},
{"galil", "defender"},
{"famas", "clarion"},
{"usp", "km45"},
{"glock", "9x19mm"},
{"awp", "magnum"},
{"mp5", "mp"},
{"m249", NULL},
{"m3", "12gauge"},
{"m4a1", NULL},
{"tmp", NULL},
{"g3sg1", "d3au1"},
{"flash", NULL},
{"deagle", "nighthawk"},
{"sg552", "krieg552"},
{"ak47", "cv47"},
{NULL, NULL},
{"p90", "c90"},
{"vest", NULL},
{"vesthelm", NULL},
{"nvgs", NULL}
}
new g_iMaxPlayers
new g_szMap[32]
new g_iScore[3]
new g_iFlagHolder[3]
new g_iFlagEntity[3]
new g_iBaseEntity[3]
new Float:g_fFlagDropped[3]
new g_iTeam[33]
new g_iMenu[33]
new g_iVGUI[33]
new g_iWeapon[33]
new g_iRebuy[33][8]
new g_iAutobuy[33][64]
new g_iAdrenaline[33]
new g_iAdrenalineUse[33]
new g_iRebuyWeapons[33][8]
new bool:g_bRestarting
new bool:g_bBot[33]
new bool:g_bAlive[33]
new bool:g_bDefuse[33]
new bool:g_bLights[33]
new bool:g_bBuyZone[33]
new bool:g_bSuicide[33]
new bool:g_bFreeLook[33]
new bool:g_bAssisted[33][3]
new bool:g_bProtected[33]
new bool:g_bRestarted[33]
new bool:g_bFirstSpawn[33]
new Float:g_fFlagBase[3][3]
new Float:g_fFlagLocation[3][3]
new Float:g_fWeaponSpeed[33]
new Float:g_fLastDrop[33]
new Float:g_fLastBuy[33][4]
new pCvar_ctf_flagreturn
new pCvar_ctf_respawntime
new pCvar_ctf_protection
new pCvar_ctf_weaponstay
new pCvar_ctf_itempercent
new pCvar_ctf_nospam_flash
new pCvar_ctf_nospam_he
new pCvar_ctf_nospam_smoke
new pCvar_ctf_spawn_prim
new pCvar_ctf_spawn_sec
new pCvar_ctf_spawn_knife
new pCvar_ctf_sound[4]
new pCvar_mp_c4timer
new pCvar_mp_winlimit
new pCvar_mp_fadetoblack
new pCvar_mp_forcecamera
new pCvar_mp_forcechasecam
new pCvar_mp_autoteambalance
new gMsg_BarTime
new gMsg_SayText
new gMsg_DeathMsg
new gMsg_RoundTime
new gMsg_ScreenFade
new gMsg_HostageK
new gMsg_HostagePos
new gMsg_SendAudio
new gMsg_ScoreInfo
new gMsg_ScoreAttrib
new gMsg_TextMsg
new gMsg_TeamScore
new gHook_EntSpawn
new gSpr_trail
new gSpr_regeneration
new gSpr_blood1
new gSpr_blood2
new g_iForwardReturn
new g_iFW_flag
public plugin_precache()
{
precache_model(FLAG_MODEL)
precache_model(ITEM_MODEL_AMMO)
precache_model(ITEM_MODEL_MEDKIT)
precache_model(ITEM_MODEL_ADRENALINE)
precache_sound(SND_GETAMMO)
precache_sound(SND_GETMEDKIT)
precache_sound(SND_GETADRENALINE)
precache_sound(SND_ADRENALINE)
precache_sound(SND_C4DISARMED)
gSpr_trail = precache_model("sprites/zbeam5.spr")
gSpr_blood1 = precache_model("sprites/blood.spr")
gSpr_blood2 = precache_model("sprites/bloodspray.spr")
gSpr_regeneration = precache_model("sprites/th_jctf_heal.spr")
for(new szSound[64], i = 0; i < sizeof g_szSounds; i++)
{
for(new t = 1; t <= 2; t++)
{
formatex(szSound, charsmax(szSound), "ctf/%s.mp3", g_szSounds[i][t])
precache_sound(szSound)
}
}
new ent = entity_create(g_szRemoveEntities[11])
if(ent)
{
DispatchKeyValue(ent, "buying", "3")
DispatchKeyValue(ent, "bombradius", C4_RADIUS)
DispatchSpawn(ent)
}
gHook_EntSpawn = register_forward(FM_Spawn, "ent_spawn")
}
public ent_spawn(ent)
{
if(!is_valid_ent(ent))
return FMRES_IGNORED
static szClass[32]
entity_get_string(ent, EV_SZ_classname, szClass, charsmax(szClass))
for(new i = 0; i < sizeof g_szRemoveEntities; i++)
{
if(equal(szClass, g_szRemoveEntities[i]))
{
entity_remove(ent)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public plugin_init()
{
register_plugin("Just Capture the Flag", MOD_VERSION, "Digi (TheHunters.ro)")
set_pcvar_string(register_cvar("jctf_version", MOD_VERSION, FCVAR_SERVER|FCVAR_SPONLY), MOD_VERSION)
server_print(" - - - - - - - - - - - - - - - - -")
server_print(" Just Capture the Flag - v%s", MOD_VERSION)
server_print(" - - - - - - - - - - - - - - - - -")
// Forwards, hooks, events, etc
unregister_forward(FM_Spawn, gHook_EntSpawn)
register_forward(FM_GetGameDescription, "game_description")
register_touch(FLAG_CLASSNAME, PLAYER, "flag_touch")
register_think(FLAG_CLASSNAME, "flag_think")
register_think(BASE_CLASSNAME, "base_think")
register_logevent("event_restartGame", 2, "1&Restart_Round", "1&Game_Commencing")
register_event("HLTV", "event_roundStart", "a", "1=0", "2=0")
register_clcmd("fullupdate", "msg_block")
register_event("TeamInfo", "player_joinTeam", "a")
RegisterHam(Ham_Spawn, PLAYER, "player_spawn", 1)
RegisterHam(Ham_Killed, PLAYER, "player_killed", 1)
RegisterHam(Ham_TakeDamage, PLAYER, "player_damage")
register_clcmd("say", "player_cmd_say")
register_clcmd("say_team", "player_cmd_sayTeam")
register_menucmd(register_menuid(MENU_ADRENALINE), MENU_KEYS_ADRENALINE, "player_key_adrenaline")
register_clcmd("adrenaline", "player_cmd_adrenaline")
register_menucmd(register_menuid(MENU_BUY), MENU_KEYS_BUY, "player_key_buy")
register_event("StatusIcon", "player_inBuyZone", "be", "2=buyzone")
register_clcmd("buy", "player_cmd_buy_main")
register_clcmd("buyammo1", "player_fillAmmo")
register_clcmd("buyammo2", "player_fillAmmo")
register_clcmd("primammo", "player_fillAmmo")
register_clcmd("secammo", "player_fillAmmo")
register_clcmd("autobuy", "player_cmd_autobuy")
register_clcmd("cl_autobuy", "player_cmd_autobuy")
register_clcmd("cl_setautobuy", "player_cmd_setAutobuy")
register_clcmd("rebuy", "player_cmd_rebuy")
register_clcmd("cl_rebuy", "player_cmd_rebuy")
register_clcmd("cl_setrebuy", "player_cmd_setRebuy")
register_clcmd("buyequip", "player_cmd_buy_equipament")
for(new w = W_P228; w <= W_NVG; w++)
{
for(new i = 0; i < 2; i++)
{
if(strlen(g_szWeaponCommands[w][i]))
register_clcmd(g_szWeaponCommands[w][i], "player_cmd_buyWeapon")
}
if(w != W_SHIELD && w <= W_P90)
RegisterHam(Ham_Weapon_PrimaryAttack, g_szWeaponEntity[w], "player_useWeapon", 1)
}
register_clcmd("ctf_moveflag", "admin_cmd_moveFlag", ADMIN_RCON, "<red/blue> - Moves team's flag base to your origin (for map management)")
register_clcmd("ctf_save", "admin_cmd_saveFlags", ADMIN_RCON)
register_clcmd("ctf_return", "admin_cmd_returnFlag", ADMIN_RETURN)
register_clcmd("dropflag", "player_cmd_dropFlag")
RegisterHam(Ham_Use, "grenade", "c4_defuse", 1)
register_logevent("c4_planted", 3, "2=Planted_The_Bomb")
register_logevent("c4_defused", 3, "2=Defused_The_Bomb")
register_touch(ITEM_CLASSNAME, PLAYER, "item_touch")
register_touch("weaponbox", PLAYER, "weapon_touch")
register_event("CurWeapon", "player_currentWeapon", "be", "1=1")
register_event("SetFOV", "player_currentWeapon", "be", "1>1")
RegisterHam(Ham_Spawn, "weaponbox", "weapon_spawn", 1)
RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_KNIFE], "player_useWeapon", 1) // not a typo
RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_USP], "player_useWeaponSec", 1)
RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_FAMAS], "player_useWeaponSec", 1)
RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_M4A1], "player_useWeaponSec", 1)
gMsg_BarTime = get_user_msgid("BarTime")
gMsg_DeathMsg = get_user_msgid("DeathMsg")
gMsg_HostagePos = get_user_msgid("HostagePos")
gMsg_HostageK = get_user_msgid("HostageK")
gMsg_SendAudio = get_user_msgid("SendAudio")
gMsg_RoundTime = get_user_msgid("RoundTime")
gMsg_SayText = get_user_msgid("SayText")
gMsg_ScoreInfo = get_user_msgid("ScoreInfo")
gMsg_ScoreAttrib = get_user_msgid("ScoreAttrib")
gMsg_ScreenFade = get_user_msgid("ScreenFade")
gMsg_TextMsg = get_user_msgid("TextMsg")
gMsg_TeamScore = get_user_msgid("TeamScore")
register_message(get_user_msgid("BombDrop"), "msg_block")
register_message(get_user_msgid("ClCorpse"), "msg_block")
register_message(gMsg_TextMsg, "msg_textMsg")
register_message(gMsg_BarTime, "c4_used")
register_message(gMsg_SendAudio, "msg_sendAudio")
register_message(gMsg_HostageK, "msg_block")
register_message(gMsg_HostagePos, "msg_block")
register_message(gMsg_RoundTime, "msg_roundTime")
register_message(gMsg_ScreenFade, "msg_screenFade")
register_message(gMsg_ScoreAttrib, "msg_scoreAttrib")
register_message(gMsg_TeamScore, "msg_teamScore")
register_message(gMsg_SayText, "msg_sayText")
// CVARS
pCvar_ctf_respawntime = register_cvar("ctf_respawntime", NULL)
pCvar_ctf_protection = register_cvar("ctf_protection", NULL)
pCvar_ctf_flagreturn = register_cvar("ctf_flagreturn", "120")
pCvar_ctf_weaponstay = register_cvar("ctf_weaponstay", "15")
pCvar_ctf_itempercent = register_cvar("ctf_itempercent", "25")
pCvar_ctf_nospam_flash = register_cvar("ctf_nospam_flash", "20")
pCvar_ctf_nospam_he = register_cvar("ctf_nospam_he", "20")
pCvar_ctf_nospam_smoke = register_cvar("ctf_nospam_smoke", "20")
pCvar_ctf_spawn_prim = register_cvar("ctf_spawn_prim", NULL)
pCvar_ctf_spawn_sec = register_cvar("ctf_spawn_sec", NULL)
pCvar_ctf_spawn_knife = register_cvar("ctf_spawn_knife", NULL)
pCvar_ctf_sound[EVENT_TAKEN] = register_cvar("ctf_sound_taken", "1")
pCvar_ctf_sound[EVENT_DROPPED] = register_cvar("ctf_sound_dropped", "1")
pCvar_ctf_sound[EVENT_RETURNED] = register_cvar("ctf_sound_returned", "1")
pCvar_ctf_sound[EVENT_SCORE] = register_cvar("ctf_sound_score", "1")
set_pcvar_num(pCvar_ctf_respawntime, FORCE_ctf_respawntime)
set_pcvar_num(pCvar_ctf_protection, FORCE_ctf_protection)
set_pcvar_string(pCvar_ctf_spawn_prim, FORCE_ctf_spawn_prim)
set_pcvar_string(pCvar_ctf_spawn_sec, FORCE_ctf_spawn_sec)
set_pcvar_num(pCvar_ctf_spawn_knife, FORCE_ctf_spawn_knife)
pCvar_mp_c4timer = get_cvar_pointer("mp_c4timer")
pCvar_mp_winlimit = get_cvar_pointer("mp_winlimit")
pCvar_mp_fadetoblack = get_cvar_pointer("mp_fadetoblack")
pCvar_mp_forcecamera = get_cvar_pointer("mp_forcecamera")
pCvar_mp_forcechasecam = get_cvar_pointer("mp_forcechasecam")
pCvar_mp_autoteambalance = get_cvar_pointer("mp_autoteambalance")
// Plugin's forwards
g_iFW_flag = CreateMultiForward("jctf_flag", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL)
// Variables
get_mapname(g_szMap, charsmax(g_szMap))
g_iMaxPlayers = get_maxplayers()
// fake bomb target
new ent = entity_create(g_szRemoveEntities[2])
if(ent)
{
entity_spawn(ent)
entity_set_size(ent, Float:{-8192.0, -8192.0, -8192.0}, Float:{8192.0, 8192.0, 8192.0})
}
state disabled
game_forwards()
}
public game_forwards() <> {}
public game_forwards() <disabled>
{
OrpheuRegisterHook(OrpheuGetFunction("CheckMapConditions", "CHalfLifeMultiplay"), "game_blockConditions")
OrpheuRegisterHook(OrpheuGetFunction("CheckWinConditions", "CHalfLifeMultiplay"), "game_blockConditions")
if(is_linux_server())
OrpheuRegisterHook(OrpheuGetFunction("HasRoundTimeExpired", "CHalfLifeMultiplay"), "game_blockConditions")
else
game_memoryReplace("roundTimeCheck", {0x90, 0x90, 0x90})
state enabled
}
public OrpheuHookReturn:game_blockConditions() <>
return OrpheuIgnored
public OrpheuHookReturn:game_blockConditions() <enabled>
{
OrpheuSetReturn(false)
return OrpheuSupercede
}
game_memoryReplace(szID[], const iBytes[], const iLen = sizeof iBytes)
{
new iAddress
OrpheuMemoryGet(szID, iAddress)
for(new i; i < iLen; i++)
{
OrpheuMemorySetAtAddress(iAddress, "roundTimeCheck|dummy", 1, iBytes[i], iAddress)
iAddress++
}
server_cmd("sv_restart 1")
}
public game_description()
{
new szFormat[32]
formatex(szFormat, charsmax(szFormat), "CS 1.6 jCTF v%s", MOD_VERSION)
forward_return(FMV_STRING, szFormat)
return FMRES_SUPERCEDE
}
public plugin_cfg()
{
new szFile[64]
formatex(szFile, charsmax(szFile), "maps/%s.ctf", g_szMap)
new hFile = fopen(szFile, "rt")
if(hFile)
{
new iFlagTeam = TEAM_RED
new szData[24]
new szOrigin[3][6]
while(fgets(hFile, szData, charsmax(szData)))
{
if(iFlagTeam > TEAM_BLUE)
break
trim(szData)
parse(szData, szOrigin[x], charsmax(szOrigin[]), szOrigin[y], charsmax(szOrigin[]), szOrigin[z], charsmax(szOrigin[]))
g_fFlagBase[iFlagTeam][x] = str_to_float(szOrigin[x])
g_fFlagBase[iFlagTeam][y] = str_to_float(szOrigin[y])
g_fFlagBase[iFlagTeam][z] = str_to_float(szOrigin[z])
iFlagTeam++
}
fclose(hFile)
}
flag_spawn(TEAM_RED)
flag_spawn(TEAM_BLUE)
task_set(6.5, "plugin_postCfg")
}
public plugin_postCfg()
{
set_cvar_num("mp_freezetime", 0)
set_cvar_num("mp_limitteams", 0)
set_cvar_num("mp_buytime", 0)
server_cmd("sv_restart 1")
}
public plugin_natives()
{
register_library("jctf")
register_native("jctf_get_adrenaline", "native_get_adrenaline")
register_native("jctf_add_adrenaline", "native_add_adrenaline")
}
public plugin_end()
DestroyForward(g_iFW_flag)
public native_get_adrenaline(iPlugin, iParams)
{
/* jctf_get_adrenaline(id) */
return g_iAdrenaline[get_param(1)]
}
public native_add_adrenaline(iPlugin, iParams)
{
/* jctf_add_adrenaline(id, iAdd, szReason[]) */
new id = get_param(1)
new iAdd = get_param(2)
new szReason[64]
get_string(3, szReason, charsmax(szReason))
if(strlen(szReason))
player_award(id, 0, 0, iAdd, szReason)
else
{
g_iAdrenaline[id] = clamp(g_iAdrenaline[id] + iAdd, 0, 100)
player_hudAdrenaline(id)
}
return g_iAdrenaline[id]
}
public flag_spawn(iFlagTeam)
{
if(g_fFlagBase[iFlagTeam][x] == 0.0 && g_fFlagBase[iFlagTeam][y] == 0.0 && g_fFlagBase[iFlagTeam][z] == 0.0)
{
new iFindSpawn = find_ent_by_class(g_iMaxPlayers, iFlagTeam == TEAM_BLUE ? "info_player_start" : "info_player_deathmatch")
if(iFindSpawn)
{
entity_get_vector(iFindSpawn, EV_VEC_origin, g_fFlagBase[iFlagTeam])
server_print("[CTF] %s flag origin not defined, set on player spawn.", g_szTeamName[iFlagTeam])
log_error(AMX_ERR_NOTFOUND, "[CTF] %s flag origin not defined, set on player spawn.", g_szTeamName[iFlagTeam])
}
else
{
server_print("[CTF] WARNING: player spawn for ^"%s^" team does not exist !", g_szTeamName[iFlagTeam])
log_error(AMX_ERR_NOTFOUND, "[CTF] WARNING: player spawn for ^"%s^" team does not exist !", g_szTeamName[iFlagTeam])
set_fail_state("Player spawn unexistent!")
return PLUGIN_CONTINUE
}
}
else
server_print("[CTF] %s flag and base spawned at: %.1f %.1f %.1f", g_szTeamName[iFlagTeam], g_fFlagBase[iFlagTeam][x], g_fFlagBase[iFlagTeam][y], g_fFlagBase[iFlagTeam][z])
new ent
new Float:fGameTime = get_gametime()
// the FLAG
ent = entity_create(INFO_TARGET)
if(!ent)
return flag_spawn(iFlagTeam)
entity_set_model(ent, FLAG_MODEL)
entity_set_string(ent, EV_SZ_classname, FLAG_CLASSNAME)
entity_set_int(ent, EV_INT_body, iFlagTeam)
entity_set_int(ent, EV_INT_sequence, FLAG_ANI_STAND)
entity_spawn(ent)
entity_set_origin(ent, g_fFlagBase[iFlagTeam])
entity_set_size(ent, FLAG_HULL_MIN, FLAG_HULL_MAX)
entity_set_vector(ent, EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
entity_set_vector(ent, EV_VEC_angles, FLAG_SPAWN_ANGLES)
entity_set_edict(ent, EV_ENT_aiment, 0)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
entity_set_float(ent, EV_FL_gravity, 2.0)
entity_set_float(ent, EV_FL_nextthink, fGameTime + FLAG_THINK)
g_iFlagEntity[iFlagTeam] = ent
g_iFlagHolder[iFlagTeam] = FLAG_HOLD_BASE
// flag BASE
ent = entity_create(INFO_TARGET)
if(!ent)
return flag_spawn(iFlagTeam)
entity_set_string(ent, EV_SZ_classname, BASE_CLASSNAME)
entity_set_model(ent, FLAG_MODEL)
entity_set_int(ent, EV_INT_body, 0)
entity_set_int(ent, EV_INT_sequence, FLAG_ANI_BASE)
entity_spawn(ent)
entity_set_origin(ent, g_fFlagBase[iFlagTeam])
entity_set_vector(ent, EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_int(ent, EV_INT_renderfx, kRenderFxGlowShell)
entity_set_float(ent, EV_FL_renderamt, 100.0)
entity_set_float(ent, EV_FL_nextthink, fGameTime + BASE_THINK)
if(iFlagTeam == TEAM_RED)
entity_set_vector(ent, EV_VEC_rendercolor, Float:{150.0, 0.0, 0.0})
else
entity_set_vector(ent, EV_VEC_rendercolor, Float:{0.0, 0.0, 150.0})
g_iBaseEntity[iFlagTeam] = ent
return PLUGIN_CONTINUE
}
public flag_think(ent)
{
if(!is_valid_ent(ent))
return
entity_set_float(ent, EV_FL_nextthink, get_gametime() + FLAG_THINK)
static iFlagTeam
static iOrigin[3]
static iSkip[3]
iFlagTeam = (ent == g_iFlagEntity[TEAM_BLUE] ? TEAM_BLUE : TEAM_RED)
if(g_iFlagHolder[iFlagTeam] != FLAG_HOLD_BASE)
{
static Float:fOrigin[3]
entity_get_vector(ent, EV_VEC_origin, fOrigin)
g_fFlagLocation[iFlagTeam] = fOrigin
FVecIVec(fOrigin, iOrigin)
}
else
{
g_fFlagLocation[iFlagTeam] = g_fFlagBase[iFlagTeam]
FVecIVec(g_fFlagBase[iFlagTeam], iOrigin)
}
if(++iSkip[iFlagTeam] >= 25)
{
iSkip[iFlagTeam] = 0
if(1 <= g_iFlagHolder[iFlagTeam] <= g_iMaxPlayers)
{
new id = g_iFlagHolder[iFlagTeam]
set_hudmessage(HUD_HELP)
show_hudmessage(id, "You have the flag, return to base!")
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(g_iTeam[i] == iFlagTeam)
{
set_hudmessage(HUD_HELP2)
show_hudmessage(i, "The enemy has your flag, get it back!")
}
}
}
else if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED)
{
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(g_iTeam[i] == iFlagTeam)
{
set_hudmessage(HUD_HELP2)
show_hudmessage(i, "Your flag is dropped, return it!")
}
}
}
message_begin(MSG_BROADCAST, gMsg_HostagePos)
write_byte(0)
write_byte(iFlagTeam)
write_coord(iOrigin[x])
write_coord(iOrigin[y])
write_coord(iOrigin[z])
message_end()
message_begin(MSG_BROADCAST, gMsg_HostageK)
write_byte(iFlagTeam)
message_end()
if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED || g_iFlagHolder[iFlagTeam] == FLAG_HOLD_BASE)
{
new Float:fVelocity[3]
entity_get_vector(ent, EV_VEC_velocity, fVelocity)
if(iOrigin[x] >= 4096 || iOrigin[y] >= 4096 || iOrigin[z] >= 4096 || iOrigin[x] <= -4096 || iOrigin[y] <= -4096 || iOrigin[z] <= -4096 || fVelocity[x] >= 2000 || fVelocity[y] >= 2000 || fVelocity[z] >= 2000 || fVelocity[x] <= -2000 || fVelocity[y] <= -2000 || fVelocity[z] <= -2000)
{
flag_autoReturn(iFlagTeam)
log_message("^"%s^" flag is outside world, auto-returned.", g_szTeamName[iFlagTeam])
return
}
}
}
if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED)
iOrigin[z] += 32
else
iOrigin[z] -= 16
if(g_iFlagHolder[iFlagTeam] != FLAG_HOLD_BASE)
{
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(g_bLights[i])
{
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, i)
write_byte(TE_DLIGHT)
write_coord(iOrigin[x])
write_coord(iOrigin[y])
write_coord(iOrigin[z])
write_byte(FLAG_LIGHT_RANGE)
write_byte(iFlagTeam == TEAM_RED ? 100 : 0)
write_byte(0)
write_byte(iFlagTeam == TEAM_BLUE ? 155 : 0)
write_byte(FLAG_LIGHT_LIFE)
write_byte(FLAG_LIGHT_DECAY)
message_end()
}
}
}
}
flag_sendHome(iFlagTeam)
{
new ent = g_iFlagEntity[iFlagTeam]
entity_set_edict(ent, EV_ENT_aiment, 0)
entity_set_origin(ent, g_fFlagBase[iFlagTeam])
entity_set_int(ent, EV_INT_sequence, FLAG_ANI_STAND)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
entity_set_vector(ent, EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
entity_set_vector(ent, EV_VEC_angles, FLAG_SPAWN_ANGLES)
g_iFlagHolder[iFlagTeam] = FLAG_HOLD_BASE
}
flag_take(iFlagTeam, id)
{
if(g_bProtected[id])
player_removeProtection(id, "Spawn protection disabled: flag touched")
new ent = g_iFlagEntity[iFlagTeam]
entity_set_edict(ent, EV_ENT_aiment, id)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_FOLLOW)
entity_set_int(ent, EV_INT_solid, SOLID_NOT)
g_iFlagHolder[iFlagTeam] = id
message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
write_byte(id)
write_byte(g_iTeam[id] == TEAM_BLUE ? 4 : 2)
message_end()
player_setSpeed(id)
}
public flag_touch(ent, id)
{
if(!g_bAlive[id])
return
new iFlagTeam = (g_iFlagEntity[TEAM_BLUE] == ent ? TEAM_BLUE : TEAM_RED)
if(1 <= g_iFlagHolder[iFlagTeam] <= g_iMaxPlayers) // if flag is carried we don't care
return
new Float:fGameTime = get_gametime()
if(g_fLastDrop[id] > fGameTime)
return
new iTeam = g_iTeam[id]
new iFlagTeamOp = get_opTeam(iFlagTeam)
new szName[32]
get_user_name(id, szName, charsmax(szName))
if(iTeam == iFlagTeam) // If the PLAYER is on the same team as the FLAG
{
if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED) // if the team's flag is dropped, return it to base
{
flag_sendHome(iFlagTeam)
task_remove(ent)
player_award(id, REWARD_RETURN, "for returning your team flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_RETURNED, id, iFlagTeam, false)
new iAssists = 0
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(i != id && g_bAssisted[i][iFlagTeam] && g_iTeam[i] == iFlagTeam)
{
player_award(i, REWARD_RETURN_ASSIST, "for assisting on returning your team flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_RETURNED, i, iFlagTeam, true)
iAssists++
}
g_bAssisted[i][iFlagTeam] = false
}
if(1 <= g_iFlagHolder[iFlagTeamOp] <= g_iMaxPlayers)
g_bAssisted[id][iFlagTeamOp] = true
if(iAssists)
{
new szFormat[64]
format(szFormat, charsmax(szFormat), "%s + %d assists", szName, iAssists)
game_announce(EVENT_RETURNED, iFlagTeam, szFormat)
}
else
game_announce(EVENT_RETURNED, iFlagTeam, szName)
log_message("<%s>%s returned the ^"%s^" flag.", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeam])
set_hudmessage(HUD_HELP)
show_hudmessage(id, "You returned your team flag!")
if(g_bProtected[id])
player_removeProtection(id, "Spawn protection disabled: flag touched")
}
else if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_BASE && g_iFlagHolder[iFlagTeamOp] == id) // if the PLAYER has the ENEMY FLAG and the FLAG is in the BASE make SCORE
{
message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
write_byte(id)
write_byte(0)
message_end()
player_award(id, REWARD_CAPTURE, "for capturing the enemy flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_CAPTURED, id, iFlagTeamOp, false)
new iAssists = 0
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(i != id && g_iTeam[i] > 0 && g_iTeam[i] == iTeam)
{
if(g_bAssisted[i][iFlagTeamOp])
{
player_award(i, REWARD_CAPTURE_ASSIST, "for assisting on capturing the enemy flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_CAPTURED, i, iFlagTeamOp, true)
iAssists++
}
else
player_award(i, REWARD_CAPTURE_TEAM, "because team captured the enemy flag")
}
g_bAssisted[i][iFlagTeamOp] = false
}
set_hudmessage(HUD_HELP)
show_hudmessage(id, "You captured the enemy flag!")
if(iAssists)
{
new szFormat[64]
format(szFormat, charsmax(szFormat), "%s + %d assists", szName, iAssists)
game_announce(EVENT_SCORE, iFlagTeam, szFormat)
}
else
game_announce(EVENT_SCORE, iFlagTeam, szName)
log_message("<%s>%s captured the ^"%s^" flag. (%d assists)", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeamOp], iAssists)
message_begin(MSG_BROADCAST, gMsg_TeamScore)
write_string(g_szCSTeams[iFlagTeam])
write_short(++g_iScore[iFlagTeam])
message_end()
flag_sendHome(iFlagTeamOp)
player_setSpeed(id)
g_fLastDrop[id] = fGameTime + 3.0
if(g_bProtected[id])
player_removeProtection(id, "Spawn protection disabled: flag touched")
else
player_setRender(id)
if(0 < get_pcvar_num(pCvar_mp_winlimit) <= g_iScore[iFlagTeam])
{
emessage_begin(MSG_ALL, SVC_INTERMISSION) /* hookable mapend */
emessage_end()
}
}
}
else
{
if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_BASE)
{
player_award(id, REWARD_STEAL, "for stealing the enemy flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_STOLEN, id, iFlagTeam, false)
log_message("<%s>%s stole the ^"%s^" flag.", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeam])
}
else
{
player_award(id, REWARD_PICKUP, "for picking up the enemy flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_PICKED, id, iFlagTeam, false)
log_message("<%s>%s picked up the ^"%s^" flag.", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeam])
}
set_hudmessage(HUD_HELP)
show_hudmessage(id, "You have the flag, return to base!")
flag_take(iFlagTeam, id)
g_bAssisted[id][iFlagTeam] = true
task_remove(ent)
if(g_bProtected[id])
player_removeProtection(id, "Spawn protection disabled: flag touched")
else
player_setRender(id)
game_announce(EVENT_TAKEN, iFlagTeam, szName)
}
}
public flag_autoReturn(ent)
{
task_remove(ent)
new iFlagTeam = (g_iFlagEntity[TEAM_BLUE] == ent ? TEAM_BLUE : (g_iFlagEntity[TEAM_RED] == ent ? TEAM_RED : 0))
if(!iFlagTeam)
return
flag_sendHome(iFlagTeam)
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_AUTORETURN, 0, iFlagTeam, false)
game_announce(EVENT_RETURNED, iFlagTeam, NULL)
log_message("^"%s^" flag returned automatically", g_szTeamName[iFlagTeam])
}
public base_think(ent)
{
if(!is_valid_ent(ent))
return
entity_set_float(ent, EV_FL_nextthink, get_gametime() + BASE_THINK)
new iFlagTeam = (g_iBaseEntity[TEAM_BLUE] == ent ? TEAM_BLUE : TEAM_RED)
if(g_iFlagHolder[iFlagTeam] != FLAG_HOLD_BASE)
return
static id
static iHealth
id = -1
while((id = find_ent_in_sphere(id, g_fFlagBase[iFlagTeam], BASE_HEAL_DISTANCE)) != 0)
{
if(1 <= id <= g_iMaxPlayers && g_bAlive[id] && g_iTeam[id] == iFlagTeam)
{
iHealth = get_user_health(id)
if(iHealth < 100)
{
set_user_health(id, iHealth + 1)
player_healingEffect(id)
}
}
if(id >= g_iMaxPlayers)
break
}
}
public client_putinserver(id)
{
g_bBot[id] = (is_user_bot(id) ? true : false)
g_iTeam[id] = TEAM_SPEC
g_bFirstSpawn[id] = true
g_bRestarted[id] = false
g_bLights[id] = !g_bBot[id]
task_set(3.0, "client_putinserverPost", id - TASK_PUTINSERVER)
}
public client_putinserverPost(id)
{
id += TASK_PUTINSERVER
player_print(id, id, "This server is running^x04 Just Capture the Flag^x01 by^x03 Digi^x01 - see console for quick-help.")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
client_print(id, print_console, " JUST CAPTURE THE FLAG v%s - QUICK-HELP", MOD_VERSION)
client_print(id, print_console, " Mod by Digi (www.TheHunters.ro)")
client_print(id, print_console, " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
client_print(id, print_console, " You must capture the enemy flag while defending your own.")
client_print(id, print_console, " This mod has lots of features, but you'll learn'em all,")
client_print(id, print_console, " just get in there and start scoring some flag captures!")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " For additional help, type /help in chat")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " You should bind ^"adrenaline^" to a key !")
if(g_iVGUI[id])
client_print(id, print_console, " Also, disable VGUI menus or use /buy command to buy!")
client_print(id, print_console, " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
client_print(id, print_console, WHITESPACE)
}
public client_disconnect(id)
{
player_dropFlag(id)
task_remove(id)
g_iTeam[id] = TEAM_NONE
g_iAdrenaline[id] = 0
g_iAdrenalineUse[id] = 0
g_bAlive[id] = false
g_bLights[id] = false
g_bFreeLook[id] = false
g_bAssisted[id][TEAM_RED] = false
g_bAssisted[id][TEAM_BLUE] = false
}
public client_infochanged(id)
{
new szInfo[2]
get_user_info(id, "_vgui_menus", szInfo, charsmax(szInfo))
if(str_to_num(szInfo))
g_iVGUI[id] = str_to_num(szInfo)
}
public player_joinTeam()
{
new id = read_data(1)
if(g_bAlive[id])
return
new szTeam[2]
read_data(2, szTeam, charsmax(szTeam))
switch(szTeam[0])
{
case 'T':
{
if(g_iTeam[id] == TEAM_RED && g_bFirstSpawn[id])
{
player_respawn(id - TASK_RESPAWN, get_pcvar_num(pCvar_ctf_respawntime) + 1)
task_remove(id - TASK_TEAMBALANCE)
task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
}
g_iTeam[id] = TEAM_RED
}
case 'C':
{
if(g_iTeam[id] == TEAM_BLUE && g_bFirstSpawn[id])
{
player_respawn(id - TASK_RESPAWN, get_pcvar_num(pCvar_ctf_respawntime) + 1)
task_remove(id - TASK_TEAMBALANCE)
task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
}
g_iTeam[id] = TEAM_BLUE
}
case 'U':
{
g_iTeam[id] = TEAM_NONE
g_bFirstSpawn[id] = true
}
default:
{
player_screenFade(id, {0,0,0,0}, 0.0, 0.0, FADE_OUT, false)
player_allowChangeTeam(id)
g_iTeam[id] = TEAM_SPEC
g_bFirstSpawn[id] = true
}
}
}
public player_spawn(id)
{
if(!is_user_alive(id) || (!g_bRestarted[id] && g_bAlive[id]))
return HAM_IGNORED
//client_infochanged(id)
g_bAlive[id] = true
g_bDefuse[id] = false
g_bBuyZone[id] = true
g_bFreeLook[id] = false
g_fLastBuy[id] = Float:{0.0, 0.0, 0.0, 0.0}
task_remove(id - TASK_PROTECTION)
task_remove(id - TASK_EQUIPAMENT)
task_remove(id - TASK_DAMAGEPROTECTION)
task_remove(id - TASK_TEAMBALANCE)
task_remove(id - TASK_ADRENALINE)
task_remove(id - TASK_DEFUSE)
task_set(0.1, "player_spawnEquipament", id - TASK_EQUIPAMENT)
player_hudAdrenaline(id)
player_protection(id - TASK_PROTECTION, get_pcvar_num(pCvar_ctf_protection))
message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
write_byte(id)
write_byte(0)
message_end()
if(g_bFirstSpawn[id] || g_bRestarted[id])
{
g_bRestarted[id] = false
g_bFirstSpawn[id] = false
set_user_xp(id, get_user_xp()
}
else if(g_bSuicide[id])
{
g_bSuicide[id] = false
player_print(id, id, "No spawn money because you commited suicide last life!")
}
else
set_user_xp(id, get_user_xp()
return HAM_IGNORED
}
public player_spawnEquipament(id)
{
id += TASK_EQUIPAMENT
if(!g_bAlive[id])
return
if(g_iVGUI[id])
player_print(id, id, "^x03 NOTICE:^x01 VGUI menus detected, disable them or use^x04 /buy^x01 in chat to buy.")
strip_user_weapons(id)
if(get_pcvar_num(pCvar_ctf_spawn_knife))
give_item(id, g_szWeaponEntity[W_KNIFE])
new szWeapon[3][24]
get_pcvar_string(pCvar_ctf_spawn_prim, szWeapon[1], charsmax(szWeapon[]))
get_pcvar_string(pCvar_ctf_spawn_sec, szWeapon[2], charsmax(szWeapon[]))
for(new iWeapon, i = 2; i >= 1; i--)
{
iWeapon = 0
if(strlen(szWeapon[i]))
{
for(new w = 1; w < sizeof g_szWeaponCommands; w++)
{
if(g_iWeaponSlot[w] == i && equali(szWeapon[i], g_szWeaponCommands[w][0]))
{
iWeapon = w
break
}
}
if(iWeapon)
{
give_item(id, g_szWeaponEntity[iWeapon])
cs_set_user_bpammo(id, iWeapon, g_iBPAmmo[iWeapon])
}
else
log_error(AMX_ERR_NOTFOUND, "WARNING: invalid %s weapon: ^"%s^", please fix ctf_spawn_%s cvar", (i == 1 ? "primary" : "secondary"), szWeapon[i], (i == 1 ? "prim" : "sec"))
}
}
}
public player_protection(id, iStart)
{
id += TASK_PROTECTION
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
return
static iCount[33]
if(iStart)
{
iCount[id] = iStart + 1
g_bProtected[id] = true
player_setRender(id)
}
if(--iCount[id] > 0)
{
set_hudmessage(HUD_RESPAWN)
show_hudmessage(id, "Spawn protection: %d seconds left...", iCount[id])
task_set(1.0, "player_protection", id - TASK_PROTECTION)
}
else
player_removeProtection(id, "Spawn protection expired")
}
public player_removeProtection(id, szText[])
{
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
return
g_bProtected[id] = false
task_remove(id - TASK_PROTECTION)
task_remove(id - TASK_DAMAGEPROTECTION)
set_hudmessage(HUD_PROTECTION)
show_hudmessage(id, szText)
player_setRender(id)
}
public player_currentWeapon(id)
{
if(!g_bAlive[id])
return
static bool:bZoom[33]
new iZoom = read_data(1)
if(1 < iZoom <= 90) /* setFOV event */
bZoom[id] = bool:(iZoom <= 40)
else /* CurWeapon event */
{
g_iWeapon[id] = read_data(2) /* used also elsewhere */
if(!bZoom[id]) /* if not zooming, get weapon speed */
g_fWeaponSpeed[id] = g_fWeaponRunSpeed[g_iWeapon[id]]
else /* if zooming, set zoom speed */
g_fWeaponSpeed[id] = g_fWeaponRunSpeed[0]
player_setSpeed(id)
}
}
public client_PostThink(id)
{
if(!g_bAlive[id])
return
static iOffset
static iShield[33]
iOffset = get_pdata_int(id, m_iUserPrefs)
if(iOffset & (1<<24)) /* Shield available */
{
if(iOffset & (1<<16)) /* Uses shield */
{
if(iShield[id] < 2) /* Trigger only once */
{
iShield[id] = 2
g_fWeaponSpeed[id] = 180.0
player_setSpeed(id)
}
}
else if(iShield[id] == 2) /* Doesn't use the shield anymore */
{
iShield[id] = 1
g_fWeaponSpeed[id] = 250.0
player_setSpeed(id)
}
}
else if(iShield[id]) /* Shield not available anymore */
iShield[id] = 0
}
public player_useWeapon(ent)
{
if(!is_valid_ent(ent))
return
static id
id = entity_get_edict(ent, EV_ENT_owner)
if(1 <= id <= g_iMaxPlayers && g_bAlive[id])
{
if(g_bProtected[id])
player_removeProtection(id, "Spawn protection disabled - weapon used")
else if(g_iAdrenalineUse[id] == ADRENALINE_BERSERKER)
{
set_pdata_float(ent, m_flNextPrimaryAttack, get_pdata_float(ent, m_flNextPrimaryAttack, 4) * BERSERKER_SPEED1)
set_pdata_float(ent, m_flNextSecondaryAttack, get_pdata_float(ent, m_flNextSecondaryAttack, 4) * BERSERKER_SPEED2)
}
}
}
public player_useWeaponSec(ent)
{
if(!is_valid_ent(ent))
return
static id
id = entity_get_edict(ent, EV_ENT_owner)
if(1 <= id <= g_iMaxPlayers && g_bAlive[id] && g_iAdrenalineUse[id] == ADRENALINE_BERSERKER)
{
set_pdata_float(ent, m_flNextPrimaryAttack, get_pdata_float(ent, m_flNextPrimaryAttack, 4) * BERSERKER_SPEED1)
set_pdata_float(ent, m_flNextSecondaryAttack, get_pdata_float(ent, m_flNextSecondaryAttack, 4) * BERSERKER_SPEED2)
}
}
public player_damage(id, iWeapon, iAttacker, Float:fDamage, iType)
{
if(g_bProtected[id])
{
player_setRender(id, fDamage)
task_remove(id - TASK_DAMAGEPROTECTION)
task_set(0.1, "player_damageProtection", id - TASK_DAMAGEPROTECTION)
entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
return HAM_SUPERCEDE
}
else if(1 <= iAttacker <= g_iMaxPlayers && g_iAdrenalineUse[iAttacker] == ADRENALINE_BERSERKER && g_iTeam[iAttacker] != g_iTeam[id])
{
SetHamParamFloat(4, fDamage * BERSERKER_DAMAGE)
new iOrigin[3]
get_user_origin(id, iOrigin)
message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
write_byte(TE_BLOODSPRITE)
write_coord(iOrigin[x] + random_num(-15, 15))
write_coord(iOrigin[y] + random_num(-15, 15))
write_coord(iOrigin[z] + random_num(-15, 15))
write_short(gSpr_blood2)
write_short(gSpr_blood1)
write_byte(248)
write_byte(18)
message_end()
return HAM_OVERRIDE
}
return HAM_IGNORED
}
public player_damageProtection(id)
{
id += TASK_DAMAGEPROTECTION
if(g_bAlive[id])
player_setRender(id)
}
public player_killed(id, killer)
{
g_bAlive[id] = false
g_bBuyZone[id] = false
task_remove(id - TASK_RESPAWN)
task_remove(id - TASK_PROTECTION)
task_remove(id - TASK_EQUIPAMENT)
task_remove(id - TASK_DAMAGEPROTECTION)
task_remove(id - TASK_TEAMBALANCE)
task_remove(id - TASK_ADRENALINE)
task_remove(id - TASK_DEFUSE)
new iHint = random_num(0, sizeof g_szHints - 1)
set_hudmessage(HUD_HINT)
show_hudmessage(id, "Hint: %s", g_szHints[iHint])
client_print(id, print_console, "[ CTF ] Hint: %s", g_szHints[iHint])
new iWeapon = entity_get_edict(id, EV_ENT_dmg_inflictor)
new szWeapon[10]
new bool:bC4 = false
if(iWeapon > g_iMaxPlayers && is_valid_ent(iWeapon))
{
entity_get_string(iWeapon, EV_SZ_classname, szWeapon, charsmax(szWeapon))
if(equal(szWeapon, "grenade") && get_pdata_int(iWeapon, 96) & (1<<8))
{
message_begin(MSG_ALL, gMsg_DeathMsg)
write_byte(killer)
write_byte(id)
write_byte(0)
write_string("c4")
message_end()
bC4 = true
}
}
if(id == killer || !(1 <= killer <= g_iMaxPlayers))
{
g_bSuicide[id] = true
player_award(id, PENALTY_SUICIDE, "for suicide")
if(bC4)
player_setScore(id, -1, 1)
}
else if(1 <= killer <= g_iMaxPlayers)
{
if(g_iTeam[id] == g_iTeam[killer])
{
if(bC4)
{
player_setScore(killer, -1, 0)
cs_set_user_money(killer, clamp(get_user_xp(killer) - 3300, 0, 16000), 1)
}
player_award(killer, PENALTY_TEAMKILL, "for teamkill")
}
else
{
if(bC4)
{
player_setScore(killer, -1, 0)
player_setScore(id, 0, 1)
cs_set_user_money(killer, clamp(get_user_xp(killer) + 300, 0, 16000), 1)
}
if(id == g_iFlagHolder[g_iTeam[killer]])
{
g_bAssisted[killer][g_iTeam[killer]] = true
player_award(killer, REWARD_KILLCARRIER, "for killing the flag carrier")
message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
write_byte(id)
write_byte(0)
message_end()
}
else
{
player_spawnItem(id)
player_award(killer, REWARD_KILL, "for killing")
}
}
}
if(g_iAdrenalineUse[id])
{
switch(g_iAdrenalineUse[id])
{
case ADRENALINE_SPEED:
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_KILLBEAM)
write_short(id)
message_end()
}
}
g_iAdrenaline[id] = 0
g_iAdrenalineUse[id] = 0
player_setRender(id)
player_hudAdrenaline(id)
}
player_respawn(id - TASK_RESPAWN, get_pcvar_num(pCvar_ctf_respawntime))
player_dropFlag(id)
player_allowChangeTeam(id)
task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
}
public player_checkTeam(id)
{
id += TASK_TEAMBALANCE
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || g_bAlive[id] || !get_pcvar_num(pCvar_mp_autoteambalance))
return
new iPlayers[3]
new iTeam = g_iTeam[id]
new iOpTeam = get_opTeam(iTeam)
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(TEAM_RED <= g_iTeam[i] <= TEAM_BLUE)
iPlayers[g_iTeam[i]]++
}
if((iPlayers[iTeam] > 1 && !iPlayers[iOpTeam]) || iPlayers[iTeam] > (iPlayers[iOpTeam] + 1))
{
player_allowChangeTeam(id)
engclient_cmd(id, "jointeam", (iOpTeam == TEAM_BLUE ? "2" : "1"))
set_task(2.0, "player_forceJoinClass", id)
player_print(id, id, "You have been transfered to the^x04 %s team^x01 due to auto-team balance.", g_szTeamName[iOpTeam])
}
}
public player_forceJoinClass(id)
{
engclient_cmd(id, "joinclass", "5")
}
public player_respawn(id, iStart)
{
id += TASK_RESPAWN
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || g_bAlive[id])
return
static iCount[33]
if(iStart)
iCount[id] = iStart + 1
set_hudmessage(HUD_RESPAWN)
if(--iCount[id] > 0)
{
show_hudmessage(id, "Respawning in %d seconds...", iCount[id])
client_print(id, print_console, "Respawning in %d seconds...", iCount[id])
task_set(1.0, "player_respawn", id - TASK_RESPAWN)
}
else
{
show_hudmessage(id, "Respawning...")
client_print(id, print_console, "Respawning...")
entity_set_int(id, EV_INT_deadflag, DEAD_RESPAWNABLE)
entity_set_int(id, EV_INT_iuser1, 0)
entity_think(id)
entity_spawn(id)
set_user_health(id, 100)
}
}
public player_cmd_buySpawn(id)
{
if(g_bAlive[id] || !(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
player_print(id, id, "You must be in a team and dead to buy an instant respawn.")
else if(g_iAdrenaline[id] < INSTANTSPAWN_COST)
player_print(id, id, "You don't have enough adrenaline, %d required!.", INSTANTSPAWN_COST)
else
{
g_iAdrenaline[id] -= INSTANTSPAWN_COST
player_print(id, id, "You bought an instant respawn for %d adrenaline!", INSTANTSPAWN_COST)
task_remove(id)
player_respawn(id - TASK_RESPAWN, -1)
}
return PLUGIN_HANDLED
}
public player_cmd_dropFlag(id)
{
if(!g_bAlive[id] || id != g_iFlagHolder[get_opTeam(g_iTeam[id])])
player_print(id, id, "You don't have the flag!")
else
{
new iOpTeam = get_opTeam(g_iTeam[id])
player_dropFlag(id)
player_award(id, PENALTY_DROP, "for intentionally dropping the flag")
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_MANUALDROP, id, iOpTeam, false)
g_bAssisted[id][iOpTeam] = false
}
return PLUGIN_HANDLED
}
public player_dropFlag(id)
{
new iOpTeam = get_opTeam(g_iTeam[id])
if(id != g_iFlagHolder[iOpTeam])
return
new ent = g_iFlagEntity[iOpTeam]
if(!is_valid_ent(ent))
return
g_fLastDrop[id] = get_gametime() + 2.0
g_iFlagHolder[iOpTeam] = FLAG_HOLD_DROPPED
entity_set_edict(ent, EV_ENT_aiment, -1)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_int(ent, EV_INT_sequence, FLAG_ANI_DROPPED)
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
entity_set_origin(ent, g_fFlagLocation[iOpTeam])
task_set(get_pcvar_float(pCvar_ctf_flagreturn), "flag_autoReturn", ent)
if(g_bAlive[id])
{
new Float:fVelocity[3]
velocity_by_aim(id, 200, fVelocity)
fVelocity[z] = 0.0
entity_set_vector(ent, EV_VEC_velocity, fVelocity)
player_setSpeed(id)
player_setRender(id)
message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
write_byte(id)
write_byte(0)
message_end()
}
else
entity_set_vector(ent, EV_VEC_velocity, FLAG_DROP_VELOCITY)
new szName[32]
get_user_name(id, szName, charsmax(szName))
game_announce(EVENT_DROPPED, iOpTeam, szName)
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_DROPPED, id, iOpTeam, false)
g_fFlagDropped[iOpTeam] = get_gametime()
log_message("<%s>%s dropped the ^"%s^" flag.", g_szTeamName[g_iTeam[id]], szName, g_szTeamName[iOpTeam])
}
public player_cmd_say(id)
{
static Float:fLastUsage[33]
new Float:fGameTime = get_gametime()
if((fLastUsage[id] + 0.5) > fGameTime)
return PLUGIN_HANDLED
fLastUsage[id] = fGameTime
new szMsg[128]
read_args(szMsg, charsmax(szMsg))
remove_quotes(szMsg)
trim(szMsg)
if(equal(szMsg, NULL))
return PLUGIN_HANDLED
if(equal(szMsg[0], "@"))
return PLUGIN_CONTINUE
new szFormat[192]
new szName[32]
get_user_name(id, szName, charsmax(szName))
switch(g_iTeam[id])
{
case TEAM_RED, TEAM_BLUE: formatex(szFormat, charsmax(szFormat), "^x01%s^x03%s ^x01: %s", (g_bAlive[id] ? NULL : "^x01*DEAD* "), szName, szMsg)
case TEAM_NONE, TEAM_SPEC: formatex(szFormat, charsmax(szFormat), "^x01*SPEC* ^x03%s ^x01: %s", szName, szMsg)
}
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(i == id || g_iTeam[i] == TEAM_NONE || g_bAlive[i] == g_bAlive[id] || g_bBot[id])
continue
message_begin(MSG_ONE, gMsg_SayText, _, i)
write_byte(id)
write_string(szFormat)
message_end()
}
if(equali(szMsg, "/buy"))
{
player_menu_buy(id, 0)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/spawn"))
{
player_cmd_buySpawn(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/adrenaline"))
{
player_cmd_adrenaline(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/help"))
{
player_cmd_help(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/dropflag"))
{
player_cmd_dropFlag(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/lights", 7))
{
player_cmd_setLights(id, szMsg[8])
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/sounds", 7))
{
player_cmd_setSounds(id, szMsg[8])
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public player_cmd_sayTeam(id)
{
static Float:fLastUsage[33]
new Float:fGameTime = get_gametime()
if((fLastUsage[id] + 0.5) > fGameTime)
return PLUGIN_HANDLED
fLastUsage[id] = fGameTime
new szMsg[128]
read_args(szMsg, charsmax(szMsg))
remove_quotes(szMsg)
trim(szMsg)
if(equal(szMsg, NULL))
return PLUGIN_HANDLED
if(equal(szMsg[0], "@"))
return PLUGIN_CONTINUE
new szFormat[192]
new szName[32]
get_user_name(id, szName, charsmax(szName))
switch(g_iTeam[id])
{
case TEAM_RED, TEAM_BLUE: formatex(szFormat, charsmax(szFormat), "^x01%s(%s) ^x03%s ^x01: %s", (g_bAlive[id] ? NULL : "*DEAD* "), g_szTeamName[g_iTeam[id]], szName, szMsg)
case TEAM_NONE, TEAM_SPEC: formatex(szFormat, charsmax(szFormat), "^x01*SPEC*(Spectator) ^x03%s ^x01: %s", szName, szMsg)
}
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(i == id || g_iTeam[i] == TEAM_NONE || g_iTeam[i] != g_iTeam[id] || g_bAlive[i] == g_bAlive[id] || g_bBot[id])
continue
message_begin(MSG_ONE, gMsg_SayText, _, i)
write_byte(id)
write_string(szFormat)
message_end()
}
if(equali(szMsg, "/buy"))
{
player_menu_buy(id, 0)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/spawn"))
{
player_cmd_buySpawn(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/dropflag"))
{
player_cmd_dropFlag(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/adrenaline"))
{
player_cmd_adrenaline(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
else if(equali(szMsg, "/help"))
{
player_cmd_help(id)
return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public player_cmd_help(id)
{
client_cmd(id, "hideconsole;toggleconsole")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
client_print(id, print_console, " JUST CAPTURE THE FLAG v%s - HELP", MOD_VERSION)
client_print(id, print_console, " Mod by Digi (www.TheHunters.ro)")
client_print(id, print_console, " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
client_print(id, print_console, " 1. Mod gameplay")
client_print(id, print_console, " 2. Player commands")
client_print(id, print_console, " 3. Get mod/download for your server")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " --- 1: MOD GAMEPLAY ---")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, "Gameplay is simple, two teams, RED (Terrorists) and BLUE (CTs), each having a flag near their base.")
client_print(id, print_console, "The goal of each team is to capture the enemy flag while defending their own because in order to capture the enemy flag, you must bring it to your base and your flag must be there.")
client_print(id, print_console, "Enemy flags are stolen and team flags are returned by a simple touch.")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " --- 2: PLAYER COMMANDS ---")
client_print(id, print_console, "NOTE: Only say/sayteam commands have ^"/^" !")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, "(say) /lights - enables/disables dynamic flag lights for that player")
client_print(id, print_console, "(say) /sounds 1-10 or test - sets the announcer volume or tests the announcer volume")
client_print(id, print_console, "(say/sayteam) /spawn - buy an instant spawn for %d adrenaline", INSTANTSPAWN_COST)
client_print(id, print_console, "(say/sayteam/console) /dropflag - drops the flag (You will loose all rewards got!)")
client_print(id, print_console, "(say/sayteam/console) /adrenaline - adrenaline combo pick menu once you got 100 adrenaline.")
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, WHITESPACE)
client_print(id, print_console, " --- 3: DOWNLOAD MOD ---")
client_print(id, print_console, " Developer's link: http://thehunters.ro/jctf")
client_print(id, print_console, " AMXX forums: http://forums.alliedmods.net/showthread.php?t=132115")
client_print(id, print_console, " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
client_print(id, print_console, WHITESPACE)
return PLUGIN_HANDLED
}
public player_cmd_setLights(id, const szMsg[])
{
switch(szMsg[1])
{
case 'n':
{
g_bLights[id] = true
player_print(id, id, "The flag lights have been turned^x04 ON^x01 (only appliable this map)")
}
case 'f':
{
g_bLights[id] = false
player_print(id, id, "The flag lights have been turned^x04 OFF^x01 (only appliable this map)")
}
default: player_print(id, id, "Invalid parameter, use^x04 on^x01 /^x04 off")
}
return PLUGIN_HANDLED
}
public player_cmd_setSounds(id, const szMsg[])
{
if(equali(szMsg, "test"))
{
player_print(id, id, "Announcement test, you should hear^x04 Red Flag Taken^x01...")
client_cmd(id, "mp3 play ^"sound/ctf/red_flag_taken.mp3^"")
return PLUGIN_HANDLED
}
new iVol = (strlen(szMsg) ? str_to_num(szMsg) : -1)
if(0 <= iVol <= 10)
{
client_cmd(id, "mp3volume %.2f", iVol == 0 ? 0.0 : iVol * 0.1)
player_print(id, id, "Announcement sound volume set to^x04 %d", iVol)
}
else
player_print(id, id, "Invalid parameter, use a number from^x04 0^x01 to^x04 10^x01 or^x04 test")
return PLUGIN_HANDLED
}
public player_cmd_adrenaline(id)
{
player_hudAdrenaline(id)
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || !g_bAlive[id])
return player_print(id, id, "You must be alive to use adrenaline!")
if(g_iAdrenalineUse[id])
return player_print(id, id, "You already are using adrenaline, wait until it's done!")
if(g_iAdrenaline[id] < 100)
return player_print(id, id, "Not enough adrenaline, it must be full (100) to use it !")
show_menu(id, MENU_KEYS_ADRENALINE, MENU_ADRENALINE_CONTENT, -1, MENU_ADRENALINE)
return PLUGIN_HANDLED
}
public player_key_adrenaline(id, iKey)
{
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || !g_bAlive[id])
return player_print(id, id, "You must be alive to use adrenaline!")
if(g_iAdrenalineUse[id])
return player_print(id, id, "You already are using adrenaline, wait until it's done!")
if(g_iAdrenaline[id] < 100)
return player_print(id, id, "Not enough adrenaline, it must be full (100) to use it !")
iKey += 1
if(1 <= iKey <= 4)
player_useAdrenaline(id, iKey)
return PLUGIN_HANDLED
}
public player_useAdrenaline(id, iUse)
{
if(!(1 <= iUse <= 4))
return PLUGIN_HANDLED
if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || !g_bAlive[id])
return player_print(id, id, "You must be alive to use adrenaline!")
if(g_iAdrenalineUse[id])
return player_print(id, id, "You already are using adrenaline, wait until it's done!")
if(g_iAdrenaline[id] < 100)
return player_print(id, id, "Not enough adrenaline, it must be full (100) to use it !")
if(g_bProtected[id])
player_removeProtection(id, "Spawn protection disabled: adrenaline used")
g_iAdrenalineUse[id] = iUse
task_set(0.25, "player_adrenalineDrain", id - TASK_ADRENALINE)
if(iUse == ADRENALINE_SPEED)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(id)
write_short(gSpr_trail)
write_byte(8) // life in 0.1's
write_byte(6) // line width in 0.1's
write_byte(255)
write_byte(255)
write_byte(0)
write_byte(255) // brightness
message_end()
player_setSpeed(id)
}
player_setRender(id)
new iOrigin[3]
get_user_origin(id, iOrigin)
message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
write_byte(TE_IMPLOSION)
write_coord(iOrigin[x])
write_coord(iOrigin[y])
write_coord(iOrigin[z])
write_byte(128) // radius
write_byte(32) // count
write_byte(4) // life in 0.1's
message_end()
emit_sound(id, CHAN_ITEM, SND_ADRENALINE, VOL_NORM, ATTN_NORM, 0, 255)
return PLUGIN_HANDLED
}
public player_adrenalineDrain(id)
{
id += TASK_ADRENALINE
if(!g_bAlive[id] || !g_iAdrenalineUse[id] || !(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
{
g_iAdrenaline[id] = 0
return
}
if(g_iAdrenaline[id] > 0)
{
new iDrain = (player_hasFlag(id) ? 2 : 1)
g_iAdrenaline[id] = clamp(g_iAdrenaline[id] - (g_iAdrenalineUse[id] == ADRENALINE_REGENERATE ? iDrain : iDrain * 2), 0, 100)
switch(g_iAdrenalineUse[id])
{
case ADRENALINE_REGENERATE:
{
new iHealth = get_user_health(id)
if(iHealth < 150)
set_user_health(id, iHealth + 1)
else
{
new CsArmorType:ArmorType
new iArmor = cs_get_user_armor(id, ArmorType)
if(iArmor < 100)
cs_set_user_armor(id, iArmor + 1, CS_ARMOR_VESTHELM)
}
player_healingEffect(id)
}
}
task_set(0.25, "player_adrenalineDrain", id - TASK_ADRENALINE)
}
else
{
new iUsed = g_iAdrenalineUse[id]
g_iAdrenaline[id] = 0
g_iAdrenalineUse[id] = 0 /* to allow player_setSpeed() to work correctly */
switch(iUsed)
{
case ADRENALINE_SPEED:
{
player_setSpeed(id)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_KILLBEAM)
write_short(id)
message_end()
}
case ADRENALINE_BERSERKER, ADRENALINE_INVISIBILITY: player_setRender(id)
}
}
player_hudAdrenaline(id)
}
public admin_cmd_moveFlag(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new szTeam[2]
read_argv(1, szTeam, charsmax(szTeam))
new iTeam = str_to_num(szTeam)
if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
{
switch(szTeam[0])
{
case 'r', 'R': iTeam = 1
case 'b', 'B': iTeam = 2
}
}
if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
return PLUGIN_HANDLED
entity_get_vector(id, EV_VEC_origin, g_fFlagBase[iTeam])
entity_set_origin(g_iBaseEntity[iTeam], g_fFlagBase[iTeam])
entity_set_vector(g_iBaseEntity[iTeam], EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
if(g_iFlagHolder[iTeam] == FLAG_HOLD_BASE)
{
entity_set_origin(g_iFlagEntity[iTeam], g_fFlagBase[iTeam])
entity_set_vector(g_iFlagEntity[iTeam], EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
}
new szName[32]
new szSteam[48]
get_user_name(id, szName, charsmax(szName))
get_user_authid(id, szSteam, charsmax(szSteam))
log_amx("Admin %s<%s><%s> moved %s flag to %.0f %.0 %.0f", szName, szSteam, g_szTeamName[g_iTeam[id]], g_szTeamName[iTeam], g_fFlagBase[iTeam][0], g_fFlagBase[iTeam][1], g_fFlagBase[iTeam][2])
show_activity(id, szName, "moved %s flag's base", g_szTeamName[iTeam])
client_print(id, print_console, "[ CTF ] %s flag base moved to your origin.", g_szTeamName[iTeam])
return PLUGIN_HANDLED
}
public admin_cmd_saveFlags(id, level, cid)
{
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new iOrigin[3][3]
new szFile[96]
new szBuffer[1024]
FVecIVec(g_fFlagBase[TEAM_RED], iOrigin[TEAM_RED])
FVecIVec(g_fFlagBase[TEAM_BLUE], iOrigin[TEAM_BLUE])
formatex(szBuffer, charsmax(szBuffer), "%d %d %d^n%d %d %d", iOrigin[TEAM_RED][x], iOrigin[TEAM_RED][y], iOrigin[TEAM_RED][z], iOrigin[TEAM_BLUE][x], iOrigin[TEAM_BLUE][y], iOrigin[TEAM_BLUE][z])
formatex(szFile, charsmax(szFile), "maps/%s.ctf", g_szMap)
if(file_exists(szFile))
delete_file(szFile)
write_file(szFile, szBuffer)
new szName[32]
new szSteam[48]
get_user_name(id, szName, charsmax(szName))
get_user_authid(id, szSteam, charsmax(szSteam))
log_amx("Admin %s<%s><%s> saved flag positions.", szName, szSteam, g_szTeamName[g_iTeam[id]])
client_print(id, print_console, "[ CTF ] Saved configuration file ^"%s^"", szFile)
return PLUGIN_HANDLED
}
public admin_cmd_returnFlag(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new szTeam[2]
read_argv(1, szTeam, charsmax(szTeam))
new iTeam = str_to_num(szTeam)
if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
{
switch(szTeam[0])
{
case 'r', 'R': iTeam = 1
case 'b', 'B': iTeam = 2
}
}
if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
return PLUGIN_HANDLED
if(g_iFlagHolder[iTeam] == FLAG_HOLD_DROPPED)
{
if(g_fFlagDropped[iTeam] < (get_gametime() - ADMIN_RETURNWAIT))
{
new szName[32]
new szSteam[48]
new Float:fFlagOrigin[3]
entity_get_vector(g_iFlagEntity[iTeam], EV_VEC_origin, fFlagOrigin)
flag_sendHome(iTeam)
ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_AUTORETURN, 0, iTeam, false)
game_announce(EVENT_RETURNED, iTeam, NULL)
get_user_name(id, szName, charsmax(szName))
get_user_authid(id, szSteam, charsmax(szSteam))
log_message("^"%s^" flag returned by admin %s<%s><%s>", g_szTeamName[iTeam], szName, szSteam, g_szTeamName[g_iTeam[id]])
log_amx("Admin %s<%s><%s> returned %s flag from %.1f %.1f %.1f", szName, szSteam, g_szTeamName[g_iTeam[id]], g_szTeamName[iTeam], fFlagOrigin[0], fFlagOrigin[1], fFlagOrigin[2])
show_activity(id, szName, "returned the %s flag", g_szTeamName[iTeam])
client_print(id, print_console, "[ CTF ] %s flag returned to it's base.", g_szTeamName[iTeam])
}
else
client_print(id, print_console, "[ CTF ] %s flag needs to be dropped at least %d seconds before you can return it by command.", g_szTeamName[iTeam], ADMIN_RETURNWAIT)
}
else
client_print(id, print_console, "[ CTF ] %s flag is not dropped!", g_szTeamName[iTeam])
return PLUGIN_HANDLED
}
public player_inBuyZone(id)
{
if(!g_bAlive[id])
return
g_bBuyZone[id] = (read_data(1) ? true : false)
if(!g_bBuyZone[id])
set_pdata_int(id, 205, 0) // no "close menu upon exit buyzone" thing
}
public player_cmd_setAutobuy(id)
{
new iIndex
new szWeapon[24]
new szArgs[1024]
read_args(szArgs, charsmax(szArgs))
remove_quotes(szArgs)
trim(szArgs)
while(contain(szArgs, WHITESPACE) != -1)
{
strbreak(szArgs, szWeapon, charsmax(szWeapon), szArgs, charsmax(szArgs))
for(new bool:bFound, w = W_P228; w <= W_NVG; w++)
{
if(!bFound)
{
for(new i = 0; i < 2; i++)
{
if(!bFound && equali(g_szWeaponCommands[w][i], szWeapon))
{
bFound = true
g_iAutobuy[id][iIndex++] = w
}
}
}
}
}
player_cmd_autobuy(id)
return PLUGIN_HANDLED
}
public player_cmd_autobuy(id)
{
if(!g_bAlive[id])
return PLUGIN_HANDLED
if(!g_bBuyZone[id])
{
client_print(id, print_center, "You must be in a buy zone!")
return PLUGIN_HANDLED
}
new iMoney = get_user_xp(id)
for(new bool:bBought[6], iWeapon, i = 0; i < sizeof g_iAutobuy[]; i++)
{
if(!g_iAutobuy[id][i])
return PLUGIN_HANDLED
iWeapon = g_iAutobuy[id][i]
if(bBought[g_iWeaponSlot[iWeapon]])
continue
if((g_iWeaponPrice[iWeapon] > 0 && g_iWeaponPrice[iWeapon] > iMoney) || (g_iWeaponAdrenaline[iWeapon] > 0 && g_iWeaponAdrenaline[iWeapon] > g_iAdrenaline[id]))
continue
player_buyWeapon(id, iWeapon)
bBought[g_iWeaponSlot[iWeapon]] = true
}
return PLUGIN_HANDLED
}
public player_cmd_setRebuy(id)
{
new iIndex
new szType[18]
new szArgs[256]
read_args(szArgs, charsmax(szArgs))
replace_all(szArgs, charsmax(szArgs), "^"", NULL)
trim(szArgs)
while(contain(szArgs, WHITESPACE) != -1)
{
split(szArgs, szType, charsmax(szType), szArgs, charsmax(szArgs), WHITESPACE)
for(new i = 1; i < sizeof g_szRebuyCommands; i++)
{
if(equali(szType, g_szRebuyCommands[i]))
g_iRebuy[id][++iIndex] = i
}
}
player_cmd_rebuy(id)
return PLUGIN_HANDLED
}
public player_cmd_rebuy(id)
{
if(!g_bAlive[id])
return PLUGIN_HANDLED
if(!g_bBuyZone[id])
{
client_print(id, print_center, "You must be in a buy zone!")
return PLUGIN_HANDLED
}
new iBought
for(new iType, iBuy, i = 1; i < sizeof g_iRebuy[]; i++)
{
iType = g_iRebuy[id][i]
if(!iType)
continue
iBuy = g_iRebuyWeapons[id][iType]
if(!iBuy)
continue
switch(iType)
{
case primary, secondary: player_buyWeapon(id, iBuy)
case armor: player_buyWeapon(id, (iBuy == 2 ? W_VESTHELM : W_VEST))
case he: player_buyWeapon(id, W_HEGRENADE)
case flash:
{
player_buyWeapon(id, W_FLASHBANG)
if(iBuy == 2)
player_buyWeapon(id, W_FLASHBANG)
}
case smoke: player_buyWeapon(id, W_SMOKEGRENADE)
case nvg: player_buyWeapon(id, W_NVG)
}
iBought++
if(iType == flash && iBuy == 2)
iBought++
}
if(iBought)
client_print(id, print_center, "%d items attempted to be rebought!", iBought)
return PLUGIN_HANDLED
}
public player_addRebuy(id, iWeapon)
{
if(!g_bAlive[id])
return
switch(g_iWeaponSlot[iWeapon])
{
case 1: g_iRebuyWeapons[id][primary] = iWeapon
case 2: g_iRebuyWeapons[id][secondary] = iWeapon
default:
{
switch(iWeapon)
{
case W_VEST: g_iRebuyWeapons[id][armor] = (g_iRebuyWeapons[id][armor] == 2 ? 2 : 1)
case W_VESTHELM: g_iRebuyWeapons[id][armor] = 2
case W_FLASHBANG: g_iRebuyWeapons[id][flash] = clamp(g_iRebuyWeapons[id][flash] + 1, 0, 2)
case W_HEGRENADE: g_iRebuyWeapons[id][he] = 1
case W_SMOKEGRENADE: g_iRebuyWeapons[id][smoke] = 1
case W_NVG: g_iRebuyWeapons[id][nvg] = 1
}
}
}
}
public player_cmd_buy_main(id)
return player_menu_buy(id, 0)
public player_cmd_buy_equipament(id)
return player_menu_buy(id, 8)
public player_menu_buy(id, iMenu)
{
if(!g_bAlive[id])
return PLUGIN_HANDLED
if(!g_bBuyZone[id])
{
client_print(id, print_center, "You must be in a buy zone!")
return PLUGIN_HANDLED
}
static szMenu[1024]
new iMoney = get_user_xp(id)
switch(iMenu)
{
case 1:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu: Pistols^n^n\d1. \%sGlock 18\R$%d^n\d2. \%sUSP\R$%d^n\d3. \%sP228\R$%d^n\d4. \%sDesert Eagle\R$%d^n\d5. \%sFiveseven\R$%d^n\d6. \%sDual Elites\R$%d^n^n\w0. Exit",
(iMoney >= g_iWeaponPrice[W_GLOCK18] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_GLOCK18],
(iMoney >= g_iWeaponPrice[W_USP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_USP],
(iMoney >= g_iWeaponPrice[W_P228] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_P228],
(iMoney >= g_iWeaponPrice[W_DEAGLE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_DEAGLE],
(iMoney >= g_iWeaponPrice[W_FIVESEVEN] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_FIVESEVEN],
(iMoney >= g_iWeaponPrice[W_ELITE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_ELITE]
)
}
case 2:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu: Shotguns^n^n\d1. \%sM3 Super90\R$%d^n\d2. \%sXM1014\R$%d^n^n\w0. Exit",
(iMoney >= g_iWeaponPrice[W_M3] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M3],
(iMoney >= g_iWeaponPrice[W_XM1014] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_XM1014]
)
}
case 3:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu: Sub-machine guns^n^n\d1. \%sTMP\R$%d^n\d2. \%sMac-10\R$%d^n\d3. \%sMP5 Navy\R$%d^n\d4. \%sUMP-45\R$%d^n\d5. \%sP90\R$%d^n^n\w0. Exit",
(iMoney >= g_iWeaponPrice[W_TMP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_TMP],
(iMoney >= g_iWeaponPrice[W_MAC10] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_MAC10],
(iMoney >= g_iWeaponPrice[W_MP5NAVY] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_MP5NAVY],
(iMoney >= g_iWeaponPrice[W_UMP45] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_UMP45],
(iMoney >= g_iWeaponPrice[W_P90] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_P90]
)
}
case 4:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu: Rifles^n^n\d1. \%sGalil\R$%d^n\d2. \%sFamas\R$%d^n\d3. \%sAK-47\R$%d^n\d4. \%sM4A1\R$%d^n\d5. \%sAUG\R$%d^n\d6. \%sSG552\R$%d^n^n\w0. Exit",
(iMoney >= g_iWeaponPrice[W_GALIL] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_GALIL],
(iMoney >= g_iWeaponPrice[W_FAMAS] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_FAMAS],
(iMoney >= g_iWeaponPrice[W_AK47] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AK47],
(iMoney >= g_iWeaponPrice[W_M4A1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M4A1],
(iMoney >= g_iWeaponPrice[W_AUG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AUG],
(iMoney >= g_iWeaponPrice[W_SG552] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG552]
)
}
case 5:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu: Special weapons^n^n\d1. \%sM249 \w(\%s%d adrenaline\w)\R\%s$%d^n\d3. \%sSG550 \w(\%s%d adrenaline\w)\R\%s$%d^n\d3. \%sG3SG1 \w(\%s%d adrenaline\w)\R\%s$%d^n\d4. \%sScout \w(\%s%d adrenaline\w)\R\%s$%d^n\d5. \%sAWP \w(\%s%d adrenaline\w)\R\%s$%d^n\d6. \%sShield \w(\%s%d adrenaline\w)\R\%s$%d^n\d7. \%sC4 \w(\%s%d adrenaline\w)\R\%s$%d^n^n\w0. Exit",
(iMoney >= g_iWeaponPrice[W_M249] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_M249], (iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M249],
(iMoney >= g_iWeaponPrice[W_SG550] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SG550] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SG550], (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG550],
(iMoney >= g_iWeaponPrice[W_G3SG1] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_G3SG1] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_G3SG1], (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_G3SG1],
(iMoney >= g_iWeaponPrice[W_SCOUT] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SCOUT] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SCOUT], (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SCOUT],
(iMoney >= g_iWeaponPrice[W_AWP] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_AWP] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_AWP], (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AWP],
(iMoney >= g_iWeaponPrice[W_SHIELD] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SHIELD] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SHIELD], (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SHIELD],
(iMoney >= g_iWeaponPrice[W_C4] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_C4] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_C4] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_C4], (iMoney >= g_iWeaponPrice[W_C4] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_C4]
)
}
case 8:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu: Equipament^n^n\d1. \%sKevlar\R$%d^n\d2. \%sKevlar + Helmet\R$%d^n^n\d3. \%sFlashbang\R$%d^n\d4. \%sHE Grenade\R$%d^n\d5. \%sSmoke Grenade\R$%d^n^n\d7. \%sNightvision goggles\R$%d^n^n\w0. Exit",
(iMoney >= g_iWeaponPrice[W_VEST] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_VEST],
(iMoney >= g_iWeaponPrice[W_VESTHELM] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_VESTHELM],
(iMoney >= g_iWeaponPrice[W_FLASHBANG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_FLASHBANG],
(iMoney >= g_iWeaponPrice[W_HEGRENADE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_HEGRENADE],
(iMoney >= g_iWeaponPrice[W_SMOKEGRENADE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SMOKEGRENADE],
(iMoney >= g_iWeaponPrice[W_NVG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_NVG]
)
}
default:
{
formatex(szMenu, charsmax(szMenu),
"\yCTF Buy Menu^n^n\d1. \%sPistols^n\d2. \%sShotguns^n\d3. \%sSub-machine guns^n\d4. \%sRifles^n\d5. \%sSpecial weapons^n^n\d6. \wFull ammo\R$0^n^n\d8. \%sEquipament^n^n\d0. \wExit",
(iMoney >= g_iWeaponPrice[W_GLOCK18] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),
(iMoney >= g_iWeaponPrice[W_M3] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),
(iMoney >= g_iWeaponPrice[W_TMP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),
(iMoney >= g_iWeaponPrice[W_GALIL] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),
(iMoney >= g_iWeaponPrice[W_M249] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),
(iMoney >= g_iWeaponPrice[W_FLASHBANG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED)
)
}
}
g_iMenu[id] = iMenu
show_menu(id, MENU_KEYS_BUY, szMenu, -1, MENU_BUY)
return PLUGIN_HANDLED
}
public player_key_buy(id, iKey)
{
iKey += 1
if(!g_bAlive[id] || iKey == 10)
return PLUGIN_HANDLED
if(!g_bBuyZone[id])
{
client_print(id, print_center, "You must be in a buy zone!")
return PLUGIN_HANDLED
}
switch(g_iMenu[id])
{
case 1:
{
switch(iKey)
{
case 1: player_buyWeapon(id, W_GLOCK18)
case 2: player_buyWeapon(id, W_USP)
case 3: player_buyWeapon(id, W_P228)
case 4: player_buyWeapon(id, W_DEAGLE)
case 5: player_buyWeapon(id, W_FIVESEVEN)
case 6: player_buyWeapon(id, W_ELITE)
}
}
case 2:
{
switch(iKey)
{
case 1: player_buyWeapon(id, W_M3)
case 2: player_buyWeapon(id, W_XM1014)
}
}
case 3:
{
switch(iKey)
{
case 1: player_buyWeapon(id, W_TMP)
case 2: player_buyWeapon(id, W_MAC10)
case 3: player_buyWeapon(id, W_MP5NAVY)
case 4: player_buyWeapon(id, W_UMP45)
case 5: player_buyWeapon(id, W_P90)
}
}
case 4:
{
switch(iKey)
{
case 1: player_buyWeapon(id, W_GALIL)
case 2: player_buyWeapon(id, W_FAMAS)
case 3: player_buyWeapon(id, W_AK47)
case 4: player_buyWeapon(id, W_M4A1)
case 5: player_buyWeapon(id, W_AUG)
case 6: player_buyWeapon(id, W_SG552)
}
}
case 5:
{
switch(iKey)
{
case 1: player_buyWeapon(id, W_M249)
case 2: player_buyWeapon(id, W_SG550)
case 3: player_buyWeapon(id, W_G3SG1)
case 4: player_buyWeapon(id, W_SCOUT)
case 5: player_buyWeapon(id, W_AWP)
case 6: player_buyWeapon(id, W_SHIELD)
case 7: player_buyWeapon(id, W_C4)
}
}
case 8:
{
switch(iKey)
{
case 1: player_buyWeapon(id, W_VEST)
case 2: player_buyWeapon(id, W_VESTHELM)
case 3: player_buyWeapon(id, W_FLASHBANG)
case 4: player_buyWeapon(id, W_HEGRENADE)
case 5: player_buyWeapon(id, W_SMOKEGRENADE)
case 7: player_buyWeapon(id, W_NVG)
}
}
default:
{
switch(iKey)
{
case 1,2,3,4,5,8: player_menu_buy(id, iKey)
case 6,7: player_fillAmmo(id)
}
}
}
return PLUGIN_HANDLED
}
public player_cmd_buyWeapon(id)
{
if(!g_bBuyZone[id])
{
client_print(id, print_center, "You must be in a buy zone!")
return PLUGIN_HANDLED
}
new szCmd[12]
read_argv(0, szCmd, charsmax(szCmd))
for(new w = W_P228; w <= W_NVG; w++)
{
for(new i = 0; i < 2; i++)
{
if(equali(g_szWeaponCommands[w][i], szCmd))
{
player_buyWeapon(id, w)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_HANDLED
}
public player_buyWeapon(id, iWeapon)
{
if(!g_bAlive[id])
return
new CsArmorType:ArmorType
new iArmor = cs_get_user_armor(id, ArmorType)
new iMoney = get_user_xp(id)
/* apply discount if you already have a kevlar and buying a kevlar+helmet */
new iCost = g_iWeaponPrice[iWeapon] - (ArmorType == CS_ARMOR_KEVLAR && iWeapon == W_VESTHELM ? 650 : 0)
if(iCost > iMoney)
{
client_print(id, print_center, "Not enough money, you need $%d", iCost)
return
}
else if(!(g_iWeaponAdrenaline[iWeapon] <= g_iAdrenaline[id]))
{
client_print(id, print_center, "Not enough adrenaline, you need %d", g_iWeaponAdrenaline[iWeapon])
return
}
switch(iWeapon)
{
case W_C4:
{
if(user_has_weapon(id, W_C4))
{
client_print(id, print_center, "You already have a C4!")
return
}
player_giveC4(id)
}
case W_NVG:
{
if(cs_get_user_nvg(id))
{
client_print(id, print_center, "You already have nightvision!")
return
}
cs_set_user_nvg(id, 1)
}
case W_VEST:
{
if(iArmor >= 100)
{
client_print(id, print_center, "You already have a kevlar!")
return
}
}
case W_VESTHELM:
{
if(iArmor >= 100 && ArmorType == CS_ARMOR_VESTHELM)
{
client_print(id, print_center, "You already have a kevlar and helmet!")
return
}
}
case W_FLASHBANG:
{
new iGrenades = cs_get_user_bpammo(id, W_FLASHBANG)
if(iGrenades >= 2)
{
client_print(id, print_center, "You can't carry any more flashbangs!")
return
}
new iCvar = get_pcvar_num(pCvar_ctf_nospam_flash)
new Float:fGameTime = get_gametime()
if(g_fLastBuy[id][iGrenades] > fGameTime)
{
client_print(id, print_center, "You can buy two flashbang grenades every %d seconds!", iCvar)
return
}
g_fLastBuy[id][iGrenades] = fGameTime + iCvar
if(iGrenades == 1)
g_fLastBuy[id][0] = g_fLastBuy[id][iGrenades]
}
case W_HEGRENADE:
{
if(cs_get_user_bpammo(id, W_HEGRENADE) >= 1)
{
client_print(id, print_center, "You can't carry any more HE grenades!")
return
}
new iCvar = get_pcvar_num(pCvar_ctf_nospam_he)
new Float:fGameTime = get_gametime()
if(g_fLastBuy[id][2] > fGameTime)
{
client_print(id, print_center, "You can buy a HE grenade every %d seconds!", iCvar)
return
}
g_fLastBuy[id][2] = fGameTime + iCvar
}
case W_SMOKEGRENADE:
{
if(cs_get_user_bpammo(id, W_SMOKEGRENADE) >= 1)
{
client_print(id, print_center, "You can't carry any more smoke grenades!")
return
}
new iCvar = get_pcvar_num(pCvar_ctf_nospam_smoke)
new Float:fGameTime = get_gametime()
if(g_fLastBuy[id][3] > fGameTime)
{
client_print(id, print_center, "You can buy a smoke grenade every %d seconds!", iCvar)
return
}
g_fLastBuy[id][3] = fGameTime + iCvar
}
}
if(1 <= g_iWeaponSlot[iWeapon] <= 2)
{
new iWeapons
new iWeaponList[32]
get_user_weapons(id, iWeaponList, iWeapons)
if(cs_get_user_shield(id))
iWeaponList[iWeapons++] = W_SHIELD
for(new w, i = 0; i < iWeapons; i++)
{
w = iWeaponList[i]
if(1 <= g_iWeaponSlot[w] <= 2)
{
if(w == iWeapon)
{
client_print(id, print_center, "You already have that weapon!")
return
}
if(iWeapon == W_SHIELD && w == W_ELITE)
engclient_cmd(id, "drop", g_szWeaponEntity[W_ELITE]) // drop the dual elites too if buying a shield
if(iWeapon == W_ELITE && w == W_SHIELD)
engclient_cmd(id, "drop", g_szWeaponEntity[W_SHIELD]) // drop the too shield if buying dual elites
if(g_iWeaponSlot[w] == g_iWeaponSlot[iWeapon])
{
if(g_iWeaponSlot[w] == 2 && iWeaponList[iWeapons-1] == W_SHIELD)
{
engclient_cmd(id, "drop", g_szWeaponEntity[W_SHIELD]) // drop the shield
new ent = find_ent_by_owner(g_iMaxPlayers, g_szWeaponEntity[W_SHIELD], id)
if(ent)
{
entity_set_int(ent, EV_INT_flags, FL_KILLME) // kill the shield
call_think(ent)
}
engclient_cmd(id, "drop", g_szWeaponEntity[w]) // drop the secondary
give_item(id, g_szWeaponEntity[W_SHIELD]) // give back the shield
}
else
engclient_cmd(id, "drop", g_szWeaponEntity[w]) // drop weapon if it's of the same slot
}
}
}
}
if(iWeapon != W_NVG && iWeapon != W_C4)
give_item(id, g_szWeaponEntity[iWeapon])
player_addRebuy(id, iWeapon)
if(g_iWeaponPrice[iWeapon])
cs_set_user_money(id, iMoney - iCost, 1)
if(g_iWeaponAdrenaline[iWeapon])
{
g_iAdrenaline[id] -= g_iWeaponAdrenaline[iWeapon]
player_hudAdrenaline(id)
}
if(g_iBPAmmo[iWeapon])
cs_set_user_bpammo(id, iWeapon, g_iBPAmmo[iWeapon])
}
public player_fillAmmo(id)
{
if(!g_bAlive[id])
return PLUGIN_HANDLED
if(!g_bBuyZone[id])
{
client_print(id, print_center, "You must be in a buy zone!")
return PLUGIN_HANDLED
}
if(player_getAmmo(id))
{
emit_sound(id, CHAN_ITEM, SND_GETAMMO, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Ammo filled")
}
return PLUGIN_HANDLED
}
public c4_used(msgid, dest, id)
{
if(g_iTeam[id])
player_setSpeed(id)
if(get_msg_arg_int(1) == 0)
g_bDefuse[id] = false
return PLUGIN_HANDLED
}
public c4_planted()
{
new szLogUser[80], szName[32]
read_logargv(0, szLogUser, charsmax(szLogUser))
parse_loguser(szLogUser, szName, charsmax(szName))
new id = get_user_index(szName)
new ent = g_iMaxPlayers
new Float:fAngles[3]
entity_get_vector(id, EV_VEC_angles, fAngles)
fAngles[pitch] = 0.0
fAngles[yaw] += 90.0
fAngles[roll] = 0.0
client_print(id, print_center, "C4 armed, detonation in %d seconds!", get_pcvar_num(pCvar_mp_c4timer))
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(g_iTeam[i] == g_iTeam[id] && !g_bBot[id])
{
/* fully fake hookable radio message and event */
emessage_begin(MSG_ONE, gMsg_TextMsg, _, i)
ewrite_byte(3)
ewrite_string("#Game_radio")
ewrite_string(szName)
ewrite_string("Planted a C4 device!")
emessage_end()
emessage_begin(MSG_ONE, gMsg_SendAudio, _, i)
ewrite_byte(id)
ewrite_string("%!MRAD_BLOW")
ewrite_short(100)
emessage_end()
}
}
while((ent = find_ent_by_owner(ent, "grenade", id)))
{
if(get_pdata_int(ent, 96) & (1<<8))
{
entity_set_int(ent, EV_INT_solid, SOLID_NOT)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_float(ent, EV_FL_gravity, 1.0)
entity_set_vector(ent, EV_VEC_angles, fAngles)
return
}
}
}
public c4_defuse(ent, id, activator, iType, Float:fValue)
{
if(g_bAlive[id] && get_pdata_int(ent, 96) & (1<<8))
{
new iOwner = entity_get_edict(ent, EV_ENT_owner)
if(id != iOwner && 1 <= iOwner <= g_iMaxPlayers && g_iTeam[id] == g_iTeam[iOwner])
{
client_print(id, print_center, "Can't defuse team's C4, better run!")
client_cmd(id, "-use")
return HAM_SUPERCEDE
}
if(g_iTeam[id] == TEAM_RED)
{
set_pdata_int(id, 114, TEAM_BLUE, 5)
ExecuteHam(Ham_Use, ent, id, activator, iType, fValue)
set_pdata_int(id, 114, TEAM_RED, 5)
}
if(!g_bDefuse[id])
{
client_print(id, print_center, "Defusing C4 in %d seconds...", C4_DEFUSETIME)
message_begin(MSG_ONE_UNRELIABLE, gMsg_BarTime, _, id)
write_short(C4_DEFUSETIME)
message_end()
set_pdata_float(ent, 99, get_gametime() + C4_DEFUSETIME, 5)
g_bDefuse[id] = true
}
}
return HAM_IGNORED
}
public c4_defused()
{
new szLogUser[80], szName[32]
read_logargv(0, szLogUser, charsmax(szLogUser))
parse_loguser(szLogUser, szName, charsmax(szName))
new id = get_user_index(szName)
if(!g_bAlive[id])
return
g_bDefuse[id] = false
player_giveC4(id)
client_print(id, print_center, "C4 disarmed, now it's yours!")
}
public weapon_touch(ent, id)
{
if(g_bAlive[id] && is_valid_ent(ent) && (entity_get_int(ent, EV_INT_flags) & FL_ONGROUND))
{
new szModel[32]
entity_get_string(ent, EV_SZ_model, szModel, charsmax(szModel))
if(equal(szModel, "models/w_backpack.mdl"))
{
if(user_has_weapon(id, W_C4))
return PLUGIN_HANDLED
player_giveC4(id)
entity_remove(ent)
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public weapon_spawn(ent)
{
if(!is_valid_ent(ent))
return
new szClass[32]
entity_get_string(ent, EV_SZ_classname, szClass, charsmax(szClass))
task_remove(ent)
task_set(get_pcvar_float(pCvar_ctf_weaponstay), "weapon_startFade", ent)
}
public weapon_startFade(ent)
{
if(!is_valid_ent(ent))
return
new szClass[32]
entity_get_string(ent, EV_SZ_classname, szClass, charsmax(szClass))
if(!equal(szClass, "weaponbox") && !equal(szClass, ITEM_CLASSNAME))
return
entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY)
entity_set_int(ent, EV_INT_rendermode, kRenderTransAlpha)
entity_set_int(ent, EV_INT_renderfx, kRenderFxGlowShell)
entity_set_float(ent, EV_FL_renderamt, 255.0)
entity_set_vector(ent, EV_VEC_rendercolor, Float:{255.0, 255.0, 0.0})
entity_set_vector(ent, EV_VEC_velocity, Float:{0.0, 0.0, 20.0})
weapon_fadeOut(ent, 255.0)
}
public weapon_fadeOut(ent, Float:fStart)
{
if(!is_valid_ent(ent))
{
task_remove(ent)
return
}
static Float:fFadeAmount[4096]
if(fStart)
{
task_remove(ent)
fFadeAmount[ent] = fStart
}
fFadeAmount[ent] -= 25.5
if(fFadeAmount[ent] > 0.0)
{
entity_set_float(ent, EV_FL_renderamt, fFadeAmount[ent])
task_set(0.1, "weapon_fadeOut", ent)
}
else
entity_remove(ent)
}
public item_touch(ent, id)
{
if(g_bAlive[id] && is_valid_ent(ent) && entity_get_int(ent, EV_INT_flags) & FL_ONGROUND)
{
new iType = entity_get_int(ent, EV_INT_iuser2)
switch(iType)
{
case ITEM_AMMO:
{
if(!player_getAmmo(id))
return PLUGIN_HANDLED
client_print(id, print_center, "Picked up ammo pack")
emit_sound(id, CHAN_ITEM, SND_GETAMMO, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
case ITEM_MEDKIT:
{
new iHealth = get_user_health(id)
if(iHealth >= 100)
return PLUGIN_HANDLED
set_user_health(id, clamp(iHealth + ITEM_MEDKIT_GIVE, 0, 100))
client_print(id, print_center, "Picked up medkit +%d health", ITEM_MEDKIT_GIVE)
emit_sound(id, CHAN_ITEM, SND_GETMEDKIT, VOL_NORM, ATTN_NORM, 0, 110)
}
case ITEM_ADRENALINE:
{
if(g_iAdrenaline[id] >= 100)
return PLUGIN_HANDLED
g_iAdrenaline[id] = clamp(g_iAdrenaline[id] + ITEM_ADRENALINE_GIVE, 0, 100)
player_hudAdrenaline(id)
client_print(id, print_center, "Picked up adrenaline +%d", ITEM_ADRENALINE_GIVE)
emit_sound(id, CHAN_ITEM, SND_GETADRENALINE, VOL_NORM, ATTN_NORM, 0, 140)
}
}
task_remove(ent)
entity_remove(ent)
}
return PLUGIN_CONTINUE
}
public event_restartGame()
g_bRestarting = true
public event_roundStart()
{
if(g_bRestarting)
{
g_iScore = {0, 0, 0}
g_bRestarting = false
for(new id = 1; id < g_iMaxPlayers; id++)
{
task_remove(id)
task_remove(id - TASK_EQUIPAMENT)
task_remove(id - TASK_TEAMBALANCE)
task_remove(id - TASK_ADRENALINE)
task_remove(id - TASK_DEFUSE)
g_bRestarted[id] = true
g_iAdrenaline[id] = 0
g_iAdrenalineUse[id] = 0
}
for(new iFlagTeam = TEAM_RED; iFlagTeam <= TEAM_BLUE; iFlagTeam++)
{
flag_sendHome(iFlagTeam)
task_remove(g_iFlagEntity[iFlagTeam])
g_iScore[iFlagTeam] = 0
g_iFlagHolder[iFlagTeam] = FLAG_HOLD_BASE
log_message("Game restarted, ^"%s^" flag returned back to base.", g_szTeamName[iFlagTeam])
}
new ent = -1
while((ent = find_ent_by_class(ent, "weaponbox")) > 0)
{
task_remove(ent)
entity_remove(ent)
}
ent = -1
while((ent = find_ent_by_class(ent, ITEM_CLASSNAME)) > 0)
{
task_remove(ent)
entity_remove(ent)
}
}
}
public msg_block()
return PLUGIN_HANDLED
public msg_sendAudio()
{
new szAudio[14]
get_msg_arg_string(2, szAudio, charsmax(szAudio))
return equal(szAudio, "%!MRAD_BOMB", 11) ? PLUGIN_HANDLED : PLUGIN_CONTINUE
}
public msg_screenFade(msgid, dest, id)
return (g_bProtected[id] && g_bAlive[id] && get_msg_arg_int(4) == 255 && get_msg_arg_int(5) == 255 && get_msg_arg_int(6) == 255 && get_msg_arg_int(7) > 199 ? PLUGIN_HANDLED : PLUGIN_CONTINUE)
public msg_scoreAttrib()
return (get_msg_arg_int(2) & (1<<1) ? PLUGIN_HANDLED : PLUGIN_CONTINUE)
public msg_teamScore()
{
new szTeam[2]
get_msg_arg_string(1, szTeam, 1)
switch(szTeam[0])
{
case 'T': set_msg_arg_int(2, ARG_SHORT, g_iScore[TEAM_RED])
case 'C': set_msg_arg_int(2, ARG_SHORT, g_iScore[TEAM_BLUE])
}
}
public msg_roundTime()
set_msg_arg_int(1, ARG_SHORT, get_timeleft())
public msg_sayText()
{
new szString[32]
get_msg_arg_string(2, szString, charsmax(szString))
new iTeam = (szString[14] == 'T' ? TEAM_RED : (szString[14] == 'C' ? TEAM_BLUE : TEAM_SPEC))
new bool:bDead = (szString[16] == 'D' || szString[17] == 'D')
if(TEAM_RED <= iTeam <= TEAM_BLUE && equali(szString, "#Cstrike_Chat_", 14))
{
formatex(szString, charsmax(szString), "^x01%s(%s)^x03 %%s1^x01 : %%s2", (bDead ? "*DEAD* " : NULL), g_szTeamName[iTeam])
set_msg_arg_string(2, szString)
}
}
public msg_textMsg(msgid, dest, id)
{
static szMsg[12]
get_msg_arg_string(2, szMsg, charsmax(szMsg))
if(equal(szMsg, "#Spec_Mode", 10) && !get_pcvar_num(pCvar_mp_fadetoblack) && (get_pcvar_num(pCvar_mp_forcecamera) || get_pcvar_num(pCvar_mp_forcechasecam)))
{
if(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE && szMsg[10] == '3')
{
if(!g_bFreeLook[id])
{
player_screenFade(id, {0,0,0,255}, 0.25, 9999.0, FADE_IN, true)
g_bFreeLook[id] = true
}
set_msg_arg_string(2, "Free look mode is blocked")
}
else if(g_bFreeLook[id])
{
player_screenFade(id, {0,0,0,255}, 0.25, 0.0, FADE_OUT, true)
g_bFreeLook[id] = false
}
}
else if(equal(szMsg, "#Only_1", 7))
set_msg_arg_string(2, "You can change your team only once after each death!")
else if(equal(szMsg, "#Defusing", 9) || equal(szMsg, "#Got_bomb", 9) || equal(szMsg, "#Game_bomb", 10) || equal(szMsg, "#Bomb", 5) || equal(szMsg, "#Target", 7))
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
player_award(id, iMoney, iFrags, iAdrenaline, szText[])
{
if(!g_iTeam[id])
return
new bool:bPrint = (strlen(szText) && (iMoney || iFrags || iAdrenaline) ? true : false)
new szMoney[24]
new szFrags[48]
new szAdrenaline[48]
if(iMoney != 0)
{
cs_set_user_money(id, clamp(get_user_xp(id) + iMoney, 0, 16000), 1)
if(bPrint)
formatex(szMoney, charsmax(szMoney), "%s%d$", iMoney > 0 ? "+" : NULL, iMoney)
}
if(iFrags != 0)
{
player_setScore(id, iFrags, 0)
if(bPrint)
formatex(szFrags, charsmax(szFrags), "%s%d frag%s", iFrags > 0 ? "+" : NULL, iFrags, iFrags > 1 ? "s" : NULL)
}
if(iAdrenaline != 0)
{
g_iAdrenaline[id] = clamp(g_iAdrenaline[id] + iAdrenaline, 0, 100)
player_hudAdrenaline(id)
if(bPrint)
formatex(szAdrenaline, charsmax(szAdrenaline), "%s%d adrenaline", iAdrenaline > 0 ? "+" : NULL, iAdrenaline)
}
if(bPrint)
{
new szFormat[192]
formatex(szFormat, charsmax(szFormat), "%s%s%s%s%s %s", szMoney, (szMoney[0] && (szFrags[0] || szAdrenaline[0]) ? ", " : NULL), szFrags, (szFrags[0] && szAdrenaline[0] ? ", " : NULL), szAdrenaline, szText)
client_print(id, print_console, "[ CTF ] Reward: %s", szFormat)
client_print(id, print_center, szFormat)
}
}
player_hudAdrenaline(id)
{
set_hudmessage(HUD_ADRENALINE)
show_hudmessage(id, "%s%s%sAdrenaline: %d of 100%s", (g_iAdrenalineUse[id] ? "Using " : NULL), (g_iAdrenalineUse[id] ? g_szAdrenalineUse[g_iAdrenalineUse[id]] : NULL), (g_iAdrenalineUse[id] ? "^n" : NULL), g_iAdrenaline[id], (!g_iAdrenalineUse[id] && g_iAdrenaline[id] >= 100 ? "^nFull! You can now use a combo (adrenaline command)" : NULL))
}
player_print(id, iSender, szMsg[], any:...)
{
if(g_bBot[id] || (id && !g_iTeam[id]))
return PLUGIN_HANDLED
new szFormat[192]
vformat(szFormat, charsmax(szFormat), szMsg, 4)
format(szFormat, charsmax(szFormat), "^x01[^x04 CTF^x01 ] %s", szFormat)
if(id)
message_begin(MSG_ONE, gMsg_SayText, _, id)
else
message_begin(MSG_ALL, gMsg_SayText)
write_byte(iSender)
write_string(szFormat)
message_end()
return PLUGIN_HANDLED
}
bool:player_getAmmo(id)
{
if(!g_bAlive[id])
return false
new iWeapons
new iWeaponList[32]
new bool:bGotAmmo = false
get_user_weapons(id, iWeaponList, iWeapons)
for(new iAmmo, iClip, ent, w, i = 0; i < iWeapons; i++)
{
w = iWeaponList[i]
if(g_iBPAmmo[w])
{
ent = find_ent_by_owner(g_iMaxPlayers, g_szWeaponEntity[w], id)
iAmmo = cs_get_user_bpammo(id, w)
iClip = (ent ? cs_get_weapon_ammo(ent) : 0)
if((iAmmo + iClip) < (g_iBPAmmo[w] + g_iClip[w]))
{
cs_set_user_bpammo(id, w, g_iBPAmmo[w] + (g_iClip[w] - iClip))
bGotAmmo = true
}
}
}
return bGotAmmo
}
player_setScore(id, iAddFrags, iAddDeaths)
{
new iFrags = get_user_frags(id)
new iDeaths = cs_get_user_deaths(id)
if(iAddFrags != 0)
{
iFrags += iAddFrags
set_user_frags(id, iFrags)
}
if(iAddDeaths != 0)
{
iDeaths += iAddDeaths
cs_set_user_deaths(id, iDeaths)
}
message_begin(MSG_BROADCAST, gMsg_ScoreInfo)
write_byte(id)
write_short(iFrags)
write_short(iDeaths)
write_short(0)
write_short(g_iTeam[id])
message_end()
}
player_spawnItem(id)
{
if(random_num(1, 100) > get_pcvar_float(pCvar_ctf_itempercent))
return
new ent = entity_create(INFO_TARGET)
if(!ent)
return
new iType = random_num(0, 2)
new Float:fOrigin[3]
new Float:fAngles[3]
new Float:fVelocity[3]
entity_get_vector(id, EV_VEC_origin, fOrigin)
fVelocity[x] = random_float(-100.0, 100.0)
fVelocity[y] = random_float(-100.0, 100.0)
fVelocity[z] = 50.0
fAngles[yaw] = random_float(0.0, 360.0)
switch(iType)
{
case ITEM_AMMO: entity_set_model(ent, ITEM_MODEL_AMMO)
case ITEM_MEDKIT: entity_set_model(ent, ITEM_MODEL_MEDKIT)
case ITEM_ADRENALINE:
{
entity_set_model(ent, ITEM_MODEL_ADRENALINE)
entity_set_int(ent, EV_INT_skin, 2)
}
}
entity_set_string(ent, EV_SZ_classname, ITEM_CLASSNAME)
entity_spawn(ent)
entity_set_size(ent, ITEM_HULL_MIN, ITEM_HULL_MAX)
entity_set_origin(ent, fOrigin)
entity_set_vector(ent, EV_VEC_angles, fAngles)
entity_set_vector(ent, EV_VEC_velocity, fVelocity)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
entity_set_int(ent, EV_INT_iuser2, iType)
task_remove(ent)
task_set(get_pcvar_float(pCvar_ctf_weaponstay), "weapon_startFade", ent)
}
player_giveC4(id)
{
give_item(id, g_szWeaponEntity[W_C4])
cs_set_user_plant(id, 1, 1)
}
player_healingEffect(id)
{
new iOrigin[3]
get_user_origin(id, iOrigin)
message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
write_byte(TE_PROJECTILE)
write_coord(iOrigin[x] + random_num(-10, 10))
write_coord(iOrigin[y] + random_num(-10, 10))
write_coord(iOrigin[z] + random_num(0, 30))
write_coord(0)
write_coord(0)
write_coord(15)
write_short(gSpr_regeneration)
write_byte(1)
write_byte(id)
message_end()
}
player_setRender(id, Float:fDamage = 0.0)
{
new iTeam = g_iTeam[id]
new iMode = kRenderNormal
new iEffect = kRenderFxNone
new iAmount = 0
new iColor[3] = {0,0,0}
if(g_bProtected[id])
{
iEffect = kRenderFxGlowShell
iAmount = 200
iColor[0] = (iTeam == TEAM_RED ? 155 : 0)
iColor[1] = (fDamage > 0.0 ? 100 - clamp(floatround(fDamage), 0, 100) : 0)
iColor[2] = (iTeam == TEAM_BLUE ? 155 : 0)
}
switch(g_iAdrenalineUse[id])
{
case ADRENALINE_BERSERKER:
{
iEffect = kRenderFxGlowShell
iAmount = 160
iColor = {55, 0, 55}
}
case ADRENALINE_INVISIBILITY:
{
iMode = kRenderTransAlpha
iEffect = kRenderFxGlowShell
iAmount = 10
iColor = {15, 15, 15}
}
}
if(player_hasFlag(id))
{
if(iMode != kRenderTransAlpha)
iMode = kRenderNormal
iEffect = kRenderFxGlowShell
iColor[0] = (iTeam == TEAM_RED ? (iColor[0] > 0 ? 200 : 155) : 0)
iColor[1] = (iAmount == 160 ? 55 : 0)
iColor[2] = (iTeam == TEAM_BLUE ? (iColor[2] > 0 ? 200 : 155) : 0)
iAmount = (iAmount == 160 ? 50 : (iAmount == 10 ? 20 : 30))
}
set_user_rendering(id, iEffect, iColor[0], iColor[1], iColor[2], iMode, iAmount)
}
player_setSpeed(id)
{
new Float:fSpeed = 1.0
if(player_hasFlag(id))
fSpeed *= SPEED_FLAG
if(g_iAdrenalineUse[id] == ADRENALINE_SPEED)
fSpeed *= SPEED_ADRENALINE
set_user_maxspeed(id, g_fWeaponSpeed[id] * fSpeed)
}
player_screenFade(id, iColor[4] = {0,0,0,0}, Float:fEffect = 0.0, Float:fHold = 0.0, iFlags = FADE_OUT, bool:bReliable = false)
{
if(id && !g_iTeam[id])
return
static iType
if(1 <= id <= g_iMaxPlayers)
iType = (bReliable ? MSG_ONE : MSG_ONE_UNRELIABLE)
else
iType = (bReliable ? MSG_ALL : MSG_BROADCAST)
message_begin(iType, gMsg_ScreenFade, _, id)
write_short(clamp(floatround(fEffect * (1<<12)), 0, 0xFFFF))
write_short(clamp(floatround(fHold * (1<<12)), 0, 0xFFFF))
write_short(iFlags)
write_byte(iColor[0])
write_byte(iColor[1])
write_byte(iColor[2])
write_byte(iColor[3])
message_end()
}
game_announce(iEvent, iFlagTeam, szName[])
{
new iColor = iFlagTeam
new szText[64]
switch(iEvent)
{
case EVENT_TAKEN:
{
iColor = get_opTeam(iFlagTeam)
formatex(szText, charsmax(szText), "%s took the %s flag!", szName, g_szTeamName[iFlagTeam])
}
case EVENT_DROPPED: formatex(szText, charsmax(szText), "%s dropped the %s flag!", szName, g_szTeamName[iFlagTeam])
case EVENT_RETURNED: formatex(szText, charsmax(szText), (strlen(szName) >= 1 ? "%s returned the %s flag!" : "%sThe %s flag returned automatically!"), szName, g_szTeamName[iFlagTeam])
case EVENT_SCORE: formatex(szText, charsmax(szText), "%s captured the %s flag!", szName, g_szTeamName[get_opTeam(iFlagTeam)])
}
set_hudmessage(iColor == TEAM_RED ? 255 : 0, 0, iColor == TEAM_BLUE ? 255 : 0, HUD_ANNOUNCE)
show_hudmessage(0, szText)
client_print(0, print_console, "[ CTF ] Announcement: %s", szText)
if(get_pcvar_num(pCvar_ctf_sound[iEvent]))
client_cmd(0, "mp3 play ^"sound/ctf/%s.mp3^"", g_szSounds[iEvent][iFlagTeam])
}
I try, but 3-error show.
1 Error.
Could not locate output file /home/groups/amxmodx/public_html/websc3/textQM1eaV.amx (compile failed).