Raised This Month: $32 Target: $400
 8% 

Freeze doesnt apply


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 03-29-2021 , 13:47   Freeze doesnt apply
Reply With Quote #1

Hello. I have a problem with my plugin. I have applied when a player holds E(+USE) he freezes and when he releases he unfreezes. but my code doesnt work.. anyone knows how to fix this?
Heres some code for just understanding what i mean...
PHP Code:
new g_nomove[33]
public 
fw_PlayerPreThink(id)
{    
    if (
g_nomove[id])
    {
        
set_pev(idpev_maxspeed1.0)
    }
    
    return 
PLUGIN_CONTINUE
}

public 
freeze_starts_here_on_pressing_e(id)
{
    
g_nomove[id] = true// this is where i want it to work but it doesnt


Last edited by HowToRuski; 03-29-2021 at 13:51.
HowToRuski is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-29-2021 , 14:21   Re: Freeze doesnt apply
Reply With Quote #2

Where is the code that detects pressing E?
Also, setting maxspeed to 1 is not a good way of freezeing someone.

Code:
set_player_freeze(id, bool:bFreeze) {     if(bFreeze)     {         set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)     }     else     {         set_pev(id, pev_flags, pev(id, pev_flags) &~ FL_FROZEN)     } }
__________________

Last edited by OciXCrom; 03-29-2021 at 14:21.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-29-2021 , 15:13   Re: Freeze doesnt apply
Reply With Quote #3

If you want to freeze the user set his maxspeed to -1

https://forums.alliedmods.net/showpo...42&postcount=9
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-29-2021 at 15:16.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-29-2021 , 15:23   Re: Freeze doesnt apply
Reply With Quote #4

No point in modifying speed + having to do so whenever he switches weapons when there's a built-in mechanic for freezeing players that does this automatically + prevents jumping + prevents shooting.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 03-30-2021 , 01:01   Re: Freeze doesnt apply
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
Where is the code that detects pressing E?
Also, setting maxspeed to 1 is not a good way of freezeing someone.

Code:
set_player_freeze(id, bool:bFreeze) {     if(bFreeze)     {         set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)     }     else     {         set_pev(id, pev_flags, pev(id, pev_flags) &~ FL_FROZEN)     } }
Your code looks a bit confusing for a beginner like me... Anything similar to mine there is? Anything why it doesnt work...
HowToRuski is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-30-2021 , 15:34   Re: Freeze doesnt apply
Reply With Quote #6

Simply copy/paste that somewhere in your code and when you want to freeze a player just do:

Code:
set_user_freeze(id, true)

To unfreeze:

Code:
set_user_freeze(id, false)
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-30-2021 , 16:02   Re: Freeze doesnt apply
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
No point in modifying speed + having to do so whenever he switches weapons when there's a built-in mechanic for freezeing players that does this automatically + prevents jumping + prevents shooting.
yup its true...

but it depends on what the author wants in the end, etc...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-30-2021 at 16:02.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 03-30-2021 , 18:31   Re: Freeze doesnt apply
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
yup its true...

but it depends on what the author wants in the end, etc...
He wants the prevent the player from moving. Setting the flag is the best workaround, setting the speed then hooking curweapon or think to prevent from resetting costs more performance and is redundant in-general.
redivcram is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-04-2021 , 03:55   Re: Freeze doesnt apply
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
Simply copy/paste that somewhere in your code and when you want to freeze a player just do:

Code:
set_user_freeze(id, true)

To unfreeze:

Code:
set_user_freeze(id, false)
For me its not working...
I will leave the code here....
PHP Code:
#include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <hamsandwich>
#include <engine>

#define PLUGIN "[ZP] Extra Drag"
#define VERSION "1.1"
#define AUTHOR "4eRT"

//Some vars
new const g_extra_drag[] = { "Hook" 
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], g_over_dmg[33]
new 
Float:g_lastHook[33]
new 
g_Lineg_item_drag
new cvar_enabledcvar_costcvar_maxdragscvar_dragspeedcvar_cooldowncvar_dmgtostopcvar_matescvar_extrahookcvar_nemesiscvar_survivorcvar_reset
new boolg_has_drag[33], boolg_drag_i[33]

public 
plugin_init()
{
    
cvar_enabled register_cvar("zp_extra_drag""1")
    
cvar_cost register_cvar("zp_extra_drag_cost""5")
    
cvar_dragspeed register_cvar("zp_extra_drag_dragspeed""160")
    
cvar_maxdrags register_cvar("zp_extra_drag_maxdrags""2")
    
cvar_cooldown register_cvar("zp_extra_drag_cooldown""5")
    
cvar_dmgtostop register_cvar("zp_extra_drag_dmg2stop""30")
    
cvar_mates register_cvar("zp_extra_drag_mates""0")
    
cvar_extrahook register_cvar("zp_extra_drag_extrahook""0")
    
cvar_nemesis register_cvar("zp_extra_drag_nemesis""0")
    
cvar_survivor register_cvar("zp_extra_drag_survivor""1")
    
cvar_reset register_cvar("zp_extra_drag_reset""0")
    
register_event("HLTV""newSpawn""a""1=0""2=0")
    
register_event("DeathMsg""player_death""a")
    
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_clcmd("-drag","drag_end")
    
g_item_drag zp_register_extra_item(g_extra_dragget_pcvar_num(cvar_cost), ZP_TEAM_ZOMBIE)
}

public 
plugin_precache()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
precache_sound(g_sndDrag)
    
precache_sound(g_sndMiss)
    
g_Line precache_model("sprites/zbeam4.spr")
}

public 
zp_extra_item_selected(iditem)
{
    if (
item == g_item_drag)
    {
        if(
is_user_alive(id) && get_pcvar_num(cvar_enabled) == 1)
        {
            
g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
            
g_has_drag[id] = true
            client_print
(idprint_chat"You bought Hook. Press E to drag")
        } else
            return
    }
}

set_user_freeze(idbool:bFreeze)
{
    if(
bFreeze)
    {
        
set_pev(idpev_flagspev(idpev_flags) | FL_FROZEN
    }
    else
    {
        
set_pev(idpev_flagspev(idpev_flags) &~ FL_FROZEN
    }
}

public 
zp_user_infected_post(idinfector)
    if(
g_has_drag[infector])
        
g_hooksLeft[infector] = g_hooksLeft[infector] + get_pcvar_num(cvar_extrahook)

public 
zp_user_humanized_post(id)
    if(
get_pcvar_num(cvar_reset) == 1)
        
g_has_drag[id] = false

public newSpawn()
{
    for (new 
id 1id <= 32id++)
    {
        if (
g_hooked[id])
            
drag_end(id)
    
        
g_has_drag[id] = false
    
}
}

public 
player_death()
{
    new 
attacker read_data(1)
    new 
id read_data(2)
    
    if (
g_hooked[attacker])
        
drag_end(id)
    
    
g_has_drag[id] = false
}

public 
client_connect(id)
    
g_has_drag[id] = false

public client_disconnect(id)
{
    if (
g_hooked[id])
        
drag_end(id)
    
    
set_user_freeze(idfalse)
    
    
g_has_drag[id] = false
}

public 
drag_start(id)
{        
    if (
zp_get_user_zombie(id) && g_has_drag[id] && !g_drag_i[id]) {
        
        static 
Float:cdown
        cdown 
get_pcvar_float(cvar_cooldown)

        if (!
is_user_alive(id)) {
            
//client_print(id, print_chat, "[ZP] You can't drag if you are dead!")
            
return PLUGIN_HANDLED
        
}

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

        if (
get_gametime() - g_lastHook[id] < cdown) {
            
client_print(idprint_chat"[ZP] Wait %.f sec. to drag again!"get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
            return 
PLUGIN_HANDLED
        
}
        
        if (
zp_is_nemesis_round() && get_pcvar_num(cvar_nemesis) == 0) {
            
client_print(idprint_chat"[ZP] You can't drag in Nemesis mode!")
            return 
PLUGIN_HANDLED
        
}

        new 
hooktargetbody
        get_user_aiming
(idhooktargetbody)
        
        if (
is_user_alive(hooktarget)) {
            if (!
zp_get_user_zombie(hooktarget))
                {
                    if (
zp_get_user_survivor(hooktarget) && get_pcvar_num(cvar_survivor) == 0) {
                        
client_print(idprint_chat"[ZP] You can't drag Survivor!")
                        return 
PLUGIN_HANDLED
                    
}
                    
                    
g_hooked[id] = hooktarget
                    emit_sound
(hooktargetCHAN_BODYg_sndDrag1.0ATTN_NORM0PITCH_HIGH)
                }
            else
                {
                    if (
get_pcvar_num(cvar_mates) == 1)
                    {
                        
g_hooked[id] = hooktarget
                        emit_sound
(hooktargetCHAN_BODYg_sndDrag1.0ATTN_NORM0PITCH_HIGH)
                    }
                    else
                    {
                        
client_print(idprint_chat"[ZP] You can't drag teammates!")
                        return 
PLUGIN_HANDLED
                    
}
                }

            if (
get_pcvar_float(cvar_dragspeed) <= 0.0)
                
cvar_dragspeed 1
            
            
new parm[2]
            
parm[0] = id
            parm
[1] = hooktarget
            
            set_task
(0.1"reelin_player"idparm2"b")
            
harpoon_target(parm)
            
            
g_hooksLeft[id]--
            
client_print(idprint_chat"[ZP] You can drag player to youself %d time%s"g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" "s")
            
g_drag_i[id] = true
            set_user_freeze
(idtrue)
        } else {
            
g_hooked[id] = 33
            noTarget
(id)
            
emit_sound(hooktargetCHAN_BODYg_sndMiss1.0ATTN_NORM0PITCH_HIGH)
            
g_drag_i[id] = true
            g_hooksLeft
[id]--
            
set_user_freeze(idtrue)
            
client_print(idprint_chat"[ZP] You can drag player to youself %d time%s"g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" "s")
        }
    }
    else
        return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE
}

public 
reelin_player(parm[])
{
    new 
id parm[0]
    new 
victim parm[1]

    if (!
g_hooked[id] || !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)
}

public 
drag_end(id)
{
    
g_hooked[id] = 0
    beam_remove
(id)
    
remove_task(id)
    
    if (
g_drag_i[id])
        
g_lastHook[id] = get_gametime()
    
    
g_drag_i[id] = false
    set_user_freeze
(idfalse)
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if (
is_user_alive(attacker) && (get_pcvar_num(cvar_dmgtostop) > 0))
    {
        
g_over_dmg[victim] = g_over_dmg[victim] + floatround(damage)
        if (
g_over_dmg[victim] >= get_pcvar_num(cvar_dmgtostop))
        {
            
g_over_dmg[victim] = 0
            drag_end
(victim)
            return 
HAM_IGNORED;
        }
    }

    return 
HAM_IGNORED;
}

public 
fw_PlayerPreThink(id)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED
    
    
new button get_user_button(id)
    new 
oldbutton get_user_oldbutton(id)
    
    if (
zp_get_user_zombie(id) && g_has_drag[id])
    {
        if (!(
oldbutton IN_USE) && (button IN_USE))
            
drag_start(id)
        
        if ((
oldbutton IN_USE) && !(button IN_USE))
            
drag_end(id)
    }
    
    
set_user_freeze(idfalse)
    
    return 
PLUGIN_CONTINUE
}

public 
harpoon_target(parm[])
{
    new 
id parm[0]
    new 
hooktarget parm[1]

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(8)
    
write_short(id)
    
write_short(hooktarget)
    
write_short(g_Line)
    
write_byte(0)
    
write_byte(0)
    
write_byte(200)
    
write_byte(8)
    
write_byte(1)
    
write_byte(155)    // r, g, b
    
write_byte(155)    // r, g, b
    
write_byte(55)
    
write_byte(90)
    
write_byte(10)
    
message_end()
}

public 
noTarget(id)
{
    new 
endorigin[3]

    
get_user_origin(idendorigin3)

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byteTE_BEAMENTPOINT );
    
write_short(id)
    
write_coord(endorigin[0])
    
write_coord(endorigin[1])
    
write_coord(endorigin[2])
    
write_short(g_Line)
    
write_byte(0)
    
write_byte(0)
    
write_byte(200)
    
write_byte(8)
    
write_byte(1)
    
write_byte(155)    // r, g, b
    
write_byte(155)    // r, g, b
    
write_byte(55)
    
write_byte(75)
    
write_byte(0)
    
message_end()
}

public 
beam_remove(id)
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(99)
    
write_short(id)
    
message_end()


Last edited by HowToRuski; 04-04-2021 at 03:57.
HowToRuski is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-05-2021 , 04:10   Re: Freeze doesnt apply
Reply With Quote #10

Anyone? Still looking for fix...
HowToRuski is offline
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 00:18.


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