AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   I have 2 questions (https://forums.alliedmods.net/showthread.php?t=55721)

B1ondu 05-28-2007 09:31

I have 2 questions
 
1.How to catch +attack ?
2.How to check if current model is cell?

regalis 05-28-2007 09:39

Re: I have 2 questions
 
I would register prethink and check in there if user button +attack.
Like this:
Code:

public plugin_init()
{
    register_forward(FM_PlayerPreThink, "fm_playerthink", 1)
}

public fm_playerthink(id)
{
    if(pev(id, pev_button) & IN_ATTACK)
    {
        // do something
    }
}

What do you mean with "model is cell"?

greetz regalis

B1ondu 05-28-2007 09:41

Re: I have 2 questions
 
cell is a model ^^

regalis 05-28-2007 09:46

Re: I have 2 questions
 
Hmm, don't really know how to do this but i think that should work:
*edit* you need to include <fakemeta> for both ;) *edit*
Code:

new model[32]
pev(id, pev_model, model, 31)
if(equal(model, "cell")
{
    // do something :P
}

greetz regalis

B1ondu 05-28-2007 09:52

Re: I have 2 questions
 
thx, now other question:

How to check how much time i pressed +attack?

regalis 05-28-2007 10:08

Re: I have 2 questions
 
Here you go:
Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_attack[33];

public plugin_init()
{
    register_forward(FM_PlayerPreThink, "fm_playerthink", 1)
    set_task(2.0, "display_attack_num", 110477, "", 0, "b")
}

public fm_playerthink(id)
{
    if((pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_oldbuttons) & IN_ATTACK))
    {
        // do something
        g_attack[id]++;
    }
}

public display_attack_num()
{
    new playercount, Players[32]
    get_players(Players, playercount,"a")
    for (new i=0; i < playercount; ++i)
    {
        client_print(Players[i], print_chat, "attacks: %d", g_attack[Players[i]])
    }
}


+karma would be nice! ;)

B1ondu 05-28-2007 10:12

Re: I have 2 questions
 
thx

+karma man ;)

B1ondu 05-28-2007 10:17

Re: I have 2 questions
 
LOL other questions ^^

How to check if a player hold +attack ?

regalis 05-28-2007 10:27

Re: I have 2 questions
 
I think this should work :)
Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_attack[33];
new holding_attack[33];

public plugin_init()
{
    register_forward(FM_PlayerPreThink, "fm_playerthink", 1);
    set_task(2.0, "display_attack_num", 110477, "", 0, "b");
}


public fm_playerthink(id)
{
        if((pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_oldbuttons) & IN_ATTACK))
        {
            holding_attack[id] = true;
            g_attack[id]++;
        }
        if((pev(id, pev_oldbuttons) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK))
        {
            holding_attack[id] = false;
        }
}

public display_attack_num()
{
    new playercount, Players[32]
    get_players(Players, playercount,"a")
    for (new i=0; i < playercount; ++i)
    {
        client_print(Players[i], print_chat, "attacks: %d - in-attack: %s", g_attack[Players[i]], holding_attack[Players[i]] ? "true" : "false");
    }
}


_Master_ 05-28-2007 16:53

Re: I have 2 questions
 
I would use FM_CmdStart instead of FM_PlayerPreThink


All times are GMT -4. The time now is 10:41.

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