Skocz do zawartości

Nowy szablon forum

mygo.pl

Stworzyliśmy dla Was nowy wygląd forum. Z pewnością znajdziesz rzeczy, które wg Ciebie mogą zostać zmienione - wspomnij o tym w specjalnym wątku.

Czytaj więcej

Jak założyć własną sieć

serwerów CS

Zastanawiasz się nad prowadzeniem własnej sieci serwerów? Przeczytaj podstawowe informacje, na które należy zwrócić uwagę, przy takim projekcie.

Czytaj więcej

Tworzymy spis sieci

dodaj swoją

Dodaj sieć do której należysz, pozwoli to na promocję i budowę ogólnopolskiej bazy sieci CS.

Czytaj więcej

RSSPlugin fix request


MYGO.pl
 Udostępnij

Rekomendowane odpowiedzi

  • RSSy
Hello people ! I want to ask for some help with my long jump plugin. First is the version that works, but it is badly written and should be written in a better way. The second code is my attempt at better writing, but it doesn't work. Can anyone help me with the second option ??? Why is not it working ???

This is the working one :
Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cromchat>

#define PLUGIN    "Long Jump"
#define VERSION  "1.0"
#define AUTHOR    "MayroN, tes-onez crew"

new g_msgStatusIcon;
new g_jumps[33];
new g_showJumpMessage[33];
new Float:g_lastJumpTime[33];

new const MAX_JUMPS_CVAR[] = "maxjumps";
new maxJumps;
new g_hasDisplayedMessage[33];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    register_cvar(MAX_JUMPS_CVAR, "3");

    g_msgStatusIcon = get_user_msgid("StatusIcon");

    for (new i = 0; i < 33; i++)
    {
        g_showJumpMessage[i] = true;
        g_hasDisplayedMessage[i] = false;
    }

    maxJumps = get_cvar_num(MAX_JUMPS_CVAR);

    RegisterHam(Ham_Player_PreThink, "player", "Player_Jump");
    RegisterHam(Ham_Killed, "player", "Hook_Icon");

    register_forward(FM_CmdStart, "Show_Icon");

    register_clcmd("amx_cvar", "CvarChangeHandler");
}

public CvarChangeHandler(id, const cmd[], argc)
{
    if (argc >= 3 && equali(cmd, MAX_JUMPS_CVAR))
    {
        maxJumps = get_cvar_num(MAX_JUMPS_CVAR);
    }
    return PLUGIN_CONTINUE;
}

public Show_Icon(id, uc_handle, seed)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;

    if (g_jumps[id] < maxJumps)
    {
        if (get_user_weapon(id) == CSW_KNIFE)
        {
            StatusIcon(id, 1);
            if (!g_hasDisplayedMessage[id])
            {
                CC_SendMatched(id, CC_COLOR_TEAM, "&x04%n&x01, you have &x04Long Jump &x01ability (&x04Jumps Left&x01: &x07%d&x01/&x04%d&x01)", id, maxJumps - g_jumps[id], maxJumps);
                g_hasDisplayedMessage[id] = true;
            }
        }
        else
        {
            StatusIcon(id, 0);
        }
    }
    else
    {
        StatusIcon(id, 0);
        if (g_lastJumpTime[id] > 0.0 && get_gametime() - g_lastJumpTime[id] < 2.0)
        {
            CC_SendMatched(id, CC_COLOR_TEAM, "&x03%n&x01, you have used all &x04Long Jumps", id);
            g_lastJumpTime[id] = 0.0;
        }
    }

    return FMRES_IGNORED;
}

public Player_Jump(id)
{
    static buttons, oldbuttons;

    buttons = pev(id, pev_button);
    oldbuttons = pev(id, pev_oldbuttons);

    if (buttons & IN_DUCK && buttons & IN_JUMP && !(oldbuttons & IN_JUMP) && (pev(id, pev_flags) & FL_ONGROUND))
    {
        if (g_jumps[id] < maxJumps && get_user_weapon(id) == CSW_KNIFE)
        {
            g_jumps[id]++;
            set_speed(id, 500.0);

            static Float:velocity[3];
            pev(id, pev_velocity, velocity);

            velocity[2] = 800 / 3.0;

            if ((pev(id, pev_button) & (IN_LEFT | IN_RIGHT)))
            {
                velocity[0] *= -1;
                velocity[1] *= -1;
            }

            set_pev(id, pev_velocity, velocity);

            if (g_jumps[id] >= maxJumps)
            {
                StatusIcon(id, 0);
                g_showJumpMessage[id] = true;
                g_hasDisplayedMessage[id] = false;
            }
            else
            {
                g_showJumpMessage[id] = true;
                g_hasDisplayedMessage[id] = false;
            }

            g_lastJumpTime[id] = get_gametime();
        }
    }
    else if (g_lastJumpTime[id] > 0.0 && get_gametime() - g_lastJumpTime[id] > 2.0)
    {
        g_lastJumpTime[id] = 0.0;
        g_showJumpMessage[id] = false;
        g_hasDisplayedMessage[id] = false;
    }
}

stock set_speed(ent, Float:speed)
{
    if(!pev_valid(ent))
        return;

    static Float:vangle[3], Float:new_velo[3], Float:y, Float:x;
    if(ent<=get_maxplayers())
    {
        pev(ent,pev_v_angle,vangle);
    }

    pev(ent,pev_velocity,new_velo);

    y = new_velo[0]*new_velo[0] + new_velo[1]*new_velo[1];
    if(y) x = floatsqroot(speed*speed / y);

    new_velo[0] *= x;
    new_velo[1] *= x;

    if(speed<0.0)
    {
        new_velo[0] *= -1;
        new_velo[1] *= -1;
    }

    set_pev(ent,pev_velocity,new_velo);
}

StatusIcon(id, run)

    if(!is_user_connected(id))
        return;
   
    message_begin(MSG_ONE, g_msgStatusIcon, {0,0,0}, id);
    write_byte(run);
    write_string("item_longjump");
    write_byte(0);
    write_byte(220);
    write_byte(220);
    message_end();
}

public Hook_Icon(id)
{
    StatusIcon(id, 0);
    g_jumps[id] = 0;
    g_lastJumpTime[id] = 0.0;
    g_showJumpMessage[id] = false;
    g_hasDisplayedMessage[id] = false;
}

And this is my trial version for better writing, but it's not working, can someone help me :
Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cromchat>

#define PLUGIN    "Long Jump"
#define VERSION  "1.0"
#define AUTHOR    "MayroN, tes-onez crew"

new g_msgStatusIcon;
new g_jumps[33];
new g_showJumpMessage[33];
new Float:g_lastJumpTime[33];

new maxJumps;
new g_hasDisplayedMessage[33];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    register_cvar("maxjumps", "3");

    g_msgStatusIcon = get_user_msgid("StatusIcon");

    for (new i = 0; i < 33; i++)
    {
        g_showJumpMessage[i] = true;
        g_hasDisplayedMessage[i] = false;
    }

    RegisterHam(Ham_Player_PreThink, "player", "Player_Jump");
    RegisterHam(Ham_Killed, "player", "Hook_Icon");

    register_forward(FM_CmdStart, "Show_Icon");

    hook_cvar_change(register_cvar("maxjumps", "3"), "Cvars_Updating");
}

public Cvars_Updating(pcvar, const old_value[], const new_value[])
{
    maxJumps = get_pcvar_num(pcvar);
}

public Show_Icon(id, uc_handle, seed)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;

    if (g_jumps[id] < maxJumps)
    {
        if (get_user_weapon(id) == CSW_KNIFE)
        {
            StatusIcon(id, 1);
            if (!g_hasDisplayedMessage[id])
            {
                CC_SendMatched(id, CC_COLOR_TEAM, "&x04%n&x01, you have &x04Long Jump &x01ability (&x04Jumps Left&x01: &x07%d&x01/&x04%d&x01)", id, maxJumps - g_jumps[id], maxJumps);
                g_hasDisplayedMessage[id] = true;
            }
        }
        else
        {
            StatusIcon(id, 0);
        }
    }
    else
    {
        StatusIcon(id, 0);
        if (g_lastJumpTime[id] > 0.0 && get_gametime() - g_lastJumpTime[id] < 2.0)
        {
            CC_SendMatched(id, CC_COLOR_TEAM, "&x03%n&x01, you have used all &x04Long Jumps", id);
            g_lastJumpTime[id] = 0.0;
        }
    }

    return FMRES_IGNORED;
}

public Player_Jump(id)
{
    static buttons, oldbuttons;

    buttons = pev(id, pev_button);
    oldbuttons = pev(id, pev_oldbuttons);

    if (buttons & IN_DUCK && buttons & IN_JUMP && !(oldbuttons & IN_JUMP) && (pev(id, pev_flags) & FL_ONGROUND))
    {
        if (g_jumps[id] < maxJumps && get_user_weapon(id) == CSW_KNIFE)
        {
            g_jumps[id]++;
            set_speed(id, 500.0);

            static Float:velocity[3];
            pev(id, pev_velocity, velocity);

            velocity[2] = 800 / 3.0;

            if ((pev(id, pev_button) & (IN_LEFT | IN_RIGHT)))
            {
                velocity[0] *= -1;
                velocity[1] *= -1;
            }

            set_pev(id, pev_velocity, velocity);

            if (g_jumps[id] >= maxJumps)
            {
                StatusIcon(id, 0);
                g_showJumpMessage[id] = true;
                g_hasDisplayedMessage[id] = false;
            }
            else
            {
                g_showJumpMessage[id] = true;
                g_hasDisplayedMessage[id] = false;
            }

            g_lastJumpTime[id] = get_gametime();
        }
    }
    else if (g_lastJumpTime[id] > 0.0 && get_gametime() - g_lastJumpTime[id] > 2.0)
    {
        g_lastJumpTime[id] = 0.0;
        g_showJumpMessage[id] = false;
        g_hasDisplayedMessage[id] = false;
    }
}

stock set_speed(ent, Float:speed)
{
    if(!pev_valid(ent))
        return;

    static Float:vangle[3], Float:new_velo[3], Float:y, Float:x;
    if(ent<=get_maxplayers())
    {
        pev(ent,pev_v_angle,vangle);
    }

    pev(ent,pev_velocity,new_velo);

    y = new_velo[0]*new_velo[0] + new_velo[1]*new_velo[1];
    if(y) x = floatsqroot(speed*speed / y);

    new_velo[0] *= x;
    new_velo[1] *= x;

    if(speed<0.0)
    {
        new_velo[0] *= -1;
        new_velo[1] *= -1;
    }

    set_pev(ent,pev_velocity,new_velo);
}

StatusIcon(id, run)

    if(!is_user_connected(id))
        return;

    message_begin(MSG_ONE, g_msgStatusIcon, {0,0,0}, id);
    write_byte(run);
    write_string("item_longjump");
    write_byte(0);
    write_byte(220);
    write_byte(220);
    message_end();
}

public Hook_Icon(id)
{
    StatusIcon(id, 0);
    g_jumps[id] = 0;
    g_lastJumpTime[id] = 0.0;
    g_showJumpMessage[id] = false;
    g_hasDisplayedMessage[id] = false;
}

Przeczytaj cały wpis

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...