This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Duration & Cooldown


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hn.S Xmix
Member
Join Date: May 2021
Old 05-03-2024 , 10:55   Duration & Cooldown
Reply With Quote #1

Hello.

i tried my best to make this zombie class skills with duration & cooldown.
Like the time of climb is 10 seconds and when duration of climb end he will wait 10 secnods to climb again.

can anyone please help me to solve this.

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <cstrike>
#include <zombieplague>
#include <hamsandwich>
//#include <fakemeta_util>

#define STR_T           33

// Stuff taken from fakemeta_util
#define fm_get_user_button(%1) pev(%1, pev_button)    
/* stock fm_get_user_button(index)
    return pev(index, pev_button) */

#define fm_get_entity_flags(%1) pev(%1, pev_flags)
/* stock fm_get_entity_flags(index)
    return pev(index, pev_flags) */

stock fm_set_user_velocity(entity, const Float:vector[3]) {
    
set_pev(entitypev_velocityvector);

    return 
1;
}
//End of stuff from fakemeta_util
//new STR_T[32]
new Float:g_lastusetime[33]
new 
Float:g_nextuse[33]
new 
bool:g_WallClimb[33]
new 
Float:g_wallorigin[32][3]
new 
cvar_zp_wallclimbcvar_zp_wallclimb_nemesiscvar_zp_wallclimb_survivorcvar_climb_cooldowncvar_climb_duration
new g_zclass_climb
  
// Climb Zombie Atributes
new const zclass_name[] = { "Climb Zombie" // name
new const zclass_info[] = { "HP-- Speed+ Jump+ Knockback++" // description
new const zclass_model[] = { "sirenzz" // model
new const zclass_clawmodel[] = { "v_knife_zombie.mdl" // claw model
const zclass_health 1200 // health
const zclass_speed 220 // speed
const Float:zclass_gravity 0.8 // gravity
const Float:zclass_knockback 1.5 // knockback

public plugin_init() 
{
    
register_plugin("[ZP] Wallclimb ""1.0""WallClimb by Python1320/Cheap_Suit, Plagued by Dabbi")
    
register_forward(FM_Touch,         "fwd_touch")
    
register_forward(FM_PlayerPreThink,     "fwd_playerprethink")
    
//register_forward(FM_PlayerPostThink,     "fwd_playerpostthink")
    
register_event("DeathMsg","EventDeathMsg","a")
    
cvar_zp_wallclimb register_cvar("zp_wallclimb""1")
    
cvar_zp_wallclimb_survivor register_cvar("zp_wallclimb_survivor""0")
    
cvar_zp_wallclimb_nemesis register_cvar("zp_wallclimb_nemesis""0")
    
cvar_climb_cooldown register_cvar("zp_wallclimb_cooldown""10.0"
    
cvar_climb_duration register_cvar("zp_wallclimb_duration""10.0"
    
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawn"1);
    
RegisterHam(Ham_Killed"player""FwdPlayerKilled"1);
    
}

public 
plugin_precache()
{
    
g_zclass_climb zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}

public 
EventDeathMsg()    
{
    new 
id read_data(2)
    
g_WallClimb[id] = true
    
return PLUGIN_HANDLED
}

public 
FwdPlayerSpawn(id)
{
    if(!
is_user_alive(id)) return HAM_IGNORED;
    
    
ResetPlayerData(id);

    return 
HAM_IGNORED;
}

public 
FwdPlayerKilled(id)
    
ResetPlayerData(id);

public 
client_disconnected(id)
    
ResetPlayerData(id);

public 
client_putinserver(id)
    
ResetPlayerData(id);

public 
client_connect(id) {
    
g_WallClimb[id] = true    
}

public 
fwd_touch(idworld)
{
    if(!
is_user_alive(id) || !g_WallClimb[id] || !pev_valid(id))
        return 
FMRES_IGNORED

    
new player STR_T
    
if (!player)
        return 
FMRES_IGNORED
        
    
new classname[STR_T]
    
pev(worldpev_classnameclassname, (STR_T))
    
    if(
equal(classname"worldspawn") || equal(classname"func_wall") || equal(classname"func_breakable"))
        
pev(idpev_origing_wallorigin[id])

    return 
FMRES_IGNORED
}

public 
client_PreThink(id)
{
    if(
zp_get_user_zombie_class(id) == g_zclass_climb
        {
        if(!
is_user_alive(id) || !zp_get_user_zombie(id)) return PLUGIN_CONTINUE;

        new 
Float:gametime get_gametime();
        new 
Float:timeleft_climb g_nextuse[id] - gametime;
        
        if( 
timeleft_climb >= 0.0)
        {
            
set_hudmessage(255255255, -1.00.8016.012.00.01.08);
            
show_hudmessage(id"[WallClimb]^nDuration^n> %.1f <"timeleft_climb);
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
checking(idbutton)
     if(
g_WallClimb[id])
             
wallclimb(idbutton)

public 
wallclimb(idbutton)
{
    static 
Float:origin[3]
    
pev(idpev_originorigin)

    if(
get_distance_f(origing_wallorigin[id]) > 25.0)
        return 
FMRES_IGNORED  // if not near wall
    
    
if(fm_get_entity_flags(id) & FL_ONGROUND)
        return 
FMRES_IGNORED
        
            
if(button IN_FORWARD)
            {
               static 
Float:velocity[3]
               
velocity_by_aim(id120velocity)
               
fm_set_user_velocity(idvelocity)
            }
            else if(
button IN_BACK)
            {
               static 
Float:velocity[3]
               
velocity_by_aim(id, -120velocity)
               
fm_set_user_velocity(idvelocity)
            }
    
    return 
FMRES_IGNORED
}    

public 
fwd_playerprethink(id
{
    new 
Float:gametime get_gametime();
    if(!
g_WallClimb[id] || !zp_get_user_zombie(id)) 
        return 
FMRES_IGNORED
        
    
if(zp_is_survivor_round() && get_pcvar_num(cvar_zp_wallclimb_survivor) == 0)
        return 
FMRES_IGNORED
        
    
if(zp_is_nemesis_round() && get_pcvar_num(cvar_zp_wallclimb_nemesis) == 0)
        return 
FMRES_IGNORED
    
    
new button fm_get_user_button(id)
    
    new 
Float:cooldown get_pcvar_float(cvar_climb_cooldown)
    new 
Float:duration get_pcvar_float(cvar_climb_duration)
    
    
//set_task(duration, "RemoveClimb", id)
    //g_WallClimb[id] = true
    
if (gametime >= g_lastusetime[id])
    {
            
g_nextuse[id] = gametime duration;
            
g_lastusetime[id] = gametime duration cooldown;
    }
    else
    {
            
set_hudmessage(255255255, -1.00.2016.012.00.01.0, -1);
            
show_hudmessage(id"[WallClimb]^nCooldown^n> %.1f <"g_lastusetime[id] - gametime);
    }
    if((
get_pcvar_num(cvar_zp_wallclimb) == 1) && (button IN_USE) && (zp_get_user_zombie_class(id) == g_zclass_climb)) //Use button = climb
    
wallclimb(idbutton)
    else if((
get_pcvar_num(cvar_zp_wallclimb) == 2) && (button IN_JUMP) && button IN_DUCK && (zp_get_user_zombie_class(id) == g_zclass_climb)) //Jump + Duck = climb
    
wallclimb(idbutton)
    
g_WallClimb[id] = true
    
return FMRES_IGNORED
}

public 
RemoveClimb(id)
{
        
g_WallClimb[id] = false
}

ResetPlayerData(id)
{
    
g_lastusetime[id] = 0.0;
    
g_nextuse[id] = 0.0;

Attached Files
File Type: sma Get Plugin or Get Source (zp_class_climb.sma - 12 views - 5.9 KB)

Last edited by Hn.S Xmix; 05-03-2024 at 10:57.
Hn.S Xmix is offline
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-03-2024 , 20:10   Re: Duration & Cooldown
Reply With Quote #2

Quote:
Originally Posted by Hn.S Xmix View Post
Hello.

i tried my best to make this zombie class skills with duration & cooldown.
Like the time of climb is 10 seconds and when duration of climb end he will wait 10 secnods to climb again.

can anyone please help me to solve this.
Here
PHP Code:
#include <amxmodx>
//#include <cstrike>
//#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

new Float:g_lastusetime[33]
new 
Float:g_nextuse[33]
new 
Float:g_wallorigin[33][3]
new 
cvar_zp_wallclimbcvar_zp_wallclimb_nemesiscvar_zp_wallclimb_survivorcvar_climb_cooldowncvar_climb_duration
new g_zclass_climb
  
// Climb Zombie Atributes
new const zclass_name[] = { "Climb Zombie" // name
new const zclass_info[] = { "HP-- Speed+ Jump+ Knockback++" // description
new const zclass_model[] = { "sirenzz" // model
new const zclass_clawmodel[] = { "v_knife_zombie.mdl" // claw model
new const zclass_health 1200 // health
new const zclass_speed 220 // speed
new const Float:zclass_gravity 0.8 // gravity
new const Float:zclass_knockback 1.5 // knockback

public plugin_init() 
{
    
register_plugin("[ZP] Wallclimb ""1.0""WallClimb by Python1320/Cheap_Suit, Plagued by Dabbi")
    
register_forward(FM_Touch,         "fwd_touch")
    
register_forward(FM_PlayerPreThink,     "fwd_playerprethink")
    
RegisterHam(Ham_Killed"player""FwdPlayerKilled"1);

    
cvar_zp_wallclimb register_cvar("zp_wallclimb""1")
    
cvar_zp_wallclimb_survivor register_cvar("zp_wallclimb_survivor""0")
    
cvar_zp_wallclimb_nemesis register_cvar("zp_wallclimb_nemesis""0")
    
cvar_climb_cooldown register_cvar("zp_wallclimb_cooldown""10.0"
    
cvar_climb_duration register_cvar("zp_wallclimb_duration""10.0"
}

public 
plugin_precache()
{
    
g_zclass_climb zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}

public 
FwdPlayerKilled(id)
{
    
ResetPlayerData(id);
}

public 
client_putinserver(id)
{
    
ResetPlayerData(id);
}

public 
fwd_touch(idworld)
{
    if(
id && id 33)
    {
        new 
classname[33]
        
pev(worldpev_classnameclassname32)

        if(
equal(classname"worldspawn") || equal(classname"func_wall") || equal(classname"func_breakable"))
        {
            
pev(idpev_origing_wallorigin[id])
        }
    }
}

public 
fwd_playerprethink(id
{
//    if(!is_user_alive(id))
    
if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_climb || (zp_is_survivor_round() && get_pcvar_num(cvar_zp_wallclimb_survivor) == 0) || (zp_is_nemesis_round() && get_pcvar_num(cvar_zp_wallclimb_nemesis) == 0))
    {
        return 
FMRES_IGNORED;
    }

    new 
Float:gametime get_gametime();
    new 
Float:cooldown get_pcvar_float(cvar_climb_cooldown)
    new 
Float:duration get_pcvar_float(cvar_climb_duration)
    new 
button pev(idpev_button)

    if(
get_pcvar_num(cvar_zp_wallclimb) == && button IN_USE || (get_pcvar_num(cvar_zp_wallclimb) == && button IN_JUMP && button IN_DUCK)) // Use or Jump + Duck = climb
    
{
        if(
gametime >= g_nextuse[id])
        {
            
g_nextuse[id] = gametime duration cooldown;
            
g_lastusetime[id] = gametime duration;
        }
        else
        {
            if(
gametime >= g_lastusetime[id])
            {
                
set_hudmessage(255255255, -1.00.2000.01.00.00.5, -1);
                
show_hudmessage(id"[WallClimb]^nCooldown^n> %.1f <"g_nextuse[id] - gametime);
            }
            else
            {
                
wallclimb(idbutton)
                
set_hudmessage(255255255, -1.00.2000.01.00.00.5, -1);
                
show_hudmessage(id"[WallClimb]^nClimb time left^n> %.1f <"g_lastusetime[id] - gametime);
            }
        }
    }

    return 
FMRES_IGNORED;
}

public 
wallclimb(idbutton)
{
    static 
Float:origin[3]
    
pev(idpev_originorigin)

    if(
get_distance_f(origing_wallorigin[id]) > 25.0)
    {
        return 
FMRES_IGNORED  // if not near wall
    
}

    if(
button IN_FORWARD)
    {
        static 
Float:velocity[3]
        
velocity_by_aim(id120velocity)
        
set_pev(idpev_velocityvelocity)
    }
    else if(
button IN_BACK)
    {
        static 
Float:velocity[3]
        
velocity_by_aim(id, -120velocity)
        
set_pev(idpev_velocityvelocity)
    }

    return 
FMRES_IGNORED
}    

ResetPlayerData(id)
{
    
g_lastusetime[id] = 0.0;
    
g_nextuse[id] = 0.0;


Last edited by v120kaaimcfg; 05-04-2024 at 07:00.
v120kaaimcfg is offline
Hn.S Xmix
Member
Join Date: May 2021
Old 05-04-2024 , 04:54   Re: Duration & Cooldown
Reply With Quote #3

ITS WORKING!!! wow

But there is one problem, why duration and cooldown stop counting when a player stop holding a KEY_USE, it still kinda weird when duration and cooldown is controlled by player

I would be greatly appreciated if you could fix this plugin bcs its so important in my server
Hn.S Xmix is offline
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-04-2024 , 06:55   Re: Duration & Cooldown
Reply With Quote #4

Quote:
Originally Posted by Hn.S Xmix View Post
ITS WORKING!!! wow

But there is one problem, why duration and cooldown stop counting when a player stop holding a KEY_USE, it still kinda weird when duration and cooldown is controlled by player

I would be greatly appreciated if you could fix this plugin bcs its so important in my server
They don't stop "counting", they just don't appear on the HUD anymore. The first frame the player is IN_USE or IN_DUCK+IN_JUMP the plugin calculates values for last use time and next use time which are respectively controlled by the two cvars zp_wallclimb_cooldown && zp_wallclimb_duration:
1. Player has the climb skill ready to go
2. Player uses IN_USE button/IN_DUCK+IN_JUMP
3. variables for till when he can use the skill (g_lastusetime[id]) and when the next time he'll be able to use the skill after the last use time expires (g_nextuse[id]) are calculated
4. player can use the skill whenever he wants in the time period between his first use of the skill and the last set time. After that time expires the skill goes into cooldown for the set amount of time until the cooldown expires and the cycle repeats.

Basically the player only controls when to start the countdown for his 10 second climb skill usage(that's what I understood from the code you gave). The HUD is merely informative. You can edit it in any way you want to.

Last edited by v120kaaimcfg; 05-04-2024 at 06:57.
v120kaaimcfg is offline
Hn.S Xmix
Member
Join Date: May 2021
Old 05-04-2024 , 11:39   Re: Duration & Cooldown
Reply With Quote #5

Quote:
Originally Posted by v120kaaimcfg View Post
They don't stop "counting", they just don't appear on the HUD anymore. The first frame the player is IN_USE or IN_DUCK+IN_JUMP the plugin calculates values for last use time and next use time which are respectively controlled by the two cvars zp_wallclimb_cooldown && zp_wallclimb_duration:
1. Player has the climb skill ready to go
2. Player uses IN_USE button/IN_DUCK+IN_JUMP
3. variables for till when he can use the skill (g_lastusetime[id]) and when the next time he'll be able to use the skill after the last use time expires (g_nextuse[id]) are calculated
4. player can use the skill whenever he wants in the time period between his first use of the skill and the last set time. After that time expires the skill goes into cooldown for the set amount of time until the cooldown expires and the cycle repeats.

Basically the player only controls when to start the countdown for his 10 second climb skill usage(that's what I understood from the code you gave). The HUD is merely informative. You can edit it in any way you want to.

Yes you're right everything you said is true i should pay more attention. I test it again right now and it works exactly as you said, i can barely understand the codes its not that complicated

But there is 2 small and tiny problems
..

1-Duration will start immediately if the player press KEY_USE in the air without even facing walls
2-if player stop holding KEY_USE the cooldown will not start deliberately it will wait until duration end so the player can climb again at that time

Is it possible to fix it? My requesting are just too much bcs this plugin is very important in my server
Hn.S Xmix is offline
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-04-2024 , 12:54   Re: Duration & Cooldown
Reply With Quote #6

Quote:
Originally Posted by Hn.S Xmix View Post

Yes you're right everything you said is true i should pay more attention. I test it again right now and it works exactly as you said, i can barely understand the codes its not that complicated

But there is 2 small and tiny problems
..

1-Duration will start immediately if the player press KEY_USE in the air without even facing walls
2-if player stop holding KEY_USE the cooldown will not start deliberately it will wait until duration end so the player can climb again at that time

Is it possible to fix it? My requesting are just too much bcs this plugin is very important in my server
Be more specific about what you want the plugin to DO and what you want it to NOT DO. As detailed as possible.
v120kaaimcfg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2024 , 21:56   Re: Duration & Cooldown
Reply With Quote #7

Please stop using large text for absolutely no reason.
__________________
fysiks is offline
Hn.S Xmix
Member
Join Date: May 2021
Old 05-05-2024 , 15:16   Re: Duration & Cooldown
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
Please stop using large text for absolutely no reason.
Ma bad
Hn.S Xmix is offline
Hn.S Xmix
Member
Join Date: May 2021
Old 05-05-2024 , 16:17   Re: Duration & Cooldown
Reply With Quote #9

Quote:
Originally Posted by v120kaaimcfg View Post
Be more specific about what you want the plugin to DO and what you want it to NOT DO. As detailed as possible.

Bug1 : If players press E to use parachute the duration will start counting before even climbing.
request1 : is there any way to make duration start only while climbing?

Bug2 : If player stop holding E while climbing the walls.. the cooldown will not start until duration end at that time the player can climb again until duration end.
Request2 : is there any way to make cooldown start immediately if players climbing so they will have to wait 10 second to climb again


Im just asking questions if its possible or not, i can make a video if you don't understand my request.

Last edited by Hn.S Xmix; 05-05-2024 at 16:20.
Hn.S Xmix is offline
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-05-2024 , 16:42   Re: Duration & Cooldown
Reply With Quote #10

Quote:
Originally Posted by Hn.S Xmix View Post
Bug1 : If players press E to use parachute the duration will start counting before even climbing.
request1 : is there any way to make duration start only while climbing?

Bug2 : If player stop holding E while climbing the walls.. the cooldown will not start until duration end at that time the player can climb again until duration end.
Request2 : is there any way to make cooldown start immediately if players climbing so they will have to wait 10 second to climb again


Im just asking questions if its possible or not, i can make a video if you don't understand my request.
So you want the player to be able to climb for cvar time(10) seconds, the climbing will activate only when you're near a wall and if you release the climbing button/s it goes automatically on cooldown, instead of letting them climb again until the time runs out?
If I haven't understood correctly, correct me and a video would come in handy (probably).
v120kaaimcfg is offline
Reply



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 02:48.


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