View Single Post
andjak123
Junior Member
Join Date: Jan 2009
Old 11-13-2009 , 21:09   Re: My Hero Wont Work!
Reply With Quote #2

Doenst matter now i got it, + i got it admin only xD
now im gonna post it in new submissions
PHP Code:
//Jacobi

/*THE CVARS TO COPY AND PASTE IN SHCONFIG.CFG

//Jacobi
Jacobi_level 10
Jacobi_damage 200
Jacobi_cooldown 50
Jacobi_diskspeed 750
Jacobi_disklife 50
Jacobi_health 1000
Jacobi_armor 1000
Jacobi_speed 1000
jacobi_disk_ammo -1
Jacobi_multishot 0.1
*/

#include <amxmodx>
#include <engine>
#include <superheromod>

new gHeroName[] = "Jacobi" 
new bool:g_hasJacobiPowers[SH_MAXSLOTS+1
new 
bool:gdiskFired[SH_MAXSLOTS+1]
new 
diskTimer[SH_MAXSLOTS+1
//This variable will represent the disk being made. 
new disk[SH_MAXSLOTS+1]
new 
flash
//------------------------------------------------------------------------------------ 
public plugin_init() 

    
//Special thanks to avalanche for helping me to debug my hero.
    
register_plugin("SUPERHERO Jacobi""1.1""Jacobi"

    
//THE CVARS 
    
register_cvar("Jacobi_level""30"
    
register_cvar("Jacobi_damage""200")  
    
register_cvar("Jacobi_cooldown""0"
    
register_cvar("Jacobi_diskspeed""750"
    
register_cvar("Jacobi_disklife""500")
    
register_cvar("Jacobi_disk_ammo""-1")
    
register_cvar("Jacobi_multishot""0.1"
    
register_cvar("Jacobi_health""200")
    
register_cvar("Jacobi_armor""200")
    
register_cvar("Jacobi_speed""200")

    
//THIS LINE MAKES THE HERO SELECTABLE 
    
shCreateHero(gHeroName"Jacobi(ADMIN ONLY)""Get Some HP/AP/Speed/Unlimited Black Discs"true"Jacobi_level"

    
//INITIAL ACTIONS 
    
register_srvcmd("Jacobi_init""Jacobi_init"
    
shRegHeroInit(gHeroName"Jacobi_init"

    
//KEY DOWN COMMAND 
    
register_srvcmd("Jacobi_kd""Jacobi_kd"
    
shRegKeyDown(gHeroName"Jacobi_kd"

    
// KEY UP
    
register_srvcmd("Jacobi_ku""Jacobi_ku")
    
shRegKeyUp(gHeroName"Jacobi_ku")

    
//SPAWNING EVENT 
    
register_event("ResetHUD""newSpawn""b"
    
// DEATH
    
register_event("DeathMsg""Jacobi_death""a")

    
//THIS EVENT IS TRIGGERED WHEN SOMEONE DIES
    
register_event("DeathMsg""Jacobi_kill""a")

    
//SET THE LIFE OF THE DISK 
    
set_task(0.1"Jacobi_disklife"0""0"b"

    
//REGISTERS A TOUCH EVENT, WHEN TWO THINGS TOUCH
    
register_touch("disk""*""touch_event")

    
// Let Server know about Jacobi's Variables
    
shSetMaxHealth(gHeroName"Jacobi_health")
    
shSetMaxArmor(gHeroName"Jacobi_armor")
    
shSetMaxSpeed(gHeroName"Jacobi_speed""[0]")


//-------------------------------------------------------------------------------------- 
public plugin_precache() 

    
precache_model("models/shmod/Jacobi_disc.mdl"
    
precache_sound("shmod/frieza_destructodisc.wav"
    
flash precache_model("sprites/muzzleflash2.spr")

//--------------------------------------------------------------------------------------- 
public Jacobi_init() 


    
//First Argument is the id of the player 
    
new temp[6]
    
read_argv(1,temp,5//Converts the string to a number 
    
new id str_to_num(temp//gets the id of the player

    //Second Argument is either 0 or 1 depending on whether the person has the hero or not 
    
read_argv(2,temp,5
    new 
hasPowers str_to_num(temp//Makes the string into a number 
    
g_hasJacobiPowers[id] = (hasPowers != 0//tells if player has power or not

    
if(hasPowers){
    
disk[id] = get_cvar_num("bass_laser_ammo")
        
diskTimer[id] = -
    
}

    if(!
hasPowers && diskTimer[id] > 0){ //When a player doesn't have power anymore
        
diskTimer[id] = -1
        
new FloatfOrigin[3]
    new 
origin[3]
    if(
is_valid_ent(disk[id])){
        
entity_get_vector(disk[id], EV_VEC_originfOrigin)
        
FVecIVec(fOriginorigin)
        
decay_effects(disk[id], origin)

    
// This gets run if they had the power but don't anymore
    
if ( hasPowers && is_user_connected(id))
          
Jacobi_admincheck(id);
        
gPlayerUltimateUsed[id] = false
        disk
[id] = get_cvar_num("Jacobi_disk_ammo")
    }

    }
    else if( !
hasPowers && g_hasJacobiPowers[id] && is_user_alive(id) ) {
        
shRemHealthPower(id)
        
shRemGravityPower(id)
        
shRemArmorPower(id)
        
shRemSpeedPower(id)


    } 


//--------------------------------------------------------------------------------------- 
public Jacobi_kd() 
{
    if ( !
hasRoundStarted() ) return

    
// 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 ( 
disk[id] == ) {
        
client_print(idprint_center"Cant Fire Disk")
        
playSoundDenySelect(id)
        return
    }

    if ( 
gPlayerUltimateUsed[id] ) {
        
playSoundDenySelect(id)
        return
    }

    
fire_disk(id)  // 1 immediate shot
    
if ( get_cvar_float("Jacobi_multishot") >= 0.0 ) {
        
set_task(get_cvar_float("Jacobi_multishot"), "fire_disk"id""0"b")  //delayed shots
    
}

    
gdiskFired[id] = true
}
//----------------------------------------------------------------------------------------------
public Jacobi_ku()
{
    
// First Argument is an id
    
new temp[6]
    
read_argv(1,temp,5)
    new 
id str_to_num(temp)

    
remove_task(id)

    if ( !
hasRoundStarted() || gPlayerUltimateUsed[id] || !gdiskFired[id] ) return

    
// Use the ultimate
    
if ( get_cvar_float("Jacobi_cooldown") > 0.0 ultimateTimer(idget_cvar_float("Jacobi_cooldown"))

    
gdiskFired[id] = false

//---------------------------------------------------------------------------------------- 
public newSpawn(id
{
    if ( 
shModActive() && g_hasJacobiPowers[id] && is_user_alive(id) ) {
        
remove_task(id)
        
gPlayerUltimateUsed[id] = false
        disk
[id] = get_cvar_num("Jacobi_disk_ammo")
        
gdiskFired[id] = false
    
}

//---------------------------------------------------------------------------------------- 
public Jacobi_kill()  //triggered everytime someone dies
{
    new 
id read_data(2)  //This tells who the victim is
    
if(g_hasJacobiPowers[id] && diskTimer[id] > 0){
        
diskTimer[id] = -1
        
new FloatfOrigin[3]
        new 
origin[3]
        
//gets current position of entity
        
entity_get_vector(disk[id], EV_VEC_originfOrigin)
        
//converts a floating vector into an integer vector
        
FVecIVec(fOriginorigin)
        
decay_effects(disk[id], origin)
    }
}
//----------------------------------------------------------------------------------------
public Jacobi_disklife(){ 
    for(new 
id 1id <= SH_MAXSLOTSid++){ 
        if(
g_hasJacobiPowers[id] && is_user_alive(id)){ 
            if(
diskTimer[id] > 0){ 
                
diskTimer[id]-- 
        new 
FloatfVelocity[3]
        
//gets the velocity by the direction you are looking at
        
velocity_by_aim(idget_cvar_num("frieza_diskspeed"), fVelocity)
        
//sets the new velocity
        
entity_set_vector(disk[id], EV_VEC_velocityfVelocity)
            } 
            else if(
diskTimer[id] == 0){
        new 
FloatfOrigin[3]
        new 
origin[3]
        
//gets the current position of entity
                
entity_get_vector(disk[id], EV_VEC_originfOrigin)
        
//converts a floating vector to an integer vector
        
FVecIVec(fOriginorigin)
        
decay_effects(disk[id], origin)
                
diskTimer[id]-- 
            } 
        } 
    } 

//----------------------------------------------------------------------------------------
public fire_disk(id
{   
//makes sure that the number of entities created does not exceed the maximum amount
    //of entities allowed
    
if(entity_count() == get_global_int(GL_maxEntities)){
    
client_print(idprint_chat"[SH] Cannot create more entities")
    return
    } 

    
//Makes an array of origin in the (x,y,z) coordinate system.
    
new origin[3]

    
//Makes an array of velocity, specifically in the (x,y,z) coordinate system 
    
new velocity[3

    new 
Float:fOrigin[3], Float:fVelocity[3]
    
get_user_origin(idorigin1)
    new 
FloatminBound[3] = {-50.0, -50.00.0}  //sets the minimum bound of entity
    
new FloatmaxBound[3] = {50.050.00.0}    //sets the maximum bound of entity
    
IVecFVec(originfOrigin)

    
//This will make it so that the disk appears in front of the user
    
new Float:viewing_angles[3]
    new 
distance_from_user 70
    entity_get_vector
(idEV_VEC_anglesviewing_angles)
    
fOrigin[0] += floatcos(viewing_angles[1], degrees) * distance_from_user
    fOrigin
[1] += floatsin(viewing_angles[1], degrees) * distance_from_user
    fOrigin
[2] += floatsin(-viewing_angles[0], degrees) * distance_from_user

    
new NewEnt create_entity("info_target")  //Makes an object 
    
entity_set_string(NewEntEV_SZ_classname"disk"//sets the classname of the entity
    
disk[id] = NewEnt

    
//This tells what the object will look like 
    
entity_set_model(NewEnt"models/shmod/jacobi_disc.mdl"

    
//This will set the origin of the entity 
    
entity_set_origin(NewEntfOrigin

    
//This will set the movetype of the entity 
    
entity_set_int(NewEnt,EV_INT_movetypeMOVETYPE_NOCLIP

    
//This makes the entity touchable
    
entity_set_int(NewEntEV_INT_solidSOLID_TRIGGER)

    
//This will set the velocity of the entity 
    
velocity_by_aim(idget_cvar_num("frieza_diskspeed"), fVelocity
    
FVecIVec(fVelocityvelocity//converts a floating vector to an integer vector

    //Sets the size of the entity
    
entity_set_size(NewEntminBoundmaxBound)

    
//Sets who the owner of the entity is
    
entity_set_edict(NewEntEV_ENT_ownerid)

    
//This will set the entity in motion 
    
entity_set_vector(NewEntEV_VEC_velocityfVelocity

    
//This will make the entity have sound.
    
emit_sound(NewEntCHAN_VOICE"shmod/frieza_destructodisc.wav"VOL_NORMATTN_NORM0PITCH_NORM)

    new 
lifetime get_cvar_num("Jacobi_disklife")

    
//This is the trail effects, to learn more about animation effects go to this link
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(22)       //TE_BEAMFOLLOW
    
write_short(NewEnt)  //The entity to attach the sprite to
    
write_short(flash)  //sprite's model
    
write_byte(lifetime)   //life in 0.1 seconds
    
write_byte(50)   //width of sprite
    
write_byte(255)  //red
    
write_byte(0)    //green
    
write_byte(255)  //blue
    
write_byte(255)  //brightness
    
message_end()

    return


//-----------------------------------------------------------------------------------------    
public touch_event(pToucherpTouched)  //This is triggered when two entites touch

    new 
aimvec[3], Float:fAimvec[3]  //This is the position where the disk collides 
    
entity_get_vector(pTouchedEV_VEC_originfAimvec
    
FVecIVec(fAimvecaimvec
    new 
self_immune get_cvar_num("frieza_disklife") - //Gives split-second immunity

    
if(pTouched == entity_get_edict(pToucherEV_ENT_owner) && diskTimer[pTouched] > self_immune)
    return 
PLUGIN_HANDLED
    
//Checks to see if entity is a player or an inanimate object. 
    
if(is_user_connected(pTouched)){
    
special_effects(pToucherpTouchedaimvec)
    return 
PLUGIN_CONTINUE
    
}

    
special_effects(pToucher0aimvec)

    return 
PLUGIN_CONTINUE 

//----------------------------------------------------------------------------------------- 
public special_effects(pToucherpTouchedaimvec[3]) //effects for when disk touch
{
    new 
Float:fVelocity[3]
    new 
velocity[3]
    new 
damage
    entity_get_vector
(pToucherEV_VEC_velocityfVelocity)
    
FVecIVec(fVelocityvelocity)

    
//Got to know who's the one using the disk
    //So that when the victim dies, he knows who's the killer
    //That used the disk
    
new killer entity_get_edict(pToucherEV_ENT_owner)

    
//To learn more about animation effects go to this link
    //http://shero.rocks-hideout.com/forums/viewtopic.php?t=1941
    
if(is_user_alive(pTouched)){
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(101)  //BLOODSTREAM
        
write_coord(aimvec[0])
        
write_coord(aimvec[1])
        
write_coord(aimvec[2])
        
write_coord(velocity[0])
        
write_coord(velocity[1])
        
write_coord(velocity[2])
        
write_byte(95)
        
write_byte(100)
        
message_end()

        
damage get_cvar_num("Jacobi_damage")
        new 
victim pTouched
        shExtraDamage
(victimkillerdamage"Jacobi's Energy Disk")
    }
    
//Same link for here to http://shero.rocks-hideout.com/forums/viewtopic.php?t=1941
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(9)  //SPARKS
    
write_coord(aimvec[0])
    
write_coord(aimvec[1])
    
write_coord(aimvec[2])
    
message_end()

}
//-----------------------------------------------------------------------------------------
public decay_effects(NewEntorigin[3])  //removes the entity plus adds a decaying effect
{
    if(
is_valid_ent(NewEnt)){
        
remove_entity(NewEnt)
        
//To learn more about animation effects go to this link
        //http://shero.rocks-hideout.com/forums/viewtopic.php?t=1941
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(14//IMPLOSION
        
write_coord(origin[0])
        
write_coord(origin[1])
        
write_coord(origin[2])
        
write_byte(50)
        
write_byte(10)
        
write_byte(10)
        
message_end()
    }
}
//------------------------------------------------------------------------------------------
public client_disconnect(id)  //This makes sure that the disk isn't flying after disconnect
{
    if(
g_hasJacobiPowers[id] && diskTimer[id] > 0){
        new 
FloatfOrigin[3]
        new 
origin[3]
        
entity_get_vector(disk[id], EV_VEC_originfOrigin)
        
FVecIVec(fOriginorigin)
        
decay_effects(disk[id], origin)
    }
}
//------------------------------------------------------------------------------------------
public Jacobi_death()
{
    new 
id read_data(2)

    if ( 
id <= || id SH_MAXSLOTS ) return

    
remove_task(id)
}
//----------------------------------------------------------------------------------------------
public Jacobi_admincheck(id)
{
    new 
accessLevel[10] = "b"
    
    
if (g_hasJacobiPowers[id] && !(get_user_flags(id)&read_flags(accessLevel)))
    {
        
client_print(idprint_chat"[SH] (%s) ***Admin Only*** You are not an admin!"gHeroName)
        
g_hasJacobiPowers[id] = false
        client_cmd
(id"say drop %s"gHeroName)
    }
}
//---------------------------------------------------------------------------------------------- 
andjak123 is offline