AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=43)
-   -   HELP: Stealth Assassin (https://forums.alliedmods.net/showthread.php?t=34819)

Fabolous1 10-13-2005 12:55

HELP: Stealth Assassin
 
Code:

/* CVARS - Copy and paste into shconfig.cfg

//Stealth Assassin
sassassin_level 10                        //Default 10
sassassin_getusp 1                        //Default 1 - Spawn with USP
sassassin_armor 250                        //Default 250
sassassin_gravity 0.50                        //Default 0.50
sassassin_speed 100                        //Default 100 (Slower then normal)
sassassin_knifemult 2.0                        //Default 2.0
sassassin_uspmult 2.5                        //Default 2.5

*/

#include <amxmod>
#include <amxmisc>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Stealth Assassin"
new bool:g_HasSassassinPower[SH_MAXSLOTS+1]
new g_Alpha


//-----------------------------------------------------------------
public plugin_init()
{
        // Plugin Info
        register_plugin("SUPERHERO Stealth Assassin", "1.0", "Fabolous1")

        // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
        register_cvar("sassassin_level", "10")
        register_cvar("sassassin_getusp", "1")
        register_cvar("sassassin_armor", "250")
        register_cvar("sassassin_gravity", "0.50")
        register_cvar("sassassin_speed", "100")
        register_cvar("sassassin_knifemult", "2")
        register_cvar("sassassin_uspmult", "2")

        // FIRE THE EVENT TO CREATE THIS SUPERHERO!
        shCreateHero(gHeroName, "Made by: Fabolous1", "Strong USP, Knife and More", false, "sassassin_level")

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

        // EVENTS
        register_event("Damage", "sassassin_damage", "b", "2!0")
        register_event("ResetHUD", "newRound", "b")
        register_event("DeathMsg", "sassassin_death", "a")

        // Let Server know about stealthassassin's Variables
        shSetMinGravity(gHeroName, "sassassin_gravity")
        shSetMaxArmor(gHeroName, "sassassin_armor")
        shSetMaxSpeed(gHeroName, "sassassin_speed", "[0]")

}
public sassassin_init()
{
        new temp[128]
        // First Argument is an id
        read_argv(1,temp,5)
        new id=str_to_num(temp)

        // 2nd Argument is 0 or 1 depending on whether the id has stealthassassin
        read_argv(2,temp,5)
        new hasPowers=str_to_num(temp)
        g_HasSassassinPower[id]=(hasPowers!=0)

        // Got to remove the powers if he is not stealthassassin
        if ( !hasPowers )
        uninvis(id)

        //Give Powers to the stealthassassin
        if ( hasPowers )
        {
                stillInvis(id)
        }
}
public newRound(id)
{
        if ( is_user_alive(id) && g_HasSassassinPower[id]) {
                stillInvis(id)
        }
}
//----------------------------------------------------------------------------------------------
public sassassin_giveweapons(id)
{
        if ( is_user_alive(id) ) {
                shGiveWeapon(id,"weapon_usp")
        }
}
//----------------------------------------------------------------------------------------------
public sassassin_damage(id)
{
        if (!shModActive() ) return PLUGIN_CONTINUE
        new damage = read_data(2)
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)

        if ( attacker <=0 || attacker>SH_MAXSLOTS ) return PLUGIN_CONTINUE

        if ( g_HasSassassinPower[attacker] && weapon == CSW_KNIFE && is_user_alive(id) )
        {
                // do extra damage
                new extraDamage = floatround(damage * get_cvar_float("sassassin_knifemult") - damage)
                shExtraDamage( id, attacker, extraDamage, "Super Knife" )
        }
        if ( g_HasSassassinPower[attacker] && weapon == CSW_USP && is_user_alive(id) )
        {
                // do extra damage
                new extraDamage = floatround(damage * get_cvar_float("sassassin_uspmult") - damage)
                shExtraDamage(id, attacker, extraDamage, "usp")
        }
        return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public stillInvis(id) {
        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,20)
}

public moveInvis(id) {
        new g_Alpha = get_cvar_num("sassassin_alpha")

        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,g_Alpha)
}

public uninvis(id) {
        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,g_Alpha)
}
//----------------------------------------------------------------------------------------------
public sassassin_loop() {
        for ( new id=1; id<=SH_MAXSLOTS; id++ ) {
                if (g_HasSAssassinPower[id] && is_user_alive(id)) {
                        new message[128]
                        format(message,127,"Invisibility: %invis", g_Alpha)
                        set_hudmessage(0,0,255,-1.0,1.0,0,1.0,1.0,0.0,0.0,4)
                        show_hudmessage(id,message)
                }
        }
}
//----------------------------------------------------------------------------------------------

Hey everyone, I know this seems like a rip atm but I plan to add more different features once I get this part of the hero working, this is my first hero ever so I consider it training for me, please.

I'm having problems with:
1. Wanting it to say "Invisibility: [percent]" At the bottom of the screen in gameplay
2. Spawning with a USP
3. For some reason it's a +power, I don't want it to be.
4. Also if I compile it myself for amx, I get errors

Thank you, Fab

Mega 10-13-2005 14:28

Change this
Code:

  // FIRE THE EVENT TO CREATE THIS SUPERHERO!
  shCreateHero(gHeroName, "Strong USP & Knife", "Protective Stealth Armor, Cloak of Levitation.", true, "sassassin_level")

To This
Code:

  // FIRE THE EVENT TO CREATE THIS SUPERHERO!
  shCreateHero(gHeroName, "Strong USP & Knife", "Protective Stealth Armor, Cloak of Levitation.", false, "sassassin_level")


Fabolous1 10-13-2005 15:37

Okay thanks, how do I make it so I get silent footsteps, and so it will show my Invisibility percent at bottom of screen

Fabolous1 10-14-2005 22:12

Now I'm working with that updated code, but I have to add silent footsteps, get invisibility working, and showing invisibility percent at bottom of screen. Can someone please help me out here, this is my first hero heh

craze 10-14-2005 22:23

for silent footsteps, try this...

Change this
Code:

public sassassin_init()
{
  new temp[128]
  // First Argument is an id
  read_argv(1,temp,5)
  new id=str_to_num(temp)

  // 2nd Argument is 0 or 1 depending on whether the id has stealthassassin
  read_argv(2,temp,5)
  new hasPowers=str_to_num(temp)
  g_HasSassassinPower[id]=(hasPowers!=0)

  // Got to remove the powers if he is not stealthassassin
  if ( !hasPowers )
  uninvis(id)

  //Give Powers to the stealthassassin
  if ( hasPowers )
  {
      stillInvis(id)
  }
}
public newRound(id)
{
  if ( is_user_alive(id) && g_HasSassassinPower[id]) {
      stillInvis(id)
  }
}
//----------------------------------------------------------------------------------------------

to this:

Code:

public sassassin_init()
{
  new temp[128]
  // First Argument is an id
  read_argv(1,temp,5)
  new id=str_to_num(temp)

  // 2nd Argument is 0 or 1 depending on whether the id has stealthassassin
  read_argv(2,temp,5)
  new hasPowers=str_to_num(temp)
  g_HasSassassinPower[id]=(hasPowers!=0)

  // Got to remove the powers if he is not stealthassassin
  if ( !hasPowers ){
  uninvis(id)
  set_user_footsteps(id,0)
  }

  //Give Powers to the stealthassassin
  if ( hasPowers )
  {
      stillInvis(id)
      set_user_footsteps(id,1)
  }
}
public newRound(id)
{
  if ( is_user_alive(id) && g_HasSassassinPower[id]) {
      stillInvis(id)
      set_user_footsteps(id,1)
  }
}
//----------------------------------------------------------------------------------------------

I just added in some lines from windwalkers code. The line is:
Code:

set_user_footsteps(id,0)
. I'm not sure if it will work, but it's worth a shot. good luck! :)

Fabolous1 10-14-2005 23:23

Okay, I'm using ::

Code:

/* CVARS - Copy and paste into shconfig.cfg

//Stealth Assassin
sassassin_level 10                        //Default 10
sassassin_getusp 1                        //Default 1 - Spawn with USP
sassassin_armor 250                        //Default 250
sassassin_gravity 0.50                        //Default 0.50
sassassin_speed 100                        //Default 100 (Slower then normal)
sassassin_knifemult 2.0                        //Default 2.0
sassassin_uspmult 2.0                        //Default 2.0

*/

#include <amxmod>
#include <amxmisc>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Stealth Assassin"
new bool:g_HasSassassinPower[SH_MAXSLOTS+1]
new g_Alpha


//-----------------------------------------------------------------
public plugin_init()
{
        // Plugin Info
        register_plugin("SUPERHERO Stealth Assassin", "1.0", "Fabolous1")

        // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
        register_cvar("sassassin_level", "10")
        register_cvar("sassassin_getusp", "1")
        register_cvar("sassassin_armor", "250")
        register_cvar("sassassin_gravity", "0.50")
        register_cvar("sassassin_speed", "100")
        register_cvar("sassassin_knifemult", "2")
        register_cvar("sassassin_uspmult", "2")

        // FIRE THE EVENT TO CREATE THIS SUPERHERO!
        shCreateHero(gHeroName, "Made by: Fabolous1", "Strong USP, Knife and More", false, "sassassin_level")

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

        // EVENTS
        register_event("Damage", "sassassin_damage", "b", "2!0")
        register_event("ResetHUD", "newRound", "b")
        register_event("DeathMsg", "sassassin_death", "a")

        // Let Server know about stealthassassin's Variables
        shSetMinGravity(gHeroName, "sassassin_gravity")
        shSetMaxArmor(gHeroName, "sassassin_armor")
        shSetMaxSpeed(gHeroName, "sassassin_speed", "[0]")

}
//----------------------------------------------------------------------------------------------
public sassassin_init()
{
  new temp[128]
  // First Argument is an id
  read_argv(1,temp,5)
  new id=str_to_num(temp)

  // 2nd Argument is 0 or 1 depending on whether the id has stealthassassin
  read_argv(2,temp,5)
  new hasPowers=str_to_num(temp)
  g_HasSassassinPower[id]=(hasPowers!=0)

  // Got to remove the powers if he is not stealthassassin
  if ( !hasPowers ){
  uninvis(id)
  set_user_footsteps(id,0)
  }

  //Give Powers to the stealthassassin
  if ( hasPowers )
  {
      stillInvis(id)
      set_user_footsteps(id,1)
  }
}
public newRound(id)
{
  if ( is_user_alive(id) && g_HasSassassinPower[id]) {
      stillInvis(id)
      set_user_footsteps(id,1)
  }
}
//----------------------------------------------------------------------------------------------
public sassassin_giveweapons(id)
{
        if ( is_user_alive(id) ) {
                shGiveWeapon(id,"weapon_usp")
        }
}
//----------------------------------------------------------------------------------------------
public sassassin_damage(id)
{
        if (!shModActive() ) return PLUGIN_CONTINUE
        new damage = read_data(2)
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)

        if ( attacker <=0 || attacker>SH_MAXSLOTS ) return PLUGIN_CONTINUE

        if ( g_HasSassassinPower[attacker] && weapon == CSW_KNIFE && is_user_alive(id) )
        {
                // do extra damage
                new extraDamage = floatround(damage * get_cvar_float("sassassin_knifemult") - damage)
                shExtraDamage( id, attacker, extraDamage, "Super Knife" )
        }
        if ( g_HasSassassinPower[attacker] && weapon == CSW_USP && is_user_alive(id) )
        {
                // do extra damage
                new extraDamage = floatround(damage * get_cvar_float("sassassin_uspmult") - damage)
                shExtraDamage(id, attacker, extraDamage, "usp")
        }
        return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public stillInvis(id) {
        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,20)
}

public moveInvis(id) {
        new g_Alpha = get_cvar_num("sassassin_alpha")

        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,g_Alpha)
}

public uninvis(id) {
        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,g_Alpha)
}
//----------------------------------------------------------------------------------------------
public sassassin_loop() {
        for ( new id=1; id<=SH_MAXSLOTS; id++ ) {
                if (g_HasSAssassinPower[id] && is_user_alive(id)) {
                        new message[128]
                        format(message,127,"Invisibility: %invis", g_Alpha)
                        set_hudmessage(0,0,255,-1.0,1.0,0,1.0,1.0,0.0,0.0,4)
                        show_hudmessage(id,message)
                }
        }
}
//----------------------------------------------------------------------------------------------

And I'm Getting These Errors

Code:

sh_sassassin.sma(74) : error 017: undefined symbol "set_user_footsteps"
sh_sassassin.sma(81) : error 017: undefined symbol "set_user_footsteps"
sh_sassassin.sma(88) : error 017: undefined symbol "set_user_footsteps"
sh_sassassin.sma(127) : warning 219: local variable "g_Alpha" shadows a variable at a preceding level
sh_sassassin.sma(138) : error 017: undefined symbol "g_HasSAssassinPower"
sh_sassassin.sma(138) : warning 215: expression has no effect
sh_sassassin.sma(138) : error 001: expected token: ";", but found "]"
sh_sassassin.sma(138) : error 029: invalid expression, assumed zero
sh_sassassin.sma(138) : fatal error 107: too many error messages on one line

Compilation aborted.Small compiler 2.6.0                Copyright (c) 1997-2004, ITB CompuPhase


7 Errors.


jtp10181 10-14-2005 23:30

code for amxx and it would work a lot better since set_user_footsteps is not available in AMX 0.9.9

v_one 10-15-2005 00:20

or try adding a PreThink function.
Code:
//------------------------------------------------------------------------- public client_prethink(id) {     if(gHasWindWalker[id]) {         Entvars_Set_Int(id, EV_INT_flTimeStepSound, 999)     } } #else     if ( !hasPowers && is_user_connected(id) ) {         set_user_footsteps(id,0)     }     if ( hasPowers && is_user_connected(id) ) {         set_user_footsteps(id,1)     } } //-------------------------------------------------------------------------

And define
Code:
#if defined AMX_NEW     #include <Vexd_Utilities> #endif #if defined AMX98     #include <xtrafun> #endif
for your includes.

Fabolous1 10-15-2005 16:01

Weeee, I finally converted my server to AMXX


All times are GMT -4. The time now is 13:34.

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