Code:
//Mafia!
/* CVARS copy and paste to shconfig.cfg
//Mafia
mafia_level 10 // Level where this hero can be choosen
mafia_galilmult 3.0 // His Galil Mult
mafia_knifemult 3.0 // His Knife
mafia_armor 150 // His body protection
mafia_money 50000 // amout of money mafia starts with
*/
#include <amxmod>
#include <Vexd_Utilities>
#include <superheromod>
//Global Variables
new gHeroName[]="Mafia"
new bool:gHasMafiaPower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
//Plugin Info
register_plugin("SUPERHERO Mafia","1.0","mega")
//DO NOT EDIT THESE CVARS. USE shconfig.cfg
register_cvar("mafia_level", "10")
register_cvar("mafia_galilmult", "3.0")
register_cvar("mafia_knifemult", "3.0")
register_cvar("mafia_armor","150")
register_cvar("mafia_money","50000")
//FIRE THIS EVENT TO CREATE THIS HERO
shCreateHero(gHeroName, "Mafia", "Get a tommygun, a knife, and get $50.000", false, "mafia_level")
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS
register_srvcmd("mafia_init", "mafia_init")
shRegHeroInit(gHeroName, "mafia_init")
//EVENTS
register_event("ResetHUD", "newSpawn","b")
register_event("CurWeapon", "weaponChange","be","1=1")
register_event("Damage", "mafia_damage", "b","2!0")
register_event("ResetHUD","newRound","b")
//DEATH
register_event("DeathMsg", "mafia_death", "a")
// MAFIA'S VARIABLE
shSetMaxArmor(gHeroName, "mafia_armor" )
}
//----------------------------------------------------------------------------------------------
public mafia_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has Mafia
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
//Reset thier shield restrict status
//Shield restrict MUST be before weapons are given out
shResetShield(id)
//Got to remove powers from a Superman that lost his powers...
//This gets run if they had the power but don't anymore
if ( !hasPowers && gHasMafiaPower[id] && is_user_alive(id) ) {
shRemArmorPower(id)
mafia_weapons(id)
switchmodel(id)
}
else {
engclient_cmd(id,"drop","weapon_galil")
//Sets this variable to the current status
gHasMafiaPower[id] = (hasPowers != 0)
}
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_model("models/shmod/mafia_galil.mdl")
precache_model("models/shmod/mafia_knife.mdl")
precache_model("models/player/mafia/mafia.mdl")
}
//----------------------------------------------------------------------------------------------
public newSpawn(id)
{
if ( gHasMafiaPower[id] && is_user_alive(id) && shModActive() ) {
set_task(0.1, "mafia_weapons", id)
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
if (wpnid != CSW_GALIL && wpnid > 0) {
new wpn[32]
get_weaponname(wpnid,wpn,31)
engclient_cmd(id,wpn)
}
}
}
//----------------------------------------------------------------------------------------------
public newRound(id)
{
new money
if ( gHasMafiaPower[id] && is_user_alive(id) && shModActive() ){
money=cs_get_user_money(id)
new addmoney=floatround(money * 0.1)
money+=addmoney
cs_set_user_money( id, money, 1 )
cs_set_user_money(id,get_cvar_num("gates_money"))
}
}
//----------------------------------------------------------------------------------------------
public Money(id,num) // check money
{
new userMoney = cs_get_user_money(id)
if (userMoney < 0)
{
client_print(id,print_center,"You have insufficient funds!")
return false
}
cs_set_user_money(id,userMoney)
return true
}
//----------------------------------------------------------------------------------------------
public mafia_weapons(id)
{
if ( is_user_alive(id) && shModActive() ) {
shGiveWeapon(id,"weapon_galil")
}
}
//----------------------------------------------------------------------------------------------
public switchmodel(id)
{
if ( !is_user_alive(id) || !gHasMafiaPower[id] ) return
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
if (wpnid == CSW_GALIL) {
// Weapon Model change thanks to [CCC]Taz-Devil
Entvars_Set_String(id, EV_SZ_viewmodel, "models/shmod/mafia_galil.mdl")
} else
if (wpnid == CSW_KNIFE) {
// Weapon Model change thanks to [CCC]Taz-Devil
Entvars_Set_String(id, EV_SZ_viewmodel, "models/shmod/mafia_knife.mdl")
}
}
//----------------------------------------------------------------------------------------------
public weaponChange(id)
{
if ( !gHasMafiaPower[id] || !shModActive() ) return
new wpnid = read_data(2)
new clip = read_data(3)
if ( wpnid != CSW_GALIL) return
switchmodel(id)
// Never Run Out of Ammo!
if ( clip == 0 ) {
shReloadAmmo(id)
}
}
//----------------------------------------------------------------------------------------------
public mafia_death()
{
new id = read_data(2)
if ( !gHasMafiaPower[id] ) return
}
//----------------------------------------------------------------------------------------------
public mafia_damage(id)
{
if (!shModActive() || !is_user_alive(id)) return
new damage = read_data(2)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
new headshot = bodypart == 1 ? 1 : 0
if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return
if ( gHasMafiaPower[attacker] && weapon == CSW_GALIL && is_user_alive(id) ) {
// do extra damage
new extraDamage = floatround(damage * get_cvar_float("mafia_galilmult") - damage)
if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "galil", headshot )
} else
if ( gHasMafiaPower[attacker] && weapon == CSW_KNIFE && is_user_alive(id) ) {
new extraDamage = floatround(damage * get_cvar_float("mafia_knifemult") - damage)
if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "knife", headshot )
}
}
//----------------------------------------------------------------------------------------------