Raised This Month: $32 Target: $400
 8% 

How To Make a Gun Hero


Post New Thread Reply   
 
Thread Tools Display Modes
KingJTellem
Member
Join Date: Dec 2011
Old 06-25-2014 , 18:49   Re: How To Make a Gun Hero
Reply With Quote #11

Okay my bad p & v_model still dont shows up.
KingJTellem is offline
KingJTellem
Member
Join Date: Dec 2011
Old 06-25-2014 , 18:54   Re: How To Make a Gun Hero
Reply With Quote #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;
}
KingJTellem is offline
KingJTellem
Member
Join Date: Dec 2011
Old 06-25-2014 , 19:14   Re: How To Make a Gun Hero
Reply With Quote #13

Nope now i dont get the weapon and if i buy it the server crashed.
KingJTellem is offline
anon12
Member
Join Date: Aug 2013
Old 06-25-2014 , 19:16   Re: How To Make a Gun Hero
Reply With Quote #14

mmk ill test it on my server and post the whole code
anon12 is offline
KingJTellem
Member
Join Date: Dec 2011
Old 06-25-2014 , 19:24   Re: How To Make a Gun Hero
Reply With Quote #15

Here you go.
Attached Files
File Type: zip Splask.zip (669.2 KB, 52 views)
KingJTellem is offline
anon12
Member
Join Date: Aug 2013
Old 06-25-2014 , 19:26   Re: How To Make a Gun Hero
Reply With Quote #16

Try this 1
PHP Code:
#include <amxmod>
#include <Vexd_Utilities>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Splask"
new gHassplaskPower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// Plugin Info
    
register_cvar("splask_level""10")
    
register_cvar("splask_ak47mult""1.5")
    
shCreateHero(gHeroName"New Super Kool Gun! With More Damage""New Super Kool Gun! With More Damage"false"splask_level")
    
register_srvcmd("splask_init""splask_init")
    
shRegHeroInit(gHeroName"splask_init")
    
register_event("ResetHUD""newSpawn""b")
    
register_event("Damage""splask_damage""b")
    
register_event("CurWeapon""weaponChange""be""1=1")
    
shSetShieldRestrict(gHeroName)
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
    
precache_model("models/shmod/v_splask.mdl")
    
precache_model("models/shmod/p_splask.mdl")
}
//----------------------------------------------------------------------------------------------
public splask_init()
{
    new 
temp[6]
    
read_argv(1,temp,5)
    new 
id str_to_num(temp)

    
read_argv(2,temp,5)
    new 
hasPowers str_to_num(temp)

    
gHassplaskPower[id] = (hasPowers != 0)

    
shResetShield(id)

    if ( !
is_user_alive(id) ) return

    if ( 
gHassplaskPower[id] ) {
        
splask_weapons(id)
        
switchmodel(id)
    }
    else {
        
engclient_cmd(id"drop""weapon_ak47")
    }
}
//-----------------------------------------------------------------------------------------------
public splask_weapons(id)
{
    if ( 
is_user_alive(id) && shModActive() ) {
        
shGiveWeapon(id"weapon_ak47")
    }
}
//-----------------------------------------------------------------------------------------------
public newSpawn(id)
{
    if ( 
gHassplaskPower[id] && is_user_alive(id) && shModActive() ) {
        
set_task(0.1"splask_weapons"id)

        new 
clipammowpnid get_user_weapon(idclipammo)
        if ( 
wpnid != CSW_AK47 && wpnid ) {
            new 
wpn[32]
            
get_weaponname(wpnidwpn31)
            
engclient_cmd(idwpn)
        }
    }
}
//-----------------------------------------------------------------------------------------------
public switchmodel(id)
{
    if ( !
is_user_alive(id) || !gHassplaskPower[id] ) return

    new 
clipammowpnid get_user_weapon(idclipammo)
    if ( 
wpnid == CSW_AK47 ) {
        
set_pev(idpev_viewmodel2"models/shmod/v_splask.mdl")
        
set_pev(idpev_weaponmodel2"models/shmod/p_splask.mdl")
    }
}
//----------------------------------------------------------------------------------------------
public weaponChange(id)
{
    if ( !
gHassplaskPower[id] || !shModActive() ) return

    new 
wpnid read_data(2)
    new 
clip read_data(3)

    if ( 
wpnid != CSW_AK47 ) return

    
switchmodel(id)

    if ( 
clip == ) {
        
shReloadAmmo(id)
    }
}
//-----------------------------------------------------------------------------------------------
public splask_damage(id)
{
    if ( !
shModActive() || !is_user_alive(id) ) return

    new 
damage read_data(2)
    new 
weaponbodypartattacker get_user_attacker(idweaponbodypart)
    new 
headshot bodypart == 0

    
if ( attacker <= || attacker SH_MAXSLOTS ) return

    if ( 
gHassplaskPower[attacker] && weapon == CSW_AK47 && is_user_alive(id) ) {
        new 
extraDamage floatround(damage get_cvar_float("splask_ak47mult") - damage)
        if (
extraDamage 0shExtraDamage(idattackerextraDamage"ak47"headshot)
    }
}
//----------------------------------------------------------------------------------------------- 
anon12 is offline
KingJTellem
Member
Join Date: Dec 2011
Old 06-25-2014 , 19:44   Re: How To Make a Gun Hero
Reply With Quote #17

Thanks alot you saved my day. Now its works perfectly.
Attached Files
File Type: zip Splask.zip (677.8 KB, 60 views)
KingJTellem is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 06-27-2014 , 04:37   Re: How To Make a Gun Hero
Reply With Quote #18

Anon12 you should read my guide with the new ways. What you did here is hopelessly inefficient.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode