AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need drag code (https://forums.alliedmods.net/showthread.php?t=94076)

~Ice*shOt 06-06-2009 04:01

Need drag code
 
what can I write and print only the even code? It is to ask for only the drag and the print:

PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#define PLUGIN "[ZP] Class Smoker"
#define VERSION "0.3"
#define AUTHOR "4eRT"
new g_Line
new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
new g_hooked[33], g_hooksLeft[33]
new 
g_zombie[33]
new 
Float:g_lastHook[33]
new 
cvar_maxdragscvar_dragspeedcvar_cooldowncvar_dmg2stopcvar_matescvar_bind
public plugin_init()
{
cvar_dragspeed register_cvar("zp_smoker_dragspeed""160")
cvar_maxdrags register_cvar("zp_smoker_maxdrags""10")
cvar_cooldown register_cvar("zp_smoker_cooldown""5.0")
cvar_dmg2stop register_cvar("zp_smoker_dmg2stop""200")
cvar_mates register_cvar("zp_smoker_mates""0")
cvar_bind register_cvar("zp_smoker_bind""1")
register_event("ResetHUD""newSpawn""b")
register_event("DeathMsg""smoker_death""a")
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
register_clcmd("+drag","drag_start"ADMIN_USER"bind ^"key^" ^"+drag^"")
register_clcmd("-drag","drag_end")
}
public 
plugin_precache()
{
register_plugin(PLUGINVERSIONAUTHOR)
precache_sound(g_sndDrag)
precache_sound(g_sndMiss)
g_Line precache_model("sprites/zbeam4.spr")
}
public 
newSpawn(id)
{
g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
g_lastHook[id] = get_gametime()

if (
g_hooked[id])
drag_end(id)
}
public 
drag_start(id
{
if (
zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_smoker) {

static 
Float:cdown
cdown 
get_pcvar_float(cvar_cooldown)

if (!
is_user_alive(id)) {
client_print(idprint_chat"[ZP] You can't drag if you are dead!")
return
}
if (
g_hooksLeft[id] <= 0) {
client_print(idprint_chat"[ZP] You can't drag anymore!")
return
}
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
}
}
public 
smoker_reelin(parm[]) // dragging player to smoker
{
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]
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
}
public 
drag_end(id// drags end function
{
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()
}
}
public 
smoker_death() // if smoker dies drag off
{
new 
id read_data(2)
if (
g_hooked[id])
drag_end(id)
}
public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type// if take damage drag off
{
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;
}
public 
client_disconnect(id// if client disconnects drag off
{
if (
id <= || id 32)
return

if (
g_hooked[id])
drag_end(id)
}
public 
harpoon_target(parm[]) // set beam (ex. tongue:) if target is player
{
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()
}
public 
noTarget(id// set beam if target isn't player
{
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()
}
public 
beam_remove(id// remove beam
{
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
write_byte(99//TE_KILLBEAM
write_short(id//entity
message_end()



Arkshine 06-06-2009 04:09

Re: Need drag code
 
"Need speak english".

~Ice*shOt 06-06-2009 04:56

Re: Need drag code
 
i please code..

Arkshine 06-06-2009 05:00

Re: Need drag code
 
- LEARN TO SPEAK ENGLISH PROPERLY AT LAST WE CAN UNDERSTAND.
- INDENT YOUR CODE.

If you don't want to do efforts, stop to post here.

~Ice*shOt 06-06-2009 05:23

Re: Need drag code
 
PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <hamsandwich>
#include <engine>

#define PLUGIN "[ZP] Class Smoker"
#define VERSION "0.3"
#define AUTHOR "4eRT"

new g_Line

new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"

new g_hooked[33], g_hooksLeft[33]
new 
g_zombie[33]
new 
Float:g_lastHook[33]

new 
cvar_maxdragscvar_dragspeedcvar_cooldowncvar_dmg2stopcvar_matescvar_bind

public plugin_init()
{
    
cvar_dragspeed register_cvar("zp_smoker_dragspeed""160")
    
cvar_maxdrags register_cvar("zp_smoker_maxdrags""10")
    
cvar_cooldown register_cvar("zp_smoker_cooldown""5.0")
    
cvar_dmg2stop register_cvar("zp_smoker_dmg2stop""200")
    
cvar_mates register_cvar("zp_smoker_mates""0")
    
cvar_bind register_cvar("zp_smoker_bind""1")
    
register_event("ResetHUD""newSpawn""b")
    
register_event("DeathMsg""smoker_death""a")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_clcmd("+drag","drag_start"ADMIN_USER"bind ^"key^" ^"+drag^"")
    
register_clcmd("-drag","drag_end")
}
public 
plugin_precache()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
precache_sound(g_sndDrag)
    
precache_sound(g_sndMiss)
    
g_Line precache_model("sprites/zbeam4.spr")
}

public 
newSpawn(id)
{
    
g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
    
g_lastHook[id] = get_gametime()
    
    if (
g_hooked[id])
        
drag_end(id)
}

public 
drag_start(id
{
    if (
zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_smoker) {
        
        static 
Float:cdown
        cdown 
get_pcvar_float(cvar_cooldown)
            
        if (!
is_user_alive(id)) {
            
client_print(idprint_chat"[ZP] You can't drag if you are dead!")
            return
        }

        if (
g_hooksLeft[id] <= 0) {
            
client_print(idprint_chat"[ZP] You can't drag anymore!")
            return
        }

        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
    }
}

public 
smoker_reelin(parm[]) // dragging player to smoker
{
    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]

    
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
}

public 
drag_end(id// drags end function
{
    
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()
    }
}

public 
smoker_death() // if smoker dies drag off
{
    new 
id read_data(2)
    if (
g_hooked[id])
        
drag_end(id)
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type// if take damage drag off
{
    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;
}

public 
client_disconnect(id// if client disconnects drag off
{
    if (
id <= || id 32)
        return
    
    if (
g_hooked[id])
        
drag_end(id)
}

public 
harpoon_target(parm[]) // set beam (ex. tongue:) if target is player
{
    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()
}

public 
noTarget(id// set beam if target isn't player
{
    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()
}

public 
beam_remove(id// remove beam
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(99)    //TE_KILLBEAM
    
write_short(id)    //entity
    
message_end()



padilha007 06-06-2009 07:22

Re: Need drag code
 
lol kkkk


All times are GMT -4. The time now is 13:48.

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