<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alliedmods.net/index.php?action=history&amp;feed=atom&amp;title=SH_Tutorial_1.2</id>
	<title>SH Tutorial 1.2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alliedmods.net/index.php?action=history&amp;feed=atom&amp;title=SH_Tutorial_1.2"/>
	<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=SH_Tutorial_1.2&amp;action=history"/>
	<updated>2026-06-05T21:04:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=SH_Tutorial_1.2&amp;diff=7427&amp;oldid=prev</id>
		<title>Jtpizzalover: Superhero Mod tutuorial for the code changes under shmod1.2</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=SH_Tutorial_1.2&amp;diff=7427&amp;oldid=prev"/>
		<updated>2009-10-14T03:13:58Z</updated>

		<summary type="html">&lt;p&gt;Superhero Mod tutuorial for the code changes under shmod1.2&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:SuperheroMod]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;superheromod&amp;gt; //Must be included in the creating of a superhero&lt;br /&gt;
&lt;br /&gt;
// VARIABLES&lt;br /&gt;
new const gHeroName[]=&amp;quot;Tutorial&amp;quot; //Name Of The Hero&lt;br /&gt;
new bool:gHasTutorialPower[SH_MAXSLOTS+1] //A Variable telling us if player has this hero&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public plugin_init()&lt;br /&gt;
{&lt;br /&gt;
  // Plugin Info&lt;br /&gt;
  register_plugin(&amp;quot;SUPERHERO Tutorial&amp;quot;,&amp;quot;1.0&amp;quot;,&amp;quot;AssKicR&amp;quot;) //Register The Plugin (name,version,creator)&lt;br /&gt;
&lt;br /&gt;
  // DEFAULT THE CVARS&lt;br /&gt;
  new pcvarGravity = register_cvar(&amp;quot;tutorial_gravity&amp;quot;, &amp;quot;0.35&amp;quot; ) //Cvar holding the heros Gravity&lt;br /&gt;
  new pcvarArmor = register_cvar(&amp;quot;tutorial_armor&amp;quot;, &amp;quot;150&amp;quot;) //Cvar holding the heros AP&lt;br /&gt;
  new pcvarHealth = register_cvar(&amp;quot;tutorial_health&amp;quot;, &amp;quot;150&amp;quot;) //Cvar holding the heros HP&lt;br /&gt;
  new pcvarSpeed = register_cvar(&amp;quot;tutorial_speed&amp;quot;, &amp;quot;300&amp;quot;) //Cvar holding the heros Speed&lt;br /&gt;
  new pcvarCooldown = register_cvar(&amp;quot;tutorial_cooldown&amp;quot;, &amp;quot;0&amp;quot; ) //Cvar holding the heros Gravity &lt;br /&gt;
  new pcvarMultiplier = register_cvar(&amp;quot;tutorial_multiplier&amp;quot;, &amp;quot;10&amp;quot; ) //Cvar holding a number that we are gonna use as a multiplier later &lt;br /&gt;
  new pcvarHealpoints = register_cvar(&amp;quot;tutorial_healpoints&amp;quot;, &amp;quot;1&amp;quot; ) //Cvar we are using to see how much he heals&lt;br /&gt;
  new pcvarLevel = register_cvar(&amp;quot;tutorial_level&amp;quot;, &amp;quot;0&amp;quot; ) ///Resister the cvar that tells us what level he is available&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
  sh_set_hero_info(gHeroID, &amp;quot;Short Desc&amp;quot;, &amp;quot;Longer Desc&amp;quot;) // This is the command that registers the hero with the mod. In The &amp;quot;Short Desc&amp;quot; You write a short Description.. And a longer one in &amp;quot;Longer Desc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  // Binds&lt;br /&gt;
  sh_set_hero_bind(gHeroID) //This command is added for bind-able heros.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  // DEATH EVENT&lt;br /&gt;
  register_event(&amp;quot;DeathMsg&amp;quot;, &amp;quot;tutorial_death&amp;quot;, &amp;quot;a&amp;quot;) //When someone is killed this event is called&lt;br /&gt;
  // NEW ROUND&lt;br /&gt;
  register_event(&amp;quot;ResetHUD&amp;quot;,&amp;quot;newRound&amp;quot;,&amp;quot;b&amp;quot;) //Called on a New Round&lt;br /&gt;
  // DAMAGE EVENT&lt;br /&gt;
  register_event(&amp;quot;Damage&amp;quot;, &amp;quot;tutorial_damage&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;2!0&amp;quot;) //Called When a Player Gets Damaged by another player&lt;br /&gt;
  // WEAPON EVENT (called on CHANGING of weapon... ZOOMING of weapon... and when you RUN OUT OF AMMO on a weapon)&lt;br /&gt;
  register_event(&amp;quot;CurWeapon&amp;quot;,&amp;quot;changeWeapon&amp;quot;,&amp;quot;be&amp;quot;,&amp;quot;1=1&amp;quot;)  &lt;br /&gt;
  // LOOP&lt;br /&gt;
  register_srvcmd(&amp;quot;tutorial_loop&amp;quot;, &amp;quot;tutorial_loop&amp;quot;)&lt;br /&gt;
  //shRegLoop1P0(gHeroName, &amp;quot;tutorial_loop&amp;quot;, &amp;quot;ac&amp;quot;) // Alive tutorialerineHeros=&amp;quot;ac&amp;quot;&lt;br /&gt;
  set_task(1.0,&amp;quot;tutorial_loop&amp;quot;,0,&amp;quot;&amp;quot;,0,&amp;quot;b&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  // Let Server know about Tutorials Variable&lt;br /&gt;
  // It is possible that another hero has more hps, less gravity, or more armor&lt;br /&gt;
  // so rather than just setting these - let the superhero module decide each round&lt;br /&gt;
  sh_set_hero_hpap(heroID, pcvarHealth, pcvarArmor)&lt;br /&gt;
  sh_set_hero_grav(heroID, pcvarGravity)&lt;br /&gt;
  sh_set_hero_speed(heroID, pcvarSpeed)&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public tutorial_init()&lt;br /&gt;
{&lt;br /&gt;
  new temp[6] //Variable to store temp info in&lt;br /&gt;
  // First Argument is an id&lt;br /&gt;
  read_argv(1,temp,5) //This Checks for the ID of the person selecting/dropping this hero and saves as string&lt;br /&gt;
  new id=str_to_num(temp) //This makes the string Into a num&lt;br /&gt;
  &lt;br /&gt;
  // 2nd Argument is 0 or 1 depending on whether the id has flash&lt;br /&gt;
  read_argv(2,temp,5) //This Checks if ID has this hero&lt;br /&gt;
  new hasPowers=str_to_num(temp) //This makes the string into a num&lt;br /&gt;
  gHasTutorialPower[id]=(hasPowers!=0) //Store if this person has the hero&lt;br /&gt;
  &lt;br /&gt;
  if ( hasPowers ) //Check if person selected this hero&lt;br /&gt;
  {&lt;br /&gt;
    //Do stuff to him if he just seleced it&lt;br /&gt;
  }&lt;br /&gt;
  // Got to slow down a Flash that lost his powers...&lt;br /&gt;
  if ( !hasPowers  &amp;amp;&amp;amp; is_user_connected(id) ) //Check if person dropped this hero&lt;br /&gt;
  {&lt;br /&gt;
    //Do stuff to him if he just droppped it&lt;br /&gt;
    shRemHealthPower(id) //Loose the HP power of this hero&lt;br /&gt;
    shRemGravityPower(id) //Loose the Gravity power of this hero&lt;br /&gt;
    shRemArmorPower(id) //Loose the AP power of this hero&lt;br /&gt;
    shRemSpeedPower(id) //Loose the Speed power of this hero&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public plugin_precache()&lt;br /&gt;
{&lt;br /&gt;
  // precache_sound(&amp;quot;misc/name.wav&amp;quot;) // Sounds Must be precached before they can be used&lt;br /&gt;
  // precache_sound(&amp;quot;models/name.mdl&amp;quot;) // Models Must be precached before they can be used&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public client_connect(id)&lt;br /&gt;
{&lt;br /&gt;
  // This event is called every time someone connects to server&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public client_putinserver(id)&lt;br /&gt;
{&lt;br /&gt;
  // This event is called every time someone gets into to server&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public client_disconnect(id)&lt;br /&gt;
{&lt;br /&gt;
  // This event is called every time someone disconnects from server&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
// RESPOND TO KEYDOWN&lt;br /&gt;
public tutorial_kd() { &lt;br /&gt;
  new temp[6] //Variable to store temp info in&lt;br /&gt;
  // First Argument is an id with Tutorial Powers!&lt;br /&gt;
  read_argv(1,temp,5) //This Checks for the ID of the person pressing the button&lt;br /&gt;
  new id=str_to_num(temp) //This makes the string Into a num&lt;br /&gt;
  &lt;br /&gt;
  // Let them know they already used their ultimate if they have&lt;br /&gt;
  if ( gPlayerUltimateUsed[id] ) //If the player already have used this and try using again while avtive/ in cooldown...&lt;br /&gt;
  {&lt;br /&gt;
    playSoundDenySelect(id) //...It plays the deny sound...&lt;br /&gt;
    return PLUGIN_HANDLED //...And cancels the users action&lt;br /&gt;
  } &lt;br /&gt;
  &lt;br /&gt;
  new TutorialCooldown=get_cvar_num(&amp;quot;tutorial_cooldown&amp;quot;) //How long the cooldown is (cvar controlled)&lt;br /&gt;
  if ( TutorialCooldown&amp;gt;0 ) //Check if it is higher than 0 (0=disabled)&lt;br /&gt;
	ultimateTimer(id, TutorialCooldown * 1.0 ) //Fire the Ultimatetimer&lt;br /&gt;
  &lt;br /&gt;
  //Fire an action on this button press here&lt;br /&gt;
&lt;br /&gt;
  return PLUGIN_HANDLED &lt;br /&gt;
} &lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
// RESPOND TO KEYUP&lt;br /&gt;
public tutorial_ku() &lt;br /&gt;
{ &lt;br /&gt;
  new temp[6] //Variable to store temp info in&lt;br /&gt;
  // First Argument is an id with tutorial Powers!&lt;br /&gt;
  read_argv(1,temp,5) //This Checks for the ID of the person pressing the button&lt;br /&gt;
  new id=str_to_num(temp) //This makes the string Into a num&lt;br /&gt;
&lt;br /&gt;
  //Fire an action on this button release here&lt;br /&gt;
&lt;br /&gt;
  return PLUGIN_HANDLED &lt;br /&gt;
} &lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public tutorial_death()&lt;br /&gt;
{&lt;br /&gt;
  //The Deathmessage is &amp;quot;Killer Weapon Victim&amp;quot; Killer=data1 Victim=data2 Weapon=data3&lt;br /&gt;
  new id=read_data(2) //Get the ID of the person who died&lt;br /&gt;
  &lt;br /&gt;
  if (gHasTutorialPower[id]) { //Checks if the person killed has the powers of this hero&lt;br /&gt;
	//Do something to him when he dies&lt;br /&gt;
  }&lt;br /&gt;
  if (!gHasTutorialPower[id]) { //Checks if the person killed doesn't have the powers of this hero&lt;br /&gt;
	//Do something to him when he dies&lt;br /&gt;
  }&lt;br /&gt;
  return PLUGIN_HANDLED &lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public newRound(id)&lt;br /&gt;
{&lt;br /&gt;
  gPlayerUltimateUsed[id]=false // It is a new round so nevermind the cooldown on the skill and let him use it again&lt;br /&gt;
  return PLUGIN_HANDLED&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public tutorial_damage(id)&lt;br /&gt;
{&lt;br /&gt;
  //!shModActive() tells us that that shMod Must be active&lt;br /&gt;
  //!gHasTutorialPower[id] tells us that the person being attacked must have Tutorial Hero&lt;br /&gt;
  if (!shModActive() || !gHasTutorialPower[id] ) return PLUGIN_CONTINUE&lt;br /&gt;
&lt;br /&gt;
  new damage = read_data(2) //This reads the damage done to ID &lt;br /&gt;
  new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)&lt;br /&gt;
    &lt;br /&gt;
  //is_user_alive(id) checks if the one attacked is still alive&lt;br /&gt;
  //id != attacker States that the Person giving damage can't be the same as the one getting it&lt;br /&gt;
  //weapon=CSW_KNIFE tell us that only the weapon knife will make this happen (Changeable.. Look in amxconst.inc for other )&lt;br /&gt;
  if ( is_user_alive(id) &amp;amp;&amp;amp; id != attacker &amp;amp;&amp;amp; weapon==CSW_KNIFE) {&lt;br /&gt;
    // DO EXTRA DAMAGE (Can be replaced by something else)&lt;br /&gt;
    new extraDamage = floatround(damage * get_cvar_float(&amp;quot;tutorial_multiplier&amp;quot;) - damage) //Find out how much extradamage there is&lt;br /&gt;
    if (extraDamage&amp;gt;0) //Check if extradamage is higher that 0&lt;br /&gt;
	new defence=random_num(0,5) //This will assign a random number between 0 and 5 to the variable defence&lt;br /&gt;
    switch (defence) { //Choose one of these defences depending on what the number is&lt;br /&gt;
		case 0:shExtraDamage( id, attacker, extraDamage, &amp;quot;Right Hook&amp;quot; ) //Do extraDamage to ID from ATTACKER with weapon Right Hook&lt;br /&gt;
		case 1:shExtraDamage( id, attacker, extraDamage, &amp;quot;Left Hook&amp;quot; ) //Do extraDamage to ID from ATTACKER with weapon Left Hook&lt;br /&gt;
		case 2:shExtraDamage( id, attacker, extraDamage, &amp;quot;Right Jab&amp;quot; ) //Do extraDamage to ID from ATTACKER with weapon Right Jab&lt;br /&gt;
		case 3:shExtraDamage( id, attacker, extraDamage, &amp;quot;Left Jab&amp;quot; ) //Do extraDamage to ID from ATTACKER with weapon left Jab&lt;br /&gt;
		case 4:shExtraDamage( id, attacker, extraDamage, &amp;quot;Uppercut&amp;quot; ) //Do extraDamage to ID from ATTACKER with weapon Uppercut&lt;br /&gt;
		case 5:shExtraDamage( id, attacker, 0, &amp;quot;Miss&amp;quot; ) //Do 0 damage to ID from ATTACKER&lt;br /&gt;
	}&lt;br /&gt;
  }&lt;br /&gt;
  setScreenFlash(attacker, 230, 10, 10, 10, damage )  //This makes the screen of the attacker flash&lt;br /&gt;
  sh_screenShake(attacker, 14, 14, 14 ) //Make his Screen Shake a little&lt;br /&gt;
  shStun(attacker, 1) //Stun Him in 1 second&lt;br /&gt;
&lt;br /&gt;
  return PLUGIN_CONTINUE&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public tutorial_loop()&lt;br /&gt;
{&lt;br /&gt;
  for ( new id=1; id&amp;lt;=SH_MAXSLOTS; id++ ) //Check Everyone on Server&lt;br /&gt;
  {&lt;br /&gt;
    if (  gHasTutorialPower[id] &amp;amp;&amp;amp; is_user_alive(id)  ) //Check if this person is alive and has the powers of the Tutorial hero&lt;br /&gt;
    {&lt;br /&gt;
      shAddHPs(id, get_cvar_num(&amp;quot;tutorial_healpoints&amp;quot;), 50 ) //This Command gives the hero back HP to max 50 in this case&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
public changeWeapon(id)&lt;br /&gt;
{&lt;br /&gt;
    if ( !gHasTutorialPower[id] || !shModActive() ) return PLUGIN_CONTINUE&lt;br /&gt;
    new  clip, ammo&lt;br /&gt;
    new wpn_id=get_user_weapon(id, clip, ammo) //Get some info on current weapon&lt;br /&gt;
    new wpn[32]&lt;br /&gt;
	//JUST MAKING SURE IT'S NOT GRENADES,KNIFE or C4&lt;br /&gt;
    if ( wpn_id==CSW_C4 || wpn_id==CSW_HEGRENADE || wpn_id == CSW_SMOKEGRENADE || wpn_id == CSW_FLASHBANG || wpn_id == CSW_KNIFE ) return PLUGIN_CONTINUE&lt;br /&gt;
    &lt;br /&gt;
    // Never Run Out of Ammo!&lt;br /&gt;
    //server_print(&amp;quot;STATUS ID=%d CLIP=%d, AMMO=%d WPN=%d&amp;quot;, id, clip, ammo, wpn_id)&lt;br /&gt;
    if ( clip == 0 )&lt;br /&gt;
    {&lt;br /&gt;
      //server_print(&amp;quot;INVOKING PUNISHER MODE! ID=%d CLIP=%d, AMMO=%d WPN=%d&amp;quot;, id, clip, ammo, wpn_id)&lt;br /&gt;
      get_weaponname(wpn_id,wpn,31) //Get name of the weapon&lt;br /&gt;
      give_item(id,wpn) //Give him that weapon&lt;br /&gt;
      engclient_cmd(id, wpn ) //Switch to that weapon&lt;br /&gt;
      shResetSpeed(id) //Set heros speed to normal hero again&lt;br /&gt;
    }&lt;br /&gt;
    return PLUGIN_CONTINUE&lt;br /&gt;
}&lt;br /&gt;
//----------------------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jtpizzalover</name></author>
		
	</entry>
</feed>