AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fast (https://forums.alliedmods.net/showthread.php?t=28103)

PsychoStand 05-07-2006 09:11

Fast
 
i Postet this hero here couse i wanted help fast i wanna add the sound the the scout model that model works and i wanna add deagle model allso to the hero plz help me
Code:

/* CVARS - copy and paste to shconfig.cfg

//Silence
Silence_level 9
Silence_health 200                        //how much health Silence has
Silence_armor 100                        //how much armor Silence has
Silence_scoutmult 2.0                        //Damage multiplyer for his Scout
Silence_deaglemult 2.0                                      //Damage Multiplayer for his deagle
*/

//

#include <amxmod.inc>
#include <Vexd_Utilities>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Silence"
new gHasSilencePower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
        // Plugin Info
        register_plugin("SUPERHERO Silence", "1", "Miles")

        // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
        register_cvar("Silence_level", "9" )
        register_cvar("Silence_health", "200" )
        register_cvar("Silence_armor", "100" )
        register_cvar("Silence_scoutmult", "2.0" )
              register_cvar("Silence_deaglemult","3.0" )
        // FIRE THE EVENT TO CREATE THIS SUPERHERO!
        shCreateHero(gHeroName, "Strong Scout and Deagle", "Ur a Murder With A Scout and Deagle Muhahaah", false, "Silence_level")

        // REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
        // INIT
        register_srvcmd("Silence_init", "Silence_init")
        shRegHeroInit(gHeroName, "Silence_init")

        register_event("ResetHUD", "newSpawn","b")
        register_event("CurWeapon", "weaponChange","be","1=1")
        register_event("Damage", "Silence_damage", "b", "2!0")

        // Let Server know about bow's Variable
        shSetMaxHealth(gHeroName, "Silence_health" )
        shSetMaxArmor(gHeroName, "Silence_armor" )
        shSetShieldRestrict(gHeroName)
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
              precache_model("models/shmod/shmod.mdl")
              precache_sound("misc/scout.wav")
              precache_model("models/deagle/deagle.mdl")
}
//----------------------------------------------------------------------------------------------
public Silence_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 Silence Scout
        read_argv(2,temp,5)
        new hasPowers=str_to_num(temp)

        gHasSilencePower[id] = (hasPowers != 0)

        //Reset thier shield restrict status
        //Shield restrict MUST be before weapons are given out
        shResetShield(id)

        if ( !is_user_alive(id) ) return

        if ( gHasSilencePower[id] ) {
                Silence_weapons(id)
                switchmodel(id)
        }
        else {
                            engclient_cmd(id, "drop", "weapon_deagle")
                engclient_cmd(id, "drop", "weapon_scout")
                shRemHealthPower(id)
                shRemArmorPower(id)
        }
}
//----------------------------------------------------------------------------------------------
public newSpawn(id)
{
        if ( gHasSilencePower[id] && is_user_alive(id) && shModActive() ) {
                set_task(0.1, "Silence_weapons", id)


new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
                if (wpnid != CSW_SCOUT && wpnid > 0) {
                        new wpn[32]
                        get_weaponname(wpnid,wpn,31)
                        engclient_cmd(id,wpn)
                }
        }
}

//----------------------------------------------------------------------------------------------
public Silence_weapons(id)
{
        if ( is_user_alive(id) && shModActive() ) {
                shGiveWeapon(id,"weapon_scout")
                            shGiveWeapon(id,"weapon_deagle")
        }
}
//----------------------------------------------------------------------------------------------
public switchmodel(id)
{
        if ( !is_user_alive(id) || !gHasSilencePower[id] ) return
        new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
        if (wpnid == CSW_DEAGLE) {
                // Weapon Model change thanks to Miles
                Entvars_Set_String(id, EV_SZ_viewmodel, "models/shmod/shmod")
        }
}
//----------------------------------------------------------------------------------------------
public weaponChange(id)
{
        if ( !gHasSilencePower[id] || !shModActive() ) return

        //new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
        new wpnid = read_data(2)
        new clip = read_data(3)
             
              if (wpnid != CSW_DEAGLE )
        if ( wpnid != CSW_SCOUT ) return

        switchmodel(id)

        // Never Run Out of Ammo!
        if ( clip == 0 ) {
                shReloadAmmo(id)
        }
}

//----------------------------------------------------------------------------------------------
public Silence_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 ( gHasSilencePower[attacker] && weapon == CSW_DEAGLE && is_user_alive(id) ) {
                // do extra damage
                new extraDamage = floatround(damage * get_cvar_float("Silence_deaglemult") - damage)
                if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "deagle", headshot )
        }
}
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
public Silence_damage2(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 ( gHasSilencePower[attacker] && weapon == CSW_SCOUT && is_user_alive(id) ) {
                // do extra damage
                new extraDamage = floatround(damage * get_cvar_float("Silence_scoutmult") - damage)
                if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "scout", headshot )
        }
}
//----------------------------------------------------------------------------------------------


SubStream 05-10-2006 08:51

would you mind editing that to use [ small ] instead of [ code ] so that it is easier to read?


All times are GMT -4. The time now is 05:03.

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