Member
|
06-25-2014
, 18:18
Re: How To Make a Gun Hero
|
#6
|
Something like this:
PHP Code:
#include <amxmodx>
#include <superheromod>
#include <fakemeta>
new gHeroName[]="Hero Name" //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 Super", "1.0", "Rolnaaba"); //register plugin (you should know what this is)
register_cvar("Super_level", "1"); //level required to select hero
shCreateHero(gHeroName, "Gun Hero desc1", "Gun Hero Desc2", false, "Super_level");
//superheromod.inc:
//stock shCreateHero(heroName[], heroPower[], heroHelp[], bool:requiresKeyEvents, heroLevel[])
register_srvcmd("Super_init", "Super_init"); //register your hero's init function with server
shRegHeroInit(gHeroName, "Super_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/Super/p_weapon_model.mdl"); //makes players download the model
g_v_model = precache_model("models/shmod/Super/v_weapon_model.mdl");
}
public Super_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
Super_set_model(id) //go to set model funciton
}
}
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_AK47 && 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_ak47")
}
}
//-----
public Super_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_AK47) {
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("Super_mult") - damage); //calculate extra damage ([damage done x multiplier] - damage done = extra damage)
if (extraDamage > 0) {
shExtraDamage( id, attacker, extraDamage, "Super damage Mult", headshot ); //superheromod.inc: stock shExtraDamage(id, attacker, damage, weaponDescription[], headshot = 0);
}
}
return PLUGIN_HANDLED;
}
I believe this is called every round so it will give the user the weapon
PHP Code:
register_event("ResetHUD", "newSpawn", "b")
PHP Code:
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_AK47 && 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_ak47")
}
}
Last edited by anon12; 06-25-2014 at 18:20.
|
|