AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pev_button, i dont understand very well... (https://forums.alliedmods.net/showthread.php?t=90009)

_lol_ 04-12-2009 22:47

pev_button, i dont understand very well...
 
well, i am doing a plugin, but i have a problem...i want to do that when a player is ducking, the viewmodel will be one, but, that when the player is not ducking, the viewmodel will be another...
this is my code.
Code:

            // Get currently pressed buttons
            static buttons
            buttons = pev(id, pev_button)
       
            if(buttons & IN_DUCK)
            {
                set_pev(id, pev_viewmodel, 0)
            }
            else
            {
                set_pev(id, pev_viewmodel, zclass_clawmodel)
            }

it is working, but not at all, because if at the time that this function is called, you are ducking, you wont have any viewmodel, but if you stop ducking, you will still without any viewmodel lol!

so...whats the problem?

ot_207 04-13-2009 00:10

Re: pev_button, i dont understand very well...
 
The code you have used is correct. But it depends where are this function is placed.
If you put it for example in PRETHINK it would work like a charm :).

Arkshine 04-13-2009 06:22

Re: pev_button, i dont understand very well...
 
You're wrong Anggara_nothing.

_lol_ 04-13-2009 12:50

Re: pev_button, i dont understand very well...
 
so...whats bad now...the debug client_print IS working, but there is no model, ducking or not doing it...


Code:

public client_PreThink(id)
{
    if (!is_user_alive(id))
        return;
       
    if(zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_invisible)
    {
        // Get currently pressed buttons
        static buttons
        buttons = pev(id, pev_button)
       
       
        if(!(buttons & IN_DUCK))
        {
            client_print(id, print_chat, "[DEBUG] unducking.");
            set_pev(id, pev_viewmodel, zclass_clawmodel)
        }
        if(buttons & IN_DUCK)
        {
            client_print(id, print_chat, "[DEBUG] ducking");
            set_pev(id, pev_viewmodel, 0)
        }
       
    }
}

EDIT:this is the constant...
Code:

new const zclass_clawmodel[] = { "v_knife_zombie.mdl" } // claw model


All times are GMT -4. The time now is 02:20.

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