PHP Code:
#define PLUGINNAME "Starting weapon"
#define VERSION "0.2"
#define AUTHOR "JGHG"
/*
Copyleft 2005
Plugin topic: http://www.amxmodx.org/forums/viewtopic.php?p=95649
STARTING WEAPONS
================
REQUIRED MODULES: CSTRIKE, FUN, ENGINE
Two cvars: startingweapons_t and startingweapons_ct.
Define them like this:
startingweapons_t "weapon_famas ammo556nato weapon_knife"
startingweapons_ct "strip weapon_scout ammo_762nato"
...or any other way you like. Just make sure to use quotes around the stuff and delimit each item with a space. Consult the following list
for valid names, and what ammo goes with what gun. If you set the cvars empty, players won't even have a knife.
Note that placing "strip" somewhere among the items will first make a player be stripped off of ALL his weapons. If you don't add "strip"
they will still have knife and glock/usp beside the other stuff you add.
Besides weapons you can also give items like the shield, c4, nvg, etc.
Default stuff for both teams is: "strip weapon_knife weapon_elite ammo_9mm"
"weapon_p228", ammo_357sig
"weapon_shield",
"weapon_scout", ammo_762nato
"weapon_hegrenade",
"weapon_xm1014", ammo_buckshot
"weapon_c4",
"weapon_mac10", ammo_45acp
"weapon_aug", ammo_556nato
"weapon_smokegrenade",
"weapon_elite", ammo_9mm
"weapon_fiveseven" ammo_57mm
"weapon_ump45", ammo_45acp
"weapon_sg550", ammo_556nato
"weapon_galil", ammo_556nato
"weapon_famas", ammo_556nato
"weapon_usp", ammo_45acp
"weapon_glock18", ammo_9mm
"weapon_awp", ammo_338magnum
"weapon_mp5navy", ammo_9mm
"weapon_m249", ammo_556natobox
"weapon_m3", ammo_buckshot
"weapon_m4a1", ammo_556nato
"weapon_tmp", ammo_9mm
"weapon_g3sg1", ammo_762nato
"weapon_flashbang",
"weapon_deagle", ammo_50ae
"weapon_sg552", ammo_556nato
"weapon_ak47", ammo_762nato
"weapon_knife", // the butterknife
"weapon_p90", ammo_57mm
"item_kevlar", // armor w/out helmet
"item_assaultsuit", // armor w/ helmet
"item_thighpack" // defuse kit
"item_nvg" // night-vision goggles
/JGHG
VERSIONS
========
050226 0.2 Fixed stuff :-) Stripping was probably not working. Now you can also give multiple grenades.
050226 0.1 First version
*/
#include <amxmodx>
#include <fun>
#include <engine>
#include <cstrike>
#define TEAM_T 1
#define TEAM_CT 2
#define CVAR_DEFAULT_T "startingweapons_t"
#define CVAR_DEFAULT_CT "startingweapons_ct"
public plugin_modules() {
require_module("fun")
require_module("engine")
require_module("cstrike")
}
public event_spawn(id) {
if (!is_user_alive(id))
return PLUGIN_CONTINUE
new team = get_user_team(id)
if (team != TEAM_T && team != TEAM_CT)
return PLUGIN_CONTINUE
new params[2]
params[0] = id
switch (team) {
case TEAM_T: params[1] = true
case TEAM_CT: params[1] = false
}
set_task(0.1, "givedefault", 0, params, 2)
return PLUGIN_CONTINUE
}
public givedefault(params[2]) {
new id = params[0]
new terrorist = params[1]
new bool:hasBomb = false
new stuff[256]
get_cvar_string(terrorist ? CVAR_DEFAULT_T : CVAR_DEFAULT_CT, stuff, 255)
if (containi(stuff, "strip") != -1) {
if (terrorist) {
new c4 = 0
while ((c4 = find_ent_by_class(c4, "weapon_c4"))) {
if (entity_get_edict(c4, EV_ENT_owner) == id) {
hasBomb = true
break
}
}
}
strip_user_weapons(id)
if (hasBomb) {
give_item(id, "weapon_c4")
cs_set_user_plant(id)
}
replace(stuff, 255, "strip", "")
}
// startingweapons_t "strip weapon_c4 weapon_c4 weapon_flashbang weapon_flashbang weapon_flashbang weapon_hegrenade weapon_hegrenade weapon_smokegrenade weapon_smokegrenade"
new parsedParams, arg[256], flashies = 0, hes = 0, smokies = 0, c4s = hasBomb ? 1 : 0
do {
parsedParams = parse(stuff, arg, 255)
if (parsedParams == 1) {
replace(stuff, 255, arg, "")
if (containi(arg, "item_thighpack") != -1)
cs_set_user_defuse(id)
else if (containi(arg, "item_nvg") != -1)
cs_set_user_nvg(id)
else if (containi(arg, "weapon_c4") != -1) {
cs_set_user_plant(id)
if (hasBomb)
hasBomb = false
else if (++c4s == 1)
give_item(id, "weapon_c4")
else
cs_set_user_bpammo(id, CSW_C4, c4s)
}
else if (containi(arg, "weapon_hegrenade") != -1) {
if (++hes == 1)
give_item(id, "weapon_hegrenade")
else
cs_set_user_bpammo(id, CSW_HEGRENADE, hes)
}
else if (containi(arg, "weapon_flashbang") != -1) {
if (++flashies == 1)
give_item(id, "weapon_flashbang")
else
cs_set_user_bpammo(id, CSW_FLASHBANG, flashies)
}
else if (containi(arg, "weapon_smokegrenade") != -1) {
if (++smokies == 1)
give_item(id, "weapon_smokegrenade")
else
cs_set_user_bpammo(id, CSW_SMOKEGRENADE, smokies)
}
else
give_item(id, arg)
}
else
return
} while (parsedParams == 1)
}
public plugin_init() {
register_plugin(PLUGINNAME, VERSION, AUTHOR)
register_cvar(CVAR_DEFAULT_T, "strip weapon_knife weapon_elite ammo_9mm")
register_cvar(CVAR_DEFAULT_CT, "strip weapon_knife weapon_elite ammo_9mm")
register_event("ResetHUD", "event_spawn", "b")
register_event("DeathMsg", "event_death", "a")
register_event("TextMsg", "event_restart", "a", "2&#Game_C", "2&#Game_w")
register_event("TextMsg", "event_restart", "a", "2&#Game_will_restart_in")
}