Member
|
06-25-2014
, 18:54
Re: How To Make a Gun Hero
|
#12
|
I have this hero Splask.
Quote:
//New Super Kool Gun! With More Damage.
#include <amxmodx>
#include <superheromod>
#include <fakemeta>
new gSplask[]="Splask" //creates a string varr to hold your hearo's name
new bool:gHasGun[SH_MAXSLOTS+1] //creates a varr with an aray, with 1 slot per player
new g_p_model; //must be outside plugin_init so it can be global
new g_v_model;
public plugin_init()
{
register_plugin("SUPERHERO Splask", "1.0", "Rolnaaba"); //register plugin (you should know what this is)
register_cvar("Splask_level", "1"); //level required to select hero
shCreateHero(gSplask, "New Super Kool Gun! With More Damage.", "New Super Kool Gun! With More Damage.", false, "Splask_level");
//superheromod.inc:
//stock shCreateHero(Splask[], heroPower[], heroHelp[], bool:requiresKeyEvents, heroLevel[])
register_srvcmd("Splask_init", "Splask_init"); //register your hero's init function with server
shRegHeroInit(gSplask, "Splask_init"); //register your hero's init with superheromod
register_event("Damage", "Event_damage","b");
register_cvar("Supher_mult", "1.5"); //how much damage to do (1.5 x normal_damage)
register_event("ResetHUD", "newSpawn", "b")
}
public plugin_precache()
{
g_p_model = precache_model("models/shmod/p_splask.mdl"); //makes players download the model
g_v_model = precache_model("models/shmod/v_splask.mdl");
register_event("CurWeapon", "weaponChange", "be", "1=1")
}
public Splask_init()
{
new temp[6]; //declare a temperary varriable
read_argv(1,temp,5); //reading the first argument will give you the id of the person who selected your hero
new id = str_to_num(temp); //transfer the string returned into a number and store it as the id
read_argv(2,temp,5); //second argument is whether they have the power or not
new hasPowers = str_to_num(temp);
gHasGun[id] = (hasPowers != 0); //(hasPowers != 0) will either return 1 (if it is true that hasPowers != 0), or 0 (if it is false that hasPowers != 0)
if(hasPowers) { //if they have power
Splask_set_model(id) //go to set model funciton
}
}
public weaponChange(id)
{
if ( !gHasGun[id] || !shModActive() ) return
new wpnid = read_data(2)
new clip = read_data(3)
if ( wpnid != CSW_GALIL ) return
Splask_set_model(id)
// Never Run Out of Ammo!
if ( clip == 0 ) {
shReloadAmmo(id)
}
}
public newSpawn(id)
{
if ( gHasGun[id] && is_user_alive(id) && shModActive() ) {
set_task(0.1, "giveweapon", 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 giveweapon(id)
{
if ( is_user_alive(id) && shModActive() ) {
shGiveWeapon(id, "weapon_galil")
}
}
//-----
public Splask_set_model(id)
{
if (!shModActive() || !is_user_alive(id) || !gHasGun[id]) return;
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo);
if(wpnid == CSW_GALIL) {
set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model));//view model
set_pev(id, pev_weaponmodel, engfunc(EngFunc_AllocString, g_p_model));//player model
}
}
public Event_damage(id) {
if (!shModActive() || !is_user_alive(id)) return PLUGIN_CONTINUE;
new damage = read_data(2); //this is covered in my events tut. (in helpful links)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart) //store what weapon used, bodypart hit, and attacker
new headshot = bodypart == 1 ? 1 : 0 //this is just short for:
if(attacker <= 0 || attacker > SH_MAXSLOTS ) return PLUGIN_CONTINUE; //checks ifs it was world that did the damage, and if so just end function.
if(gHasGun[attacker] && is_user_alive(id)) { //if alive and have power
new extraDamage = floatround(damage * get_cvar_float("Splask_mult") - damage); //calculate extra damage ([damage done x multiplier] - damage done = extra damage)
if (extraDamage > 0) {
shExtraDamage( id, attacker, extraDamage, "Splask damage Mult", headshot ); //superheromod.inc: stock shExtraDamage(id, attacker, damage, weaponDescription[], headshot = 0);
}
}
return PLUGIN_HANDLED;
}
|
|
|