Raised This Month: $ Target: $400
 0% 

Correct this code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 09-27-2009 , 14:05   Correct this code
Reply With Quote #1

can you correct this code cuz im at scripting i now some examples but i need you're help to know for sure what iam doing bad and what iam doing good.

The zombies are Terrorist team if i missed a tam zombie or zombie team pls correct .

It's not finished code.

Code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>
#include <fun>
#include <fakemeta>

#define PLUGIN "Swarm Extension"
#define VERSION "1.0"
#define AUTHOR "DoviuX"

//Sounds
//Hunter
new g_sndleap[] = "Swarm/Hunter/Hunter_Leap.wav"
new const HuntHit[][]= 
{    
    
"Swarm/Hunter/Hit/Hit1.wav",
    
"Swarm/Hunter/Hit/Hit2.wav",
    
"Swarm/Hunter/Hit/Hit3.wav"
}
new const 
HuntMiss[][]= 
{    
    
"Swarm/Hunter/Miss/Miss1.wav",
    
"Swarm/Hunter/Miss/Miss2.wav",
    
"Swarm/Hunter/Miss/Miss3.wav"
}
new const 
HuntDie[][]= 
{    
    
"Swarm/Hunter/Die/Die1.wav",
    
"Swarm/Hunter/Die/Die2.wav",
    
"Swarm/Hunter/Die/Die3.wav"
}
new const 
HuntPain[][]= 
{    
    
"Swarm/Hunter/Pain/Pain1.wav",
    
"Swarm/Hunter/Pain/Pain2.wav",
    
"Swarm/Hunter/Pain/Pain3.wav"
}

//Smoker
new g_sndMiss[] = "Swarm/Smoker/TongueHit_miss.wav"
new g_sndDrag[] = "Swarm/Smoker/TongueHit_drag.wav"
new g_sndamb[] = "Swarm/Smoker/Draging_Ambience.wav"
new const SmokHit[][]= 
{    
    
"Swarm/Smoker/Hit/Hit1.wav",
    
"Swarm/Smoker/Hit/Hit2.wav",
    
"Swarm/Smoker/Hit/Hit3.wav"
}
new const 
SmokMiss[][]= 
{    
    
"Swarm/Smoker/Miss/Miss1.wav",
    
"Swarm/Smoker/Miss/Miss2.wav",
    
"Swarm/Smoker/Miss/Miss3.wav"
}
new const 
SmokDie[][]= 
{    
    
"Swarm/Smoker/Die/Die1.wav",
    
"Swarm/Smoker/Die/Die2.wav",
    
"Swarm/Smoker/Die/Die3.wav"
}
new const 
SmokPain[][]= 
{    
    
"Swarm/Smoker/Pain/Pain1.wav",
    
"Swarm/Smoker/Pain/Pain2.wav",
    
"Swarm/Smoker/Pain/Pain3.wav"
}

//Boomer
new const BoomHit[][]= 
{    
    
"Swarm/Boomer/Hit/Hit1.wav",
    
"Swarm/Boomer/Hit/Hit2.wav",
    
"Swarm/Boomer/Hit/Hit3.wav"
}
new const 
BoomMiss[][]= 
{    
    
"Swarm/Boomer/Miss/Miss1.wav",
    
"Swarm/Boomer/Miss/Miss2.wav",
    
"Swarm/Boomer/Miss/Miss3.wav"
}
new const 
BoomDie[][]= 
{    
    
"Swarm/Boomer/Die/Die1.wav",
    
"Swarm/Boomer/Die/Die2.wav",
    
"Swarm/Boomer/Die/Die3.wav"
}
new const 
BoomPain[][]= 
{    
    
"Swarm/Boomer/Pain/Pain1.wav",
    
"Swarm/Boomer/Pain/Pain2.wav",
    
"Swarm/Boomer/Pain/Pain3.wav"
}

//Tank
new const TankHit[][]= 
{    
    
"Swarm/Tank/Hit/Hit1.wav",
    
"Swarm/Tank/Hit/Hit2.wav",
    
"Swarm/Tank/Hit/Hit3.wav"
}
new const 
TankMiss[][]= 
{    
    
"Swarm/Tank/Miss/Miss1.wav",
    
"Swarm/Tank/Miss/Miss2.wav",
    
"Swarm/Tank/Miss/Miss3.wav"
}
new const 
TankDie[][]= 
{    
    
"Swarm/Tank/Die/Die1.wav",
    
"Swarm/Tank/Die/Die2.wav",
    
"Swarm/Tank/Die/Die3.wav"
}
new const 
TankPain[][]= 
{    
    
"Swarm/Tank/Pain/Pain1.wav",
    
"Swarm/Tank/Pain/Pain2.wav",
    
"Swarm/Tank/Pain/Pain3.wav"
}
/// Bool class
new bool:is_Hunter[33]
new 
bool:is_Smoker[33]
new 
bool:is_Boomer[33]
new 
bool:is_Tank[33]

/// Hunter
new hunter_health
new hunter_gravity 
new hunter_speed
new hunter_zclass_LongJumphunter_LongJump_forcehunter_LongJump_heightcvar_cooldown
new Float:hunter_lastleaptime[33// time leap was last used 

/// Smoker
new smoker_health
new smoker_gravity 
new smoker_speed
new g_hooked[33], g_hooksLeft[33]
new 
g_zombie[33]
new 
Float:g_lastHook[33]
new 
cvar_maxdrags
cvar_dragspeed
cvar_cooldown
cvar_dmg2stop 
cvar_mates 
cvar_bind
new g_zclass_smokerg_Line

/// Boomer
new boomer_health
new boomer_gravity 
new boomer_speed 

/// Tank
new tank_health
new tank_gravity 
new tank_speed 

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
/// FCVAR
    
register_cvar("L4D Infected Class v.%s"VERSIONFCVAR_SERVER)
    
    
    
/// Register Ham_Spawn
    
RegisterHam(Ham_Spawn"player""fwdPlayer_Spawn"1)
    
    
/// Register Forwards 
    
register_forward(FM_PlayerPreThink"cmdHunter")
    
register_forward(FM_PlayerPreThink"cmdSmoker")
    
register_forward(FM_PlayerPreThink"cmdBoomer")
    
register_forward(FM_PlayerPreThink"cmdTank")
    
    
/// Hunter
    
hunter_health register_cvar("hunter_health""600")
    
hunter_gravity register_cvar("hunter_gravity ""0.7")
    
hunter_speed register_cvar("hunter_speed""270")
    
hunter_LongJump_force register_cvar("hunter_leap_force""525")
    
hunter_LongJump_height register_cvar("hunter_leap_height""345")
    
cvar_cooldown register_cvar("hunter_leap_cooldown""1.5")
    
    
/// Smoker
    
smoker_health register_cvar("smoker_health""700")
    
smoker_gravity register_cvar("smoker_gravity ""0.9")
    
smoker_speed register_cvar("smoker_speed""255")
    
cvar_dragspeed register_cvar("smoker_dragspeed""160")
    
cvar_maxdrags register_cvar("smoker_maxdrags""20")
    
cvar_cooldown register_cvar("smoker_cooldown""0.0")
    
cvar_dmg2stop register_cvar("smoker_dmg2stop""200")
    
cvar_mates register_cvar("smoker_mates""0")
    
register_clcmd("+drag","drag_start"ADMIN_USER"bind ^"key^" ^"+drag^"")
    
register_clcmd("-drag","drag_end")
    
    
/// Boomer
    
boomer_health register_cvar("boomer_health""300")
    
boomer_gravity register_cvar("boomer_gravity ""0.7")
    
boomer_speed register_cvar("boomer_speed""245")
    
    
/// Tank
    
tank_health register_cvar("tank_health""3000")
    
tank_gravity register_cvar("tank_gravity  ""0.8")
    
tank_speed register_cvar("tank_speed""260")
    
}

public 
plugin_precache() 
{    
    
precache_model("models/player/Hunter/Hunter.mdl")
    
precache_model("models/player/Smoker/Smoker.mdl")
    
precache_model("models/player/Boomer/Boomer.mdl"
    
precache_model("models/player/Tank/Tank.mdl"
    
precache_sound(g_sndDrag)
    
precache_sound(g_sndMiss)
    
g_Line precache_model("sprites/zbeam4.spr")     
    
    return 
PLUGIN_CONTINUE
}

public 
fwdPlayer_Spawn(id)
{
    
is_Hunter[id] = false;
    
is_Smoker[id] = false;
    
is_Boomer[id] = false;
    
is_Tank[id] = false;
}

public 
cmdHunter(identity)
{
    if(
TEAM_T && is_user_alive(id) && is_Hunter[id] == true)
    {   
    if (!
is_user_alive(id))
        return
        
    if (
allowed_LongJump(id))
    {
        static 
Float:velocity[3]
        
velocity_by_aim(idget_pcvar_num(hunter_LongJump_force), velocity)
        
        
velocity[2] = get_pcvar_float(hunter_LongJump_height)
        
        
set_pev(idpev_velocityvelocity)

        
// Set the current leap time
        
g_lastleaptime[id] = get_gametime()
    
        
set_user_health(idget_pcvar_num(hunter_health))
        
set_user_gravity(idget_pcvar_float(hunter_gravity))
        
set_user_maxspeed(idget_pcvar_float(hunter_speed))
        
cs_set_user_model(id"Hunter")
         
    if (!((
pev(idpev_flags) & FL_ONGROUND) && (pev(idpev_flags) & FL_DUCKING)) || fm_get_speed(id) < 10)
        return 
false
    
    
static buttons
    buttons 
pev(idpev_button)
    
    
// Not doing a longjump (added bot support)
    
if (!(buttons IN_ATTACK) && !is_user_bot(id))
        return 
false

    
// Get cooldown cvar
    
static Float:cooldown
    cooldown 
get_pcvar_float(cvar_cooldown)

    
// Cooldown not over yet
    
if (get_gametime() - hunter_lastleaptime[id] < cooldown)
        return 
false
        
    
static Float:velocity[3]
    
pev(entitypev_velocityvelocity)
    
    return 
floatround(vector_length(velocity));

    return 
true
    
}
}

public 
cmdSmoker(id)
{
    if(
TEAM_T && is_user_alive(id) && is_Smoker[id] == true)
    {
        
set_user_health(idget_pcvar_num(smoker_health))
        
set_user_gravity(idget_pcvar_float(smoker_gravity))
        
set_user_maxspeed(idget_pcvar_float(smoker_speed))
        
cs_set_user_model(id"Smoker")

    
g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
    
g_lastHook[id] = get_gametime()
    
    if (
g_hooked[id])
        
drag_end(id)

    if(
TEAM_T && is_user_alive(id) && is_Smoker[id] == true) {
        
        static 
Float:cdown
        cdown 
get_pcvar_float(cvar_cooldown)
            
        if (!
is_user_alive(id)) {
            
client_print(idprint_chat"You can't drag if you are dead!")
            return
        }

        if (
g_hooksLeft[id] <= 0) {
            
client_print(idprint_chat"You can't drag anymore!")
            return
        }
            
        if (
get_gametime() - g_lastHook[id] < cdown) {
            
client_print(idprint_chat"Wait %.fsec to drag again!"get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
            return
        }

        if (
g_hooksLeft[id] > 0) {
            
g_hooksLeft[id]--
            
client_print(idprint_chat"You can drag player to youself %d time%s"g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" "s")
        }

        new 
hooktargetbody

        get_user_aiming
(idhooktargetbody)

        if (
is_user_alive(hooktarget)) {
            if (
get_user_team(hooktarget) != get_user_team(id)) {
                
g_hooked[id] = hooktarget
                emit_sound
(hooktargetCHAN_BODYg_sndDrag1.0ATTN_NORM0PITCH_HIGH)
            } else {
                
/*if (get_user_team(hooktarget) == get_user_team(id)) {
                    if (get_pcvar_num(cvar_mates) == 1) {*/
    //if (get_user_team(hooktarget) == get_user_team(id)) {
                  
if (get_user_team(hooktarget) == g_zombie[id]) {
                    if (
get_pcvar_num(cvar_mates) == 1) { // If is 1 , hook!
                        
g_hooked[id] = hooktarget
                        emit_sound
(hooktargetCHAN_BODYg_sndDrag1.0ATTN_NORM0PITCH_HIGH)
                        
//emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                       
if (get_pcvar_num(cvar_mates) == 0) { // If is 0 , hook , but missed!
                        
g_hooked[id] = hooktarget
                        emit_sound
(hooktargetCHAN_BODYg_sndMiss1.0ATTN_NORM0PITCH_HIGH
                    }
                        } else {
                        
                        
g_hooked[id] = 33
                        noTarget
(id)
                        
emit_sound(hooktargetCHAN_BODYg_sndMiss1.0ATTN_NORM0PITCH_HIGH)
                        return
                    }
                    } else {
                    
g_hooked[id] = 33
                    noTarget
(id)
                    
emit_sound(hooktargetCHAN_BODYg_sndMiss1.0ATTN_NORM0PITCH_HIGH)
                    return
                }
            }

            new 
parm[2]
            
parm[0] = id
            parm
[1] = hooktarget
            
            set_task
(0.1"smoker_reelin"idparm2"b")
            
harpoon_target(parm)
        } else {
            
g_hooked[id] = 33
            noTarget
(id)
            
emit_sound(hooktargetCHAN_BODYg_sndMiss1.0ATTN_NORM0PITCH_HIGH)
        }
    } else {
        return
    }
    new 
id parm[0]
    new 
victim parm[1]

    if (!
g_hooked[id])
        return

    if (!
is_user_alive(victim)) {
        
drag_end(id)
        return
    }

    new 
Float:fl_Velocity[3]
    new 
idOrigin[3], vicOrigin[3]
    
emit_sound(idCHAN_BODYg_sndamb1.0ATTN_NORM0PITCH_HIGH)

    
get_user_origin(victimvicOrigin)
    
get_user_origin(ididOrigin)

    new 
distance get_distance(idOriginvicOrigin)

    if (
distance 1) {
        new 
Float:fl_Time distance get_pcvar_float(cvar_dragspeed)

        
fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
        fl_Velocity
[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
        fl_Velocity
[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
    
} else {
        
fl_Velocity[0] = 0.0
        fl_Velocity
[1] = 0.0
        fl_Velocity
[2] = 0.0
    
}

    
entity_set_vector(victimEV_VEC_velocityfl_Velocity//<- rewritten. now uses engine

    
g_hooked[id] = 0
    beam_remove
(id)
    
remove_task(id)
    
    if (
get_gametime() - g_lastHook[id] <= get_pcvar_float(cvar_cooldown)) {
        return
    } else {
        
g_lastHook[id] = get_gametime()

    new 
id read_data(2)
    if (
g_hooked[id])
        
drag_end(id)

    if (
victim == attacker || !is_user_connected(attacker)) {
        if (
damage 25) {
            
drag_end(victim)
            return 
HAM_IGNORED;
        }
    }
    
    if (
get_user_team(attacker) != get_user_team(victim)) {
        if (
damage get_pcvar_num(cvar_dmg2stop)) {
            
drag_end(victim)
            return 
HAM_IGNORED;
        }
    }
    
    return 
HAM_IGNORED;

    if (
id <= || id 32)
        return
    
    if (
g_hooked[id])
        
drag_end(id)

    new 
id parm[0]
    new 
hooktarget parm[1]

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(8)    // TE_BEAMENTS
    
write_short(id)
    
write_short(hooktarget)
    
write_short(g_Line)    // sprite index
    
write_byte(0)    // start frame
    
write_byte(0)    // framerate
    
write_byte(200)    // life
    
write_byte(8)    // width
    
write_byte(1)    // noise
    
write_byte(155)    // r, g, b
    
write_byte(155)    // r, g, b
    
write_byte(55)    // r, g, b
    
write_byte(90)    // brightness
    
write_byte(10)    // speed
    
message_end()

    new 
endorigin[3]

    
get_user_origin(idendorigin3)

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byteTE_BEAMENTPOINT ); // TE_BEAMENTPOINT
    
write_short(id)
    
write_coord(endorigin[0])
    
write_coord(endorigin[1])
    
write_coord(endorigin[2])
    
write_short(g_Line// sprite index
    
write_byte(0)    // start frame
    
write_byte(0)    // framerate
    
write_byte(200)    // life
    
write_byte(8)    // width
    
write_byte(1)    // noise
    
write_byte(155)    // r, g, b
    
write_byte(155)    // r, g, b
    
write_byte(55)    // r, g, b
    
write_byte(75)    // brightness
    
write_byte(0)    // speed
    
message_end()

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(99)    //TE_KILLBEAM
    
write_short(id)    //entity
    
message_end()
}

public 
cmdBoomer(id)
{
    if(
TEAM_T && is_user_alive(id) && is_Boomer[id] == true)
    {
        
set_user_health(idget_pcvar_num(boomer_health))
        
set_user_gravity(idget_pcvar_float(boomer_gravity))
        
set_user_maxspeed(idget_pcvar_float(boomer_speed))
        
cs_set_user_model(id"Boomer")
    }
}

public 
cmdTank(id)
{
    if(
TEAM_T && is_user_alive(id) && is_Tank[id] == true)
    {
        
set_user_health(idget_pcvar_num(tank_health))
        
set_user_gravity(idget_pcvar_float(tank_gravity))
        
set_user_maxspeed(idget_pcvar_float(tank_speed))
        
cs_set_user_model(id"Tank")
    }
}

public 
client_connect(id)
{
    
is_Hunter[id] = false;
    
is_Smoker[id] = false;
    
is_Boomer[id] = false;
    
is_Tank[id] = false;


Last edited by DoviuX; 09-27-2009 at 14:10.
DoviuX is offline
Send a message via Skype™ to DoviuX
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-27-2009 , 14:12   Re: Correct this code
Reply With Quote #2

do you know prethink is called a hundred times per second ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 09-27-2009 , 14:14   Re: Correct this code
Reply With Quote #3

no , not really
DoviuX is offline
Send a message via Skype™ to DoviuX
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode