I decided to make this post so that you can finish understanding how to re-make the heroes or transfer them to new forms in case anyone wants to start and get started
Why change to the new ways?
Because the fact of being able to use the new forms simplifies being able to make better interactions between heroes, for example if we wanted a way to prevent Magneto from affecting a player who has the hero Noob, the new forms would be necessary.
If we wanted to make a cooldown visible to heroes who have cooldown we would also need these new forms
If we wanted to make a menu to be able to choose between all the knife skins that we have for the heroes depending on whether the hero has it or not, it is also necessary
I recommend that if you are new, you first start reading this tutorial on how to create a hero from scratch, it is quite simple to understand:
[Tutorial] Learn the new ways
Continuing with how to change, first we are going to see how to change the simplest heroes, that is, those that do not have keypowers.
In this case I am going to give an example with the hero "Noob" that we already know:
The first thing we have to generate is a global variables gHeroID that refers to the hero to be able to reuse it
PHP Code:
// GLOBAL VARIABLES
new gHeroName[]="Noob"
new gHasNoobPower[SH_MAXSLOTS+1]

PHP Code:
// GLOBAL VARIABLES
new gHeroID
new gHeroName[]="Noob"
new gHasNoobPower[SH_MAXSLOTS+1]
The next change comes in the function public plugin_init() here we must make changes to how the hero starts
PHP Code:
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Noob","1.3","AssKicR")
register_cvar("noob_level", "0")
register_cvar("noob_arrows", "3")
register_cvar("noob_getdeagle", "1")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "exploding deagle shots", "U WILL HAVE A DEAGE WITH 3 EXPLODING SHOTS!!", false, "noob_level")
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("noob_init", "noob_init")
shRegHeroInit(gHeroName, "noob_init")

PHP Code:
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Noob","1.3","AssKicR")
new pcvarLevel = register_cvar("noob_level", "0")
register_cvar("noob_arrows", "3")
register_cvar("noob_getdeagle", "1")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
gHeroID = sh_create_hero(gHeroName, pcvarLevel)
sh_set_hero_info(gHeroID, "exploding deagle shots", "U WILL HAVE A DEAGE WITH 3 EXPLODING SHOTS!!")
As you could see we eliminated the function calls
// INIT
register_srvcmd("noob_init", "noob_init")
shRegHeroInit(gHeroName, "noob_init")
and we change how the hero is registered
What follows now is to eliminate the following function and replace it with this one, but before eliminating this function we must pay attention to some events that the hero has when we choose him, for example:
PHP Code:
public noob_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 garrow
read_argv(2,temp,5)
new hasPowers=str_to_num(temp)
gHasNoobPower[id]=(hasPowers!=0)
if ( gHasNoobPower[id] ) {
shGiveWeapon(id,"weapon_deagle")
}
else {
sh_drop_weapon(id, CSW_DEAGLE, true)
}
}
we have to pay attention to the part of
PHP Code:
if ( gHasNoobPower[id] ) {
shGiveWeapon(id,"weapon_deagle")
}
else {
sh_drop_weapon(id, CSW_DEAGLE, true)
}
What we have to understand from this fragment is what functions occur when it is added and when it is dropped


So to achieve a correct change with the events it shows us we have to do the following:
PHP Code:
public sh_hero_init(id, heroID, mode)
{
if ( gHeroID == heroID ) {
switch(mode) {
case SH_HERO_ADD: {
gHasNoobPower[id] = true
shGiveWeapon(id,"weapon_deagle")
}
case SH_HERO_DROP: {
gHasNoobPower[id] = false
sh_drop_weapon(id, CSW_DEAGLE, true)
}
}
sh_debug_message(id, 1, "%s %s", gHeroName, mode ? "ADDED" : "DROPPED")
}
}
Thus we conclude with how to write a hero without key powers, we can notice but a small difference in generic simplification in the code, but the most important thing is not that, but that it allows us to eventually be able to perform the actions that I mentioned at the beginning
In the end we should pass the code, it should look something like this, (although of course I am ignoring many more events that are called from the init plugin but that are not relevant to registering the hero)
PHP Code:
// VARIABLES
new gHeroName[]="Noob"
new gHasNoobPower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Noob","1.3","AssKicR")
register_cvar("noob_level", "0")
register_cvar("noob_arrows", "3")
register_cvar("noob_getdeagle", "1")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "exploding deagle shots", "U WILL HAVE A DEAGE WITH 3 EXPLODING SHOTS!!", false, "noob_level")
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("noob_init", "noob_init")
shRegHeroInit(gHeroName, "noob_init")
}
public noob_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 garrow
read_argv(2,temp,5)
new hasPowers=str_to_num(temp)
gHasNoobPower[id]=(hasPowers!=0)
if ( gHasNoobPower[id] ) {
shGiveWeapon(id,"weapon_deagle")
}
else {
sh_drop_weapon(id, CSW_DEAGLE, true)
}
}



PHP Code:
// VARIABLES
new gHeroID
new gHeroName[]="Noob"
new gHasNoobPower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Noob","1.3","AssKicR")
new pcvarLevel = register_cvar("noob_level", "0")
register_cvar("noob_arrows", "3")
register_cvar("noob_getdeagle", "1")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
gHeroID = sh_create_hero(gHeroName, pcvarLevel)
sh_set_hero_info(gHeroID, "exploding deagle shots", "U WILL HAVE A DEAGE WITH 3 EXPLODING SHOTS!!")
}
public sh_hero_init(id, heroID, mode)
{
if ( gHeroID == heroID ) {
switch(mode) {
case SH_HERO_ADD: {
gHasNoobPower[id] = true
shGiveWeapon(id,"weapon_deagle")
}
case SH_HERO_DROP: {
gHasNoobPower[id] = false
sh_drop_weapon(id, CSW_DEAGLE, true)
}
}
sh_debug_message(id, 1, "%s %s", gHeroName, mode ? "ADDED" : "DROPPED")
}
}