This is the first hero by me which isn't a rip... I didn't take any code from other heroes, but I have a few problems with it:
1st: The cooldown doesn't work. (Fixed)
2nd: The damagemultiplyers doesn't seem to work. (Fixed)
3rd: The gravity thing works first the next round and not if you choose it.
4th: You first have to change your weapon that the speed works.
5th: Only Mp5navy has unlimited bullets and I wanna have it for glock, usp & mp5navy. (Fixed)
I don't get any errors while compiling it and there also doesn't occur any errors or problems in the console (with debugging), so I hope you can help me
Code:
// The Mask! -- From The Movie With Jim Carrey
// Credit goes to Gorlag/Batman for help me with the cooldown and weaponchange part
// Credit also goes to Emp` who helped me with the damage part
// And also thanks to vittu for the finishing touch :D
/* CVARS - copy and paste to shconfig.cfg
//The Mask
themask_level 10
themask_health 300 //How much hp he has
themask_armor 999 //How much ap he has
themask_speed 600 //How fast he is
themask_gravity 0.30 //How much gravity he has
themask_cooldown 60 //# of seconds for The Mask cooldown
themask_uspmult 3 //Multiplyer for the USP
themask_glock18mult 3.5 //Multiplyer for the Glock18
themask_mp5navymult 1.5 //Multiplyer for the Mp5navy
*/
#include <amxmod>
#include <superheromod>
// GLOBAL VARIABLES
new gHeroName[]="The Mask"
new bool:gHasTheMaskPowers[SH_MAXSLOTS+1]
new gHasTheMaskUltimate[SH_MAXSLOTS+1]
new bool:gDamage1[SH_MAXSLOTS+1]
new bool:gDamage2[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO The Mask","1.0","-]Tical2k[- DooM")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("themask_level", "10" )
register_cvar("themask_health", "300" )
register_cvar("themask_armor", "999" )
register_cvar("themask_speed", "600" )
register_cvar("themask_gravity", "0.30" )
register_cvar("themask_cooldown", "60" )
register_cvar("themask_uspmult", "300" )
register_cvar("themask_glock18mult", "300" )
register_cvar("themask_mp5navymult", "100" )
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Choose!", "You will have a menu with nice opportunities.", true, "themask_level" )
// INIT
register_srvcmd("themask_init", "themask_init")
shRegHeroInit(gHeroName, "themask_init")
// EVENTS
register_event("Damage", "themask_Damage", "b", "2!0")
register_event("CurWeapon", "WeaponChange", "be", "1=1")
register_event("DeathMsg", "Death", "a")
register_event("ResetHUD","NewRound","b")
// MENU
register_menucmd(register_menuid("The Mask's Opportunities"), 1023, "main_menu_action")
// KEYDOWN
register_srvcmd("themask_kd", "themask_kd")
shRegKeyDown(gHeroName, "themask_kd")
}
//----------------------------------------------------------------------------------------------
public themask_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has wolverine skills
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
//This gets run if they had the power but don't anymore
if ( !hasPowers && gHasTheMaskPowers[id] ) {
engclient_cmd(id, "drop", "weapon_usp")
engclient_cmd(id, "drop", "weapon_glock18")
engclient_cmd(id, "drop", "weapon_mp5navy")
shRemHealthPower(id)
shRemArmorPower(id)
shRemGravityPower(id)
shRemSpeedPower(id)
}
//Sets this variable to the current status
gHasTheMaskPowers[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------
public NewRound(id)
{
gPlayerUltimateUsed[id] = false
gDamage1[id] = false
gDamage2[id] = false
}
//----------------------------------------------------------------------------------------------
public themask_kd()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
if ( !is_user_alive(id) ) return
if ( gPlayerUltimateUsed[id] )
{
playSoundDenySelect(id)
return
}
if ( gHasTheMaskUltimate[id]>0 ) return
show_main_menu(id)
ultimateTimer(id, get_cvar_num("themask_cooldown") * 1.0)
return
}
//----------------------------------------------------------------------------------------------
public show_main_menu(id)
{
new menu_body[320]
new n = 0
new len = 319
if ( !gHasTheMaskPowers[id] || !is_user_alive(id) ) return
n += format(menu_body[n], len-n, "\rThe Mask's Opportunities^n", " ")
n += format(menu_body[n], len-n, "^n\w1. More HP")
n += format(menu_body[n], len-n, "^n2. More AP")
n += format(menu_body[n], len-n, "^n3. More Speed")
n += format(menu_body[n], len-n, "^n4. Lower Gravity")
n += format(menu_body[n], len-n, "^n5. More DMG for USP & Glock")
n += format(menu_body[n], len-n, "^n6. More DMG for Mp5navy")
n += format(menu_body[n], len-n, "^n^n0. Exit")
new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9)
show_menu(id, keys, menu_body)
}
//----------------------------------------------------------------------------------------------
public main_menu_action(id, key)
{
key++
if ( !shModActive() || !gHasTheMaskPowers[id] || !is_user_alive(id) ) return
switch(key){
case 1: {
themask_health(id)
}
case 2: {
themask_armor(id)
}
case 3: {
themask_speed(id)
}
case 4: {
themask_gravity(id)
}
case 5: {
themask_ability(id)
gDamage1[id] = true
}
case 6: {
themask_ability2(id)
gDamage2[id] = true
}
case 10: return
default: show_main_menu(id)
}
}
//----------------------------------------------------------------------------------------------
public WeaponChange(id)
{
if ( !gHasTheMaskPowers[id] || !shModActive() ) return
new wpnid = read_data(2)
new clip = read_data(3)
if (wpnid != CSW_USP && wpnid != CSW_GLOCK18 && wpnid != CSW_MP5NAVY) return
// Never Run Out of Ammo!
if ( clip == 0 ) {
shReloadAmmo(id)
}
}
//----------------------------------------------------------------------------------------------
public themask_health(id)
{
set_user_health(id, get_cvar_num("themask_health"))
// This is here that the person sees what he/she chose
new message[128]
format(message, 127, "The Mask - You decided to take more hp. Nice Choice!")
set_hudmessage(157,50,250,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
//----------------------------------------------------------------------------------------------
public themask_armor(id)
{
give_item(id, "item_assaultsuit")
set_user_armor(id, get_cvar_num("themask_armor"))
// This is here that the person sees what he/she chose
new message[128]
format(message, 127, "The Mask - You decided to take more ap. Nice Choice!")
set_hudmessage(255,255,255,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
//----------------------------------------------------------------------------------------------
public themask_speed(id)
{
server_cmd("sh_setmaxspeed ^"%s^" ^"%s^" ^"%s^"", gHeroName, "themask_speed", "[0]" )
// This is here that the person sees what he/she chose
new message[128]
format(message, 127, "The Mask - You decided to take more speed. Nice Choice!")
set_hudmessage(255,255,0,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
//----------------------------------------------------------------------------------------------
public themask_gravity(id)
{
server_cmd("sh_setmingravity ^"%s^" ^"%s^"", gHeroName, "themask_gravity" )
// This is here that the person sees what he/she chose
new message[128]
format(message, 127, "The Mask - You decided to take lower gravity. Nice Choice!")
set_hudmessage(157,250,180,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
//----------------------------------------------------------------------------------------------
public themask_ability(id)
{
if ( is_user_alive(id) ) {
shGiveWeapon(id, "weapon_usp")
shGiveWeapon(id, "weapon_glock18")
// This is here that the person sees what he/she chose
new message[128]
format(message, 127, "The Mask - You decided to take more dmg for USP & Glock18. Nice Choice!")
set_hudmessage(18,240,167,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
}
//----------------------------------------------------------------------------------------------
public themask_ability2(id)
{
if ( is_user_alive(id) ) {
shGiveWeapon(id, "weapon_mp5navy")
// This is here that the person sees what he/she chose
new message[128]
format(message, 127, "The Mask - You decided to take more dmg for Mp5navy. Nice Choice!")
set_hudmessage(255,255,0,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
}
//----------------------------------------------------------------------------------------------
public themask_Damage(id)
{
new damage = read_data(2)
new body, weapon, attacker = get_user_attacker(id, weapon, body)
new headshot = body == 1 ? 1 : 0
if ( attacker > 0 && attacker <= SH_MAXSLOTS && is_user_alive(attacker) && attacker != id ) {
if (gDamage1[attacker]){
if(weapon==CSW_USP){
new extraDamage = floatround(damage * get_cvar_float("themask_uspmult") - damage)
if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "usp", headshot )
}
if(weapon==CSW_GLOCK18){
new extraDamage = floatround(damage * get_cvar_float("themask_glock18mult") - damage)
if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "glock18", headshot )
}
}
else if (gDamage2[attacker] && weapon==CSW_MP5NAVY){
new extraDamage = floatround(damage * get_cvar_float("themask_mp5navymult") - damage)
if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "mp5navy", headshot )
}
}
}
//----------------------------------------------------------------------------------------------
public Death()
{
new id = read_data(2)
if ( !gHasTheMaskPowers[id] ) return
}
//---------------------------------------------------------------------------------------------