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(id, heroID, key)
{
//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(id, 1)
//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(id, print_chat, "[SH] Noclip removed")
//set cooldown variable to false so user can use noclip again
gCooldown[id] = false
//take away noclip
set_user_noclip(id, 0)
}
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", 0, parm, 1)
}
}
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(players, pnum, "ac")
// if no alive non-bots do not respawn
if ( !pnum )
return
}
emit_sound(id, CHAN_STATIC, "ambience/port_suckin1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_chat, "[SH](%s) You used %s's Voodoo power to come back to life!", HeroName, HeroName)
// 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(id, CHAN_STATIC, "nihilanth/nil_comes.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
shGlow(id, 75, 75, 255)
set_task(3.0, "chucky_unglow", 0, parm, 1)
set_task(1.0, "chucky_teamcheck", 0, parm, 1)
}
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.
__________________