Raised This Month: $ Target: $400
 0% 

Advanced Superhero 1.2.0.1.4 Scripting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-26-2011 , 17:47   Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #1

Could anybody be nice to make a tutorial for
Advanced Superhero 1.2.0.1.4 Scripting.
And if possible make it look like Jelle's Tutorial


Codes for:
Lasers
Invisibility
No Clip
Creating Hooks
Respawning Upon Death
Exploding Bullets


[Tutorial] Learn The New Ways

PLEASE NO USELESS REPLY'S!
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-26-2011 , 18:06   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #2

PHP Code:
//first create a new variable to hold each players cooldown status
new bool:gCooldown[SH_MAXSLOTS+1]

//remember to register key with shmod in plugin_init()
public sh_hero_key(idheroIDkey)
{
    
//Not going to bother with this
    
if ( gHeroID != heroID ) return
    
    
//if the key pressed is keydown (keyup can also be registered)
    
if ( key == SH_KEYDOWN )
    {
        
//if player is not in cooldown
        
if ( !gCooldown[id] )
        {
            
//set noclip
            
set_user_noclip(id1)
            
//set the cooldown variable to true to make sure this wont be executed more than once at a time
            
gCooldown[id] = true
            
//now we set a task (here 5 sec) to when we want noclip removed
            
set_task(5.0"remove_noclip"id)
        }
    }
}

//forward for the task
public remove_noclip(id)
{
    
//let user know that noclip has been removed
    
client_print(idprint_chat"[SH] Noclip removed")
    
    
//set cooldown variable to false so user can use noclip again
    
gCooldown[id] = false
    
    
//take away noclip
    
set_user_noclip(id0)

Now I tell you that invisibility is almost the same, you just need to use another native instead of set_user_noclip. That native is sh_set_user_rendering. You can also use set_user_rendering: http://www.amxmodx.org/funcwiki.php?...ring&go=search
Notice that if you use set_user_rendering you need to include fun (not sure if it is included in shmod include)

Now, next time you want to do something like this, you do it this way, and just search for the appropriate native. If you want a laser that is done the same way too, and to find out how to draw a laser you use the hero bass to see how it works. I believe it uses write_byte functions with a few sprites.
Next you do the damage with sh_extra_damage.

Respawn upon death? Well, we take a look at chucky:

We see that this is happening when a user dies:

PHP Code:
public chucky_death()
{
    new 
id read_data(2)

    if ( !
shModActive() || BetweenRounds || !is_user_connected(id) || !HasChucky[id] )
        return

    
// What is the users team when he dies?
    
UserTeam[id] = cs_get_user_team(id)

    
// Look for self to raise from dead
    
if ( !is_user_alive(id) && !ChuckyPowerUsed[id] )
    {
        
// Chucky will raise self from dead
        
new parm[1]
        
parm[0] = id
        
// Respawn him faster then Zues, let this power be used before Zues's
        // never set higher then 1.9 or lower then 0.5
        
set_task(0.5"chucky_respawn"0parm1)
    }

Okay, so what we see is that on certain conditions (user has hero and sh is running etc.) we are sent to another forward called chucky_respawn. The comment says that you should NEVER set task lower than 0.5, so never do that, there is multiple reasons for that.

Next up the respawn forward:

PHP Code:
public chucky_respawn(parm[])
{
    new 
id parm[0]

    if ( !
shModActive() || !is_user_connected(id) || is_user_alive(id) ) return
    if ( 
ChuckyPowerUsed[id] || BetweenRounds ) return

    
// Check prevents respawning spectators, cs_get_user_team prevents team change respawning
    
if ( UserTeam[id] != cs_get_user_team(id) ) return

    
// Prevent respawn if Pod-Bot kills all bots when no players are alive and bomb has not been planted
    
if ( get_cvar_num("pb_autokill") && !BombPlanted )
    {
        new 
players[SH_MAXSLOTS], pnum

        
// Check for any alive non-bots 
        
get_players(playerspnum"ac")

        
// if no alive non-bots do not respawn
        
if ( !pnum )
            return
    }

    
emit_sound(idCHAN_STATIC"ambience/port_suckin1.wav"1.0ATTN_NORM0PITCH_NORM)

    
client_print(idprint_chat"[SH](%s) You used %s's Voodoo power to come back to life!"HeroNameHeroName)

    
// Double spawn prevents the no HUD glitch
    // This should eventually be changed to use a better method
    
spawn(id)
    
spawn(id)

    
// Respawned by Chucky, it's ok to set cooldown now.
    
new Float:chuckyCooldown get_pcvar_float(CvarCooldown)
    if ( 
chuckyCooldown 0.0 )
    {
        
set_task(chuckyCooldown"enable_chucky"id)
        
ChuckyPowerUsed[id] = true
    
}

    
emit_sound(idCHAN_STATIC"nihilanth/nil_comes.wav"1.0ATTN_NORM0PITCH_NORM)

    
shGlow(id7575255)
    
set_task(3.0"chucky_unglow"0parm1)
    
set_task(1.0"chucky_teamcheck"0parm1)

First we see some conditions if the user has the hero etc.
A prevention regarding bots has also been added (see comments)
Next an emitted sound, we don't need that.
next a notice to the user, we dont need that either.
oh, now something interesting came up. If we read the comments we see that we should spawn the guy twice to avoid the ghost bug, so we do that in the task forward we did earlier using the other code from chucky.
Next we see some cooldown stuff as to when you can be respawned once again, we might want to do that as well. We see that a new float is getting fetched from the cvar for it, then checked if it is more than 0.0, if it is, then set a task as to when to enable the respawn once again using that fetched cvar.
Last we see an emitted sound once again, we don't really need that for a simple respawn.
Then as the very last we see a native regarding a glow, we have never set a glow, we don't need that. There is also a few tasks, we didn't use that either, fuck that.

Then your done!

Now, please, for the love of god, look at other heroes before asking.
__________________
No idea what to write here...

Last edited by Jelle; 05-26-2011 at 18:18.
Jelle is offline
Send a message via MSN to Jelle
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-27-2011 , 01:57   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #3

Thanks Jelle, but i also needed. The codes for exploding bullets ;)

Last edited by MuzzMikkel; 05-27-2011 at 02:13.
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-27-2011 , 02:31   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #4

Look at dark predator, now you have the basic knowledge of how to use code from another hero.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Exploited
Veteran Member
Join Date: Jul 2010
Location: Sweden
Old 05-27-2011 , 02:38   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #5

I would use SH_DMG_KILL.
Also, why didn't you use HAM for the respawn?

ExecuteHamB(Ham_CS_RoundRespawn, id)
__________________
Jelle (1): I LOVE YOU
Jelle (1): Yeah. omg you are so awesome!
--------------
Jelle (1): You know when a poo is about to exit but it is too big?
Jelle (1): God my ass still hurts
Exploited is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 05-27-2011 , 03:11   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #6

Quote:
Originally Posted by Exploited View Post
I would use SH_DMG_KILL.
Also, why didn't you use HAM for the respawn?

ExecuteHamB(Ham_CS_RoundRespawn, id)
Because he haz copy paste.




Look at this then... Its no near perfect but atleast I do some explaining in there... And no I wont explain exploding bullets its just plain retardness using that stuff in a server.


http://forums.alliedmods.net/showpos...66&postcount=5
__________________
The Art of War is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-27-2011 , 03:32   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #7

Quote:
Originally Posted by Exploited View Post
I would use SH_DMG_KILL.
Also, why didn't you use HAM for the respawn?

ExecuteHamB(Ham_CS_RoundRespawn, id)
Because I am showing him how to use an older hero to code a new one. Older heroes does not use ham, nor is it no way near just as uptimized, but it gets the job done, and if you just want it done without posting it, whats the point in using hours making it it efficient then?
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-27-2011 , 04:05   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #8

Quote:
Originally Posted by The Art of War View Post
Because he haz copy paste.




Look at this then... Its no near perfect but atleast I do some explaining in there... And no I wont explain exploding bullets its just plain retardness using that stuff in a server.


http://forums.alliedmods.net/showpos...66&postcount=5
It worked, but i wanted another color of the beam ;)

I think it has something to do with this code. How do i change the color?

PHP Code:
// Beam effect between two points
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_BEAMPOINTS)    // 0
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(aimvec[0])
    
write_coord(aimvec[1])
    
write_coord(aimvec[2])
    
write_short(Beam)
    
write_byte(1)        // framestart
    
write_byte(5)        // framerate
    
write_byte(2)        // life
    
write_byte(40)        // width
    
write_byte(0)        // noise
    
write_byte(255)        // r, g, b
    
write_byte(255)        // r, g, b
    
write_byte(0)        // r, g, b
    
write_byte(200)        // brightness
    
write_byte(200)        // speed
    
message_end() 
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
Exploited
Veteran Member
Join Date: Jul 2010
Location: Sweden
Old 05-27-2011 , 05:00   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #9

You change the RGB values. Where it says "// r, g, b" after the write byte, change the values.

The first one is red, second one is green and the third one is blue.
Here is a chart showing you what combination makes what color, but it isn't spot on in game.

http://www.tayloredmktg.com/rgb/
__________________
Jelle (1): I LOVE YOU
Jelle (1): Yeah. omg you are so awesome!
--------------
Jelle (1): You know when a poo is about to exit but it is too big?
Jelle (1): God my ass still hurts
Exploited is offline
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-27-2011 , 07:28   Re: Advanced Superhero 1.2.0.1.4 Scripting
Reply With Quote #10

Quote:
Originally Posted by Exploited View Post
You change the RGB values. Where it says "// r, g, b" after the write byte, change the values.

The first one is red, second one is green and the third one is blue.
Here is a chart showing you what combination makes what color, but it isn't spot on in game.

http://www.tayloredmktg.com/rgb/
Thank you. It worked fine

-------------------------------------------------------------------------------------------------

I would like to get burn decals & multishot in my code.
If anybody would help me?


Here's my code ;)

PHP Code:
#include <superheromod> 

new gHeroID 
new gHeroName[] = "Beam Test" 
new bool:gHasBeam[SH_MAXSLOTS+1]
new 
gLaserSound[] = "weapons/electro5.wav" 

new Beam 

new pCvarDmgpCvarCool 


public plugin_init() 

    
register_plugin("SUPERHERO Beam Test""0.1""MuzzMikkel"
    
    
    new 
pCvarLevel register_cvar("Beam_Test_level""1"
    
    
pCvarCool register_cvar("Beam_Test_cooldown""20.0"
    
    
pCvarDmg register_cvar("Beam_Test_dmg""100"
    
    
gHeroID sh_create_hero(gHeroNamepCvarLevel)  
    
sh_set_hero_info(gHeroID"Beam Test""Press the +power key to fire a beam!"
    
sh_set_hero_bind(gHeroID)  


public 
plugin_precache()  
{  
    
Beam precache_model("sprites/shmod/beam.spr"
    
precache_sound(gLaserSound)
}   

public 
sh_hero_init(idheroidmode)
{
    if ( 
heroid == gHeroID 
    {
        
gHasBeam[id] = mode true false
    
}
    if ( 
mode == SH_HERO_ADD ) {
        
gPlayerInCooldown[id] = false
    
}
}
    
public 
sh_hero_key(idheroIDkey)  
{  
    
    if (
gHeroID != heroID || !gHasBeam[id] || gPlayerInCooldown[id] || !is_user_alive(id)) return  
    
    if (
key == SH_KEYDOWN)
    {
       
emit_sound(idCHAN_STATICgLaserSound1.0ATTN_NORM0PITCH_NORM)
      
      if ( 
gPlayerInCooldown[id] )
        {
            
sh_sound_deny(id)
            return
        }
        
fire_attack(id)  
    }  
}   

public 
sh_client_spawn(id)   
{   
    if (
gHasBeam[id])  
    {      
        
gPlayerInCooldown[id] = false   
    
}  
}   

public 
fire_attack(id)  
{   
    new 
tidtbodydamage  
    
    damage 
get_pcvar_num(pCvarDmg)   
    
    
get_user_aiming(idtidtbody)  
    
    
    
attack_effects(id)
    
    
    if ( 
is_user_alive(tid) && (cs_get_user_team(id) != cs_get_user_team(tid) || sh_friendlyfire_on()) )  
    {  
        
sh_extra_damage(tididdamage"Beam_Test")  
    }  
    
sh_set_cooldown(idget_pcvar_float(pCvarCool))  
}  

public 
attack_effects(id)
{
    new 
aimvec[3]  
    
get_user_origin(idaimvec3
    
    
    new 
origin[3]
    
get_user_origin(idorigin1)
    
    
// Beam effect between two points
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_BEAMPOINTS)    // 0
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(aimvec[0])
    
write_coord(aimvec[1])
    
write_coord(aimvec[2])
    
write_short(Beam)
    
write_byte(1)        // framestart
    
write_byte(5)        // framerate
    
write_byte(2)        // life
    
write_byte(40)        // width
    
write_byte(0)        // noise
    
write_byte(255)        // r, g, b
    
write_byte(250)        // r, g, b
    
write_byte(250)        // r, g, b
    
write_byte(200)        // brightness
    
write_byte(200)        // speed
    
message_end()
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1030\\ f0\\ fs16 \n\\ par }
*/ 
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
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 13:30.


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