Raised This Month: $51 Target: $400
 12% 

Need nelp with new hero


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tmp
Junior Member
Join Date: Jan 2012
Old 01-08-2012 , 15:08   Need nelp with new hero
Reply With Quote #1

Hello all,

I am new to pawn coding, and actually not going to become a pro, but just want to make a simple (?) hero for my favorite server.

Hero should:

- give a TMP weapon at spawn
- make more damage
- have unlimited ammo (no need to reload)
- have silent steps (no footstep and fall sound)

So i have read SH making tutorial, PAWN tutorial, dozen of various source codes, and wrote the following:

PHP Code:

/* CVARS - copy and paste to shconfig.cfg

silencer_level 16
silencer_tmpmult 2.5

*/

#include <amxmod>
#include <superheromod>

//global vars
new gHeroName[]="Silencer"
new bool:gHasSilencerPower[SH_MAXSLOTS+1]
//----------------------------------

public plugin_init() 
{
    
register_plugin("silencer""1.0""silencer")
    
    
    
register_cvar("silencer_level""16")
    
register_cvar("silencer_tmpmult""2.5")
    
    
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
    
shCreateHero(gHeroName"Silent death""Get free TMP with xTra DMG & unlimited ammo"false"silencer_level")
    
    
// INIT EVENTS
    
register_srvcmd("silencer_init""silencer_init")
    
shRegHeroInit(gHeroName"silencer_init"
    
    
    
//EVENTS
    //damage event
    
register_event("Damage""silencer_damage","b""2!0"
    
register_event("ResetHUD""new_Spawn""b"
    
register_event("CurWeapon""weapon_Change","be","1=1")
    
register_forward(FM_PlayerPreThink"ninja_walk")
}

public 
silencer_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)
    if ( 
is_user_alive(id) ) {
        if ( 
hasPowers ) {
            
silencer_weapons(id)
        }
    }
    
gHasSilencerPower[id] = (hasPowers != 0)
}

//action for new spawn
public newSpawn(id)
{
    if ( 
shModActive() && gHasSilencerPower[id] && is_user_alive(id) ) {
        
set_task(0.1"silencer_weapons"id)
    }
}

//give weapons

public silencer_weapons(id) {
    if( 
is_user_alive(id) ) {
        
shGiveWeapon(id"weapon_tmp")
    }
}

//weapon reload
public weaponChange(id)
{
    if ( !
gHasSilencerPower[id] || !shModActive() ) return

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

    if ( 
wpnid != CSW_TMP ) return

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


//ninja walking
public ninja_walk(id)
{
    if ( 
shModActive() && is_user_alive(id) && gHasSilencerPower[id] ) {
        
set_pev(idpev_flTimeStepSound999)
    }
}




public 
silencer_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 ( 
gHasSilencerPower[attacker] && weapon == CSW_TMP && is_user_alive(id) ) {
        
// do extra damage
        
new extraDamage floatround(damage get_cvar_float("silencer_tmpmult") - damage)
        if (
extraDamage 0shExtraDamageidattackerextraDamage"tmp"headshot)
    }

This has no errors during compile, but it seems the only function that works is increased damage. Others just fail to work.
Code is basically done with copy-paste from other heroes, which are installed and working on our server. so it has to work, but it does not
tmp is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 01-08-2012 , 23:14   Re: Need nelp with new hero
Reply With Quote #2

It looks a bit like you have used a generator for the most part.

Anyway, read this: http://forums.alliedmods.net/showthread.php?t=120051

It should give you a better understanding of how you can code using the new ways. You are using the old way, which is slow and outdated.

Once you have re-written your code, see if it works, if it doesn't post it here and give us the errors.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
tmp
Junior Member
Join Date: Jan 2012
Old 01-09-2012 , 09:47   Re: Need nelp with new hero
Reply With Quote #3

Thanks Jelle, i have read the "new method" and this really simplifies all the stuff

so i've started up with the following:

PHP Code:
/* CVARS - copy and paste to shconfig.cfg

silencer_level 16
silencer_tmpmult 3

*/
#include <amxmod>
#include <superheromod>


new gHeroID
new gHeroName[] = "Silencer"
new bool:gHasSilencerPower[SH_MAXSLOTS+1]
public 
plugin_init()
{
    
register_plugin("SUPERHERO Silencer""1.0""silencer")
    
//CVARS
    
new pcvarLevel register_cvar("silencer_level""16"//hero level
    
new pcvarMult register_cvar("silencer_tmpmult""3"//damage multiplier
    //CREATE HERO
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Silent death""Get free TMP with xTra DMG & run silently")
    
//SET DAMAGE MULTIPLIER
    
sh_set_hero_dmgmult(gHeroIDpcvarMultCSW_TMP)
}

public 
sh_hero_init(idheroIDmode)
{
    if (
gHeroID != heroID) return
    switch(
mode)
    {
        case 
SH_HERO_ADD:
        {
            
gHasSilencerPower[id] = true
        
}
        case 
SH_HERO_DROP:
        {
            
gHasSilencerPower[id] = false
        
}
    }

It seems to compile OK at this point, and we got basic hero with increased damage from TMP.
so how do i give him a weapon, make unlimited ammo and silent steps? where to find those functions?
tmp is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 01-09-2012 , 11:04   Re: Need nelp with new hero
Reply With Quote #4

part 7 in his tut combined giving a weapon, setting unlimited ammo and setting a weapon model so just strip out the model stuff from it to get the other 2 and look at windwalker(can't recall if it was renamed in 1.2.0 series or not) for the silent steps
__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
tmp
Junior Member
Join Date: Jan 2012
Old 01-09-2012 , 11:26   Re: Need nelp with new hero
Reply With Quote #5

Quote:
Originally Posted by G-Dog View Post
part 7 in his tut combined giving a weapon, setting unlimited ammo and setting a weapon model so just strip out the model stuff from it to get the other 2 and look at windwalker(can't recall if it was renamed in 1.2.0 series or not) for the silent steps
Thanks, i didn't noticed that some things in his tutorial are combined.
So, am i on the right way?

PHP Code:
new gHeroID
new gHeroName[] = "Silencer" //creates a string varr to hold the hero name
new bool:gHasSilencerPower[SH_MAXSLOTS+1//creates a varr with an aray, with 1 slot per player

public plugin_init()
{
    
register_plugin("SUPERHERO Silencer""1.0""silencer")
    
//CVARS
    
new pcvarLevel register_cvar("silencer_level""16"//hero level
    
new pcvarMult register_cvar("silencer_tmpmult""3"//damage multiplier
    //CREATE HERO
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Silent death""Get free TMP with xTra DMG & run silently")
    
//SET DAMAGE MULTIPLIER
    
sh_set_hero_dmgmult(gHeroIDpcvarMultCSW_TMP)
    
//REGISTER EVENTS
    
register_event("CurWeapon""weapon_change""be""1=1")
}

public 
sh_hero_init(idheroIDmode)
{
    if (
gHeroID != heroID) return
    switch(
mode)
    {
        case 
SH_HERO_ADD:
        {
            
gHasSilencerPower[id] = true
            silencer_weapon
(id)
        }
        case 
SH_HERO_DROP:
        {
            
gHasSilencerPower[id] = false
            sh_drop_weapon
(idCSW_TMPtrue)
        }
    }


public 
sh_client_spawn(id)
{
    if (
gHasSilencerPower[id])
    {
        
silencer_weapon(id)
    }
}

silencer_weapon(id)
{
    if (
sh_is_active() && is_user_alive(id) && gHasSilencerPower[id] )
    {
        
sh_give_weapon(idCSW_TMP)
    }
}

public 
weapon_change(id)
{
    if ( !
sh_is_active() || !gHasSilencerPower[id] ) return
    new 
weaponID read_data(2)
    if (
weaponID !=CSW_TMP) return
    if (
read_data(3) == 0)
    {
        
sh_reload_ammo(id1)
    }

tmp is offline
tmp
Junior Member
Join Date: Jan 2012
Old 01-09-2012 , 12:37   Re: Need nelp with new hero
Reply With Quote #6

just tested this on server. it FAILS to even appear in hero list
so it seems our server does not support "modern way" of sh coding
any other thoughts what to do?
tmp is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 01-09-2012 , 18:56   Re: Need nelp with new hero
Reply With Quote #7

When you are not adding any include files, you cannot even compile it, however, I assume it is just a mistake that you didn't get the include lines in the code.

Could you provide us with the output of the server console command "amxx plugins"? Then we can quickly find out what you are running.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
tmp
Junior Member
Join Date: Jan 2012
Old 01-10-2012 , 00:23   Re: Need nelp with new hero
Reply With Quote #8

Yes, of course i have included amxmod, superheromod, just as in "old way" from my first post, and it compiles normally. I'm using this web compiler:
http://webcomp.ak-team.com/

"amxx plugins" output is as follows:

Quote:

] amxx plugins
AMX Mod X 1.8.0.3660
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko, Felix "SniperBeamer" Geyer
Jonny "Got His Gun" Bergstrom, Lukasz "SidLuke" Wlasinski
Christian "Basic-Master" Hammacher, Borja "faluco" Ferrer
Scott "Damaged Soul" Ehlert
Compiled: Oct 25 2007, 22:03:28
URL:http://www.amxmodx.org/
Core mode JIT

Last edited by tmp; 01-10-2012 at 00:24.
tmp is offline
tmp
Junior Member
Join Date: Jan 2012
Old 01-10-2012 , 09:26   Re: Need nelp with new hero
Reply With Quote #9

Jelle, you have mentioned a generator, where can i find a working version?
i found some threads about it on this forum, and external link to site which propably contained generator script, but now its dead
tmp is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 01-10-2012 , 10:06   Re: Need nelp with new hero
Reply With Quote #10

Quote:
Originally Posted by tmp View Post
Yes, of course i have included amxmod, superheromod, just as in "old way" from my first post, and it compiles normally. I'm using this web compiler:
http://webcomp.ak-team.com/

"amxx plugins" output is as follows:
It was not that information that I was after. You need to put amxx plugins in the server console itself, or do it using the rcon command. I can't use the information you gave me there.

Quote:
Originally Posted by tmp View Post
Jelle, you have mentioned a generator, where can i find a working version?
i found some threads about it on this forum, and external link to site which propably contained generator script, but now its dead
JT made a generator which used PHP code to generate a superhero. If the link is dead, it means that he has taken it down, he mentioned some time ago that it had about a year left, I assume that year has now passed and the website used to host the php code is now offline.
__________________
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 15:22.


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