AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pev_button (https://forums.alliedmods.net/showthread.php?t=217921)

Randomize 06-09-2013 08:50

pev_button
 
PHP Code:

public client_PreThink(id)
{
    if(
is_user_connectedid ) && is_user_aliveid ))
    {
        if( 
pev(idpev_button) & IN_DUCK )
        {
            
client_print(idprint_chat"Duck")
            
        }
        else
        {
            
client_print(idprint_chat"Stand")
        }
    }


When I crouched, it worked well and print the "Duck" well. But when I didn't stand, the client_print flood. Did it use CPU process highly? Or is there any good method? I'm afraid it'll make the CS lag.

ConnorMcLeod 06-09-2013 09:16

Re: pev_button
 
PHP Code:

public client_PreThink(id)
{
    if( 
is_user_aliveid ) )
    {
        new 
button entity_get_int(idEV_INT_button);
        new 
buttonsChanged button entity_get_int(idEV_INT_oldbuttons);

        if( 
buttonsChanged IN_DUCK )
        {
            if( 
button IN_DUCK )
            {
                
client_print(idprint_chat"Duck")
            }
            else
            {
                
client_print(idprint_chat"Stand")
            }
        }
    }



Randomize 06-09-2013 09:37

Re: pev_button
 
Still flood chat.

ConnorMcLeod 06-09-2013 09:41

Re: pev_button
 
No, make sure you have code after my edition.

Randomize 06-09-2013 10:35

Re: pev_button
 
Something like this?
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <acg>

#define PLUGIN "Crouch"
#define VERSION "1.0"
#define AUTHOR "DavidJr"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
// Add your code here...
}
public 
plugin_precache()
{    
    
precache_generic("gfx/csf/crouch.tga")
    
precache_generic("gfx/csf/stand.tga")
}
public 
client_PreThink(id)
{
    if( 
is_user_aliveid ) )
    {
        new 
button entity_get_int(idEV_INT_button);
        new 
buttonsChanged button entity_get_int(idEV_INT_oldbuttons);

        if( 
buttonsChanged IN_DUCK )
        {
            if( 
button IN_DUCK )
            {
                
//acg_drawtga(id, "gfx/csf/crouch.tga", 255, 255, 255, 50, 0.1375, 0.065, 0, FX_NONE, 0.0, 0.0, 0.0, 0.0, 0, ALIGN_RIGHT | ALIGN_BOTTOM, 2)
                
client_print(idprint_chat"Duck")
            }
            else
            {
                
//acg_drawtga(id, "gfx/csf/stand.tga", 255, 255, 255, 50,  0.1375, 0.065, 0, FX_NONE, 0.0, 0.0, 0.0, 0.0, 0, ALIGN_RIGHT |  ALIGN_BOTTOM, 2)
                
client_print(idprint_chat"Stand")
            }
        }
    }


and sorry, I typed 1 line code wrong from the first post.
PHP Code:

if( pev(idpev_button) & IN_DUCK )
        {
            
client_print(idprint_chat"Jongkok")
            
        }
        if( !(
pev(idpev_oldbuttons) & IN_DUCK) )
        {
            
client_print(idprint_chat"Berdiri")
        } 


President 06-09-2013 11:59

Re: pev_button
 
PHP Code:

public client_PreThink(id)
{
        if(!
is_user_alive(id)) return;
        
        if(
pev(idpev_button) & IN_DUCK)
                if(
pev(idpev_flags) & FL_DUCKING)
                         
client_print(idprint_chat"Duck");
        else 
client_print(idprint_chat"Standing");


You don't have to check if the player is connected. He can't think (execute client_PreThink) when he isn't in the game.


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

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