Freecode
09-18-2005, 14:36
Converting Heroes to the new Module API.
Notes: This convert guide is only for AMXX heroes.
Required Global Variables:
You need a bool to store whether or not user has this hero
ex: new bool: g_HasPower[SH_MAXSLOTS+1];
You need a variable to store current hero id #
ex: new g_heroID;
Converting plugin_init() to the new API:
You register plugin just as usualy
ex: register_plugin("SUPERHERO Superman","1.18","{HOJ} Batman");
New syntax for registering a hero:
Register hero in the module. Will return hero ID number:
sh_create_hero(g_heroName);
ex: g_heroID = sh_create_hero(g_heroName);
Set heroes Power and Help info.
sh_hero_info(g_heroID, power[], help[]);
ex: sh_hero_info(g_heroID, "Health/Armor/Gravity", "More Health/Free Armor/Reduced Gravity");
Set whether hero will use a bind.
sh_hero_bind(g_heroID, bool:button = false);
ex: sh_hero_bind(g_heroID, false);
Set what level the hero is available at.
sh_hero_level(g_heroID, level);
ex: sh_hero_level(g_heroID, get_cvar_num("superman_level"));
Other syntax:
Setting heroes Max AP/HP
sh_set_hero_vars(g_heroID, maxHP, maxAP);
ex: sh_set_hero_vars(g_heroID, get_cvar_num("superman_health"), get_cvar_num("superman_armor"))
Now i introduced a new gravity feature which resembles old speed feature where you can set certain speed for certain weapons.
So to set a certain gravity for certain gun you need this :)
So let me break this down so you understand:
Float:gravity = 1.0 - Just a float specifying the gravity obviously
weaponsNum - a number specifying how many weapons gravity you will be changing. (min - 1)
weapons[] - an array which stores the weapon numbers. Use 0 for all weapons.
sh_set_hero_grav(g_heroID, Float:gravity = 1.0, weaponsNum, weapons[]);
ex: sh_set_hero_grav(g_heroID, get_cvar_float("superman_gravity"), 1, {0}); // Will set gravity for all weapons
Setting speed for certain weapons.
sh_set_hero_speed(g_heroID, Float:speed = -1.0, numWeapons, weapons[]);
ex: set_hero_speed(g_heroID, 500.0, 3, {6,26,29}); // Will set 500.0 speed for weapons 6, 26, 29
Converting hero_init() to the new API:
The new API got rid of old hero_init() and now uses sh_hero_init forward which gets called everytime a hero is added or dropped.
Mode:
HERO_ADD
HERO_DROP
sh_hero_init(id, heroID, mode)
public sh_hero_init(id, heroID, mode)
{
if ( g_heroID == heroID )
{
switch(mode)
{
case HERO_ADD:
g_HasPower[id] = true;
case HERO_DROP:
g_HasPower[id] = false;
}
}
}
Converting bound key heroes to the new API:
The new API got rid of registering functions for keyUP/keyDOWN heroes and now uses a forward: sh_hero_key that gets called everytime a key is pressed.
Key:
SH_KEYDOWN
SH_KEYUP
sh_hero_key(id, heroID, key)
public sh_hero_key(id, heroID, key)
{
if ( g_heroID != heroID ) return PLUGIN_CONTINUE
switch(key)
{
case SH_KEYDOWN:
// Call your keydown function from here
case SH_KEYUP:
// Call your keyup function from here
}
return PLUGIN_HANDLED
}
I will post the rest later on today. :D
Notes: This convert guide is only for AMXX heroes.
Required Global Variables:
You need a bool to store whether or not user has this hero
ex: new bool: g_HasPower[SH_MAXSLOTS+1];
You need a variable to store current hero id #
ex: new g_heroID;
Converting plugin_init() to the new API:
You register plugin just as usualy
ex: register_plugin("SUPERHERO Superman","1.18","{HOJ} Batman");
New syntax for registering a hero:
Register hero in the module. Will return hero ID number:
sh_create_hero(g_heroName);
ex: g_heroID = sh_create_hero(g_heroName);
Set heroes Power and Help info.
sh_hero_info(g_heroID, power[], help[]);
ex: sh_hero_info(g_heroID, "Health/Armor/Gravity", "More Health/Free Armor/Reduced Gravity");
Set whether hero will use a bind.
sh_hero_bind(g_heroID, bool:button = false);
ex: sh_hero_bind(g_heroID, false);
Set what level the hero is available at.
sh_hero_level(g_heroID, level);
ex: sh_hero_level(g_heroID, get_cvar_num("superman_level"));
Other syntax:
Setting heroes Max AP/HP
sh_set_hero_vars(g_heroID, maxHP, maxAP);
ex: sh_set_hero_vars(g_heroID, get_cvar_num("superman_health"), get_cvar_num("superman_armor"))
Now i introduced a new gravity feature which resembles old speed feature where you can set certain speed for certain weapons.
So to set a certain gravity for certain gun you need this :)
So let me break this down so you understand:
Float:gravity = 1.0 - Just a float specifying the gravity obviously
weaponsNum - a number specifying how many weapons gravity you will be changing. (min - 1)
weapons[] - an array which stores the weapon numbers. Use 0 for all weapons.
sh_set_hero_grav(g_heroID, Float:gravity = 1.0, weaponsNum, weapons[]);
ex: sh_set_hero_grav(g_heroID, get_cvar_float("superman_gravity"), 1, {0}); // Will set gravity for all weapons
Setting speed for certain weapons.
sh_set_hero_speed(g_heroID, Float:speed = -1.0, numWeapons, weapons[]);
ex: set_hero_speed(g_heroID, 500.0, 3, {6,26,29}); // Will set 500.0 speed for weapons 6, 26, 29
Converting hero_init() to the new API:
The new API got rid of old hero_init() and now uses sh_hero_init forward which gets called everytime a hero is added or dropped.
Mode:
HERO_ADD
HERO_DROP
sh_hero_init(id, heroID, mode)
public sh_hero_init(id, heroID, mode)
{
if ( g_heroID == heroID )
{
switch(mode)
{
case HERO_ADD:
g_HasPower[id] = true;
case HERO_DROP:
g_HasPower[id] = false;
}
}
}
Converting bound key heroes to the new API:
The new API got rid of registering functions for keyUP/keyDOWN heroes and now uses a forward: sh_hero_key that gets called everytime a key is pressed.
Key:
SH_KEYDOWN
SH_KEYUP
sh_hero_key(id, heroID, key)
public sh_hero_key(id, heroID, key)
{
if ( g_heroID != heroID ) return PLUGIN_CONTINUE
switch(key)
{
case SH_KEYDOWN:
// Call your keydown function from here
case SH_KEYUP:
// Call your keyup function from here
}
return PLUGIN_HANDLED
}
I will post the rest later on today. :D