AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Need to change leap's keys from CROUCH and JUMP (https://forums.alliedmods.net/showthread.php?t=309336)

jigore 07-22-2018 04:53

[Help] Need to change leap's keys from CROUCH and JUMP
 
I need help with key changing, want to make leap only after pressing +forward 3 times, but I am new to pawn, so cant do it myself.
Code:

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

#define PLUGIN "plugin"
#define VERSION "ver"
#define AUTHOR "author"

/*based on zp_leap*/

#define TASK_ID 1337

new www_leap
new www_time
new bool:g_hasLeap[33]
new Float:g_lastLeaptime[33]
new g_Leap_force
new g_Leap_height
new g_Leap_cooldown

public ()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        g_Leap_force = register_cvar("www_force", "550")
        g_Leap_height = register_cvar("www_height", "255")
        g_Leap_cooldown = register_cvar("www_cooldown", "5.0")
        www_leap = register_cvar("www_leap","1")
        www_time = register_cvar("www_leap_time","15.0")
       
        register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
       
        register_event("DeathMsg", "death", "a")
        register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}

public client_disconnect(id)
{
    g_hasLeap[id] = false;
    if ( task_exists(TASK_ID+id) )
        remove_task(TASK_ID+id)
}

public death()
{
        g_hasLeap[read_data(2)] = false
}

public zp_user_humanized_pre(id)
{
        if (is_user_alive(id) && zp_get_user_zombie(id))
        {
        if (get_pcvar_num(www_leap))
        {
                set_task(1.00, "CountDown", id + 1337, "", 0, "", 0);
                new Float:leap_float = get_pcvar_float(www_time);
                set_task(leap_float, "leap_begin", id, "", 0, "", 0);
                }
        }
        return PLUGIN_HANDLED
}   

public event_round_start()
{
        for (new i = 1; i <= 32; i++)
                g_hasLeap[i] = true
}

public zp_user_infected_post(id, infector)
{
                g_hasLeap[id] = false
}

public leap_begin(id)
{
        if (!is_user_alive(id))
                return PLUGIN_HANDLED
       
        if (zp_get_user_zombie(id))
        {
                g_hasLeap[id] = true
                remove_task(TASK_ID+id)
        }
        return PLUGIN_HANDLED
}

public fw_PlayerPreThink(id)
{
        if (!is_user_alive(id))
                return FMRES_IGNORED
       
        if (leap_longjump(id))
        {
                static Float:velocity[3]
                velocity_by_aim(id, get_pcvar_num(g_Leap_force), velocity)
               
                velocity[2] = get_pcvar_float(g_Leap_height)
               
                set_pev(id, pev_velocity, velocity)
               
                g_lastLeaptime[id] = get_gametime()
        }
       
        return FMRES_IGNORED
}

leap_longjump(id)
{
        if (!g_hasLeap[id])
                return false
       
        if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
                return false
       
        static buttons
        buttons = pev(id, pev_button)
       
        if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))
                return false
       
        if (get_gametime() - g_lastLeaptime[id] < get_pcvar_float(g_Leap_cooldown))
                return false
       
        return true
}

stock fm_get_speed(entity)
{
        static Float:velocity[3]
        pev(entity, pev_velocity, velocity)
       
        return floatround(vector_length(velocity))
}


Celena Luna 07-22-2018 05:43

Re: [Help] Need to change leap's keys from CROUCH and JUMP
 
Quote:

Originally Posted by edon1337 (Post 2605091)
Why are you posting in Scripting help section when you have no knowledge on Scripting then?

So please post in the Request/Suggest Section.


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

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