AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blocking input while dead (https://forums.alliedmods.net/showthread.php?t=60706)

Des12 09-10-2007 18:07

Blocking input while dead
 
Hello everyone, I'm once again coding for The Specialists, and in The Specialists, once a player dies he must press +attack to respawn.

Blocking IN_ATTACK works perfectly when the player is alive, but does not work at all when he is dead.

Code:
public client_PreThink(id) {     if(!is_user_alive(id)) { // if I take away, person still can spawn but can't attack while alive         if(g_spawnblock[id] > 0) { //is always > 0             new bufferstop = entity_get_int(id,EV_INT_button)                 if(bufferstop != 0) {                 entity_set_int(id,EV_INT_button,bufferstop & ~IN_ATTACK & ~IN_ATTACK2 & ~IN_USE & ~IN_ALT1)             }                                       return PLUGIN_HANDLED;         }     } }

Strange, anyone have a solution to preventing someone from spawning?

Des12 09-27-2007 20:18

Re: Blocking input while dead
 
Bump, well is it possible to hook a respawn message and block it? How do you block messages?

X-Script 09-27-2007 20:24

Re: Blocking input while dead
 
you mean?

PHP Code:

#include <amxmodx>
#include <engine>

public plugin_init() {
    
register_plugin("LOL","ROFL","PWN");
    
    
register_cvar("mp_deathblock","0");
    
    
register_message(get_user_msgid("DeathMsg"),"message");
    
    new 
mod[32];
    
get_modname(mod,31);
    
    if(
equal(mod,"ts")) {
        
register_message(get_user_msgid("TSMessage"),"message");
        
register_cvar("mp_tsmessageblock","0");
    }
}

public 
message(msg_id,msg_dest,msg_entity) {
    new 
mod[32];
    
get_modname(mod,31);
    if(
msg_id == get_user_msgid("DeathMsg")) {
        if(
get_cvar_num("mp_deathblock") >= 1) {
            return 
PLUGIN_HANDLED;
        }
    }
    if(
equal(mod,"ts")) {
        if(
msg_id == get_user_msgid("TSMessage")) {
            if(
get_cvar_num("mp_tsmessageblock") >= 1) {
                new 
msg[92];
                
get_msg_arg_string(6,msg,91);
                if(!
is_integer(msg) && !equal(msg,"Press Fire To Play!")) {
                    return 
PLUGIN_HANDLED;
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}

stock bool:is_integer(str[]) {
    new 
istr str_to_num(str);
    new 
restr[32];
    
num_to_str(istr,restr,31);
    if(
equal(str,restr)) {
        return 
true;
    }
    return 
false;



Wilson [29th ID] 09-29-2007 14:53

Re: Blocking input while dead
 
No, that's not what he means.

Des12, debug. First start simple and give it an echo so you know the global variables that you claim are always above 0 are actually above 0, for example.

Code:
Change:             if(bufferstop != 0) {                 entity_set_int(id,EV_INT_button,bufferstop & ~IN_ATTACK & ~IN_ATTACK2 & ~IN_USE & ~IN_ALT1)             } TO:             if(bufferstop != 0) {                 entity_set_int(id,EV_INT_button,bufferstop & ~IN_ATTACK)                 client_print(id,print_chat,"Stopped Attack")             }

And take out PLUGIN_HANDLED - you don't need that there.

I would bet you don't get any echo, which will tell you that the error lies before the button setting, in your variable testing code.

potatis_invalido 10-01-2007 05:39

Re: Blocking input while dead
 
This works in Counter-Strike.
You need AMX Mod X 1.80 or Ham Sandwich installed.
Code:

#include <amxmodx>
#include <hamsandwich>
 
public plugin_init()
{
    RegisterHam(Ham_Spawn, "player", "ham_spawn_player");
}
 
public ham_spawn_player(id)
{
    if(!is_user_alive(id))
    {
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}


purple_pixie 10-01-2007 12:01

Re: Blocking input while dead
 
It just depends whether or not TS sends a Ham_Spawn on player spawn or does it some other way.

Only one way to find out ...


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

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